Apollo-link-state cache.writedata results in no field warning

When I cause a mutation on my client, I get the following warning:

writeToStore.js: 111 Missing updateLocale field in {}

This is my condition:

const stateLink = withClientState({ cache, resolvers: { Mutation: { updateLocale: (root, { locale }, context) => { context.cache.writeData({ data: { language: { __typename: 'Language', locale, }, }, }); }, }, }, defaults: { language: { __typename: 'Language', locale: 'nl', }, }, }); 

And this is my component:

 export default graphql(gql` mutation updateLocale($locale: String) { updateLocale(locale: $locale) @client } `, { props: ({ mutate }) => ({ updateLocale: locale => mutate({ variables: { locale }, }), }), })(LanguagePicker); 

What am I missing?

+4
source share
1 answer

I received the same warning and solved it by returning data from the mutation method.

 updateLocale: (root, { locale }, context) => { const data = { language: { __typename: 'Language', locale, } }; context.cache.writeData({ data }); return data; }; 
+7
source

Source: https://habr.com/ru/post/1275050/


All Articles