-
Notifications
You must be signed in to change notification settings - Fork 783
Unknown directive "client" #1898
Comments
The same thing. Everything is ok when I query data from my server but I get the error when trying to do one with a client directive. |
I added an empty resolvers object to clientState configuration and everything seems to be alright now. Before that I had only defaults object so I guess we must specify both to get everything work. The fact is documentation says that those are optional. |
Yeah, it seem to add defaults, resolvers object although the docs said it's not require. Thanks @Vladiio |
@Vladiio, can you show the code with comments? |
Hi. Here I have the same error. I have the following code: Mutation mutation Alerts {
updateAlerts(input: {}) @client
} Resolvers export const resolvers = {
Mutation: {
updateAlerts: () => null
}
}; Client const client = new ApolloClient({
link: authLink.concat(httpLink),
cache,
clientState: {
resolvers
}
}); As you can see, everything is empty to avoid other bugs. And the error I get is: Error: GraphQL error: Cannot query field "updateAlerts" on type "Mutation". My idea here is to create a new object inside the Apollo cache to store application alerts state locally, but if it cannot find the mutation, I have no idea how to make it work. |
@goodok21 I don't have it anymore. |
Thanks, @Vladiio. That is the solution. I have found this amazing VIDEO among the documentation, and the example works like a charm. Once you create an initial state, the rest is using it as a normal server with queries and mutations. You even can see it in the Apollo dev tools in Chrome. Pretty cool :) |
@Vladiio's solution worked for me as well. Here's my setup:
|
Guys! check this Initialize Local State
Add this code after initialize ApolloClient, because we need to write initial data to the cache to. |
I still get the same error in Apollo 2.5 and can't figure out why. I follwed the documentation for Apollo-client 2.5, yet the client directive is still unknown to the client. Is it necessary to manually declare it in the client schema? Error Package Versions Apollo client implementation Query |
@preciserobot Would you mind opening a new issue with the contents of #1898 (comment)? |
Got the same issue switching to 2.5.1 following the documentation https://www.apollographql.com/docs/react/essentials/local-state.html#migrating
PS: removed appollo boost dependency and it seems to work again.. |
I've encountered an issue that seems to be related to yours. I've answered here |
Hi all, first, thanks for watching my issue.
I don't know how to fix this issue when I add "@client" on my gql to query local data, log will be print this error:
[GraphQL error]: Message: Unknown directive "client"., Location: [object Object], Path: undefined
I searched but can't find any solution for this issue.
Thanks for help.
The text was updated successfully, but these errors were encountered: