The second example in the link does not work.
Intended outcome:
refetchQueries should also accept an array
OR
the example should use the function
`refetchQueries`: (mutationResult: FetchResult) => Array<{ query: DocumentNode, variables?: TVariables}>
Actual outcome:
Uncaught Error: query option is required. You must specify your GraphQL document in the query option.
How to reproduce the issue:
Doing this results in the error above.
import { REFETCH_QUERY } from '...';
const MUTATION = gql`...`;
export default graphql(MUTATION, {
options: {
refetchQueries: [
{ query: REFETCH_QUERY },
],
},
})(MyComponent);
changing refetchQueries to a function works
refetchQueries: () => [
{ query: REFETCH_QUERY },
],
Version
[email protected]
relevant snippet of code
https://github.com/apollographql/apollo-client/blob/9ac90e0c1729d11a41663c9a7032200369f3305d/packages/apollo-client/src/core/QueryManager.ts#L254-L265
This appears to have been addressed (the mentioned examples are working with apollo-client
2.3.3). If anyone notices otherwise, please let me know (ideally with a reproduction). Thanks!
how can I refetch a Query and tell it to reuse the previous vars,
without me knowing what those vars where.
@japrogramer That used to work by providing a list of strings to refetchQueries, but with latest react-apollo & apollo-client, the store doesn't always update.
Most helpful comment
how can I refetch a Query and tell it to reuse the previous vars,
without me knowing what those vars where.