-
Notifications
You must be signed in to change notification settings - Fork 100
Resolvers should look for a custom resolver first, but this would break the mixed @client / server query #226
Comments
Hi @PCreations, can you please send in a PR with the failing test and fix? It's impossible for me to see the file diff otherwise. Thanks! |
Sure thing ! Here we go : #235 |
any chance someone could explain the "this would break the mixed @client / server query" bit? My team is running into this issue and are looking to help with a fix. |
Related: #272 |
Still running into this issue, anyone looking into this or pointers for a fix? Happy to take a stab at this myself. |
@marktani I just tested on Apollo client 2.1 and this seems to be, for lack of a better word, resolved. If you can migrate then it will probably solve the problem, complete with async resolution: Example client side schema
For example, defining this as the resolver: const client = new ApolloClient({
cache,
resolvers: {
Query: {
getTasks: (root, variables, { cache, getCacheKey }) => {
return [
{
__typename: "Task",
id: "test"
}
];
}
},
// Help to resolve the dependencies
Task: {
comments: async () => {
return [
{
__typename: "Comment",
id: "commentId",
commentText: "the work text"
},
{
__typename: "Comment",
id: "commentId2",
commentText: "another comment"
}
];
}
}
},
typeDefs
});
const GET_TASKS = gql`
query {
getTasks @client {
id
comments {
id
commentText
}
}
}
`; |
I am experiencing this issue currently when nesting more than one level. I will try and get around to a complete code example soon. For now I'm looking for workarounds. Here is the quick and dirty: This works, resolving both
This query breaks complaining that there is no
|
When resolving a field, the
resolve
function should first look for a custom resolver, thus simulating the same behavior as on a server :With
apollo-link-state
, due to this statement stating that if there is a field in the root value, it's because the server already sent something. It's not true, this statement should be valid only if we are at theQuery
level.Here is a failing test :
Quick edit (to be refactored) to make all the tests pass (this one included) :
in
index.js
The text was updated successfully, but these errors were encountered: