React-apollo: refetchQueries should have "skip" option

Created on 28 Jun 2017  路  5Comments  路  Source: apollographql/react-apollo

Steps to Reproduce

const ADD_THING = gql mutation addThing($var1: String!, $var2: String) { addThing(var1: $var1, var2: $var2) { _id name } }

const withAddThing = graphql(ADD_THING, {
props:({ mutate }) => ({
addThing: ({ var1, var2 }) => mutate({
variables: {var1, var2},
refetchQueries: [{
query: ANOTHER_QUERY,
skip: !!var2,
variables: { _id: var2 },
fetchPolicy: 'network-only'
}]
})
})
})

In example above, var2 is an optional variable, if only it is there, we want to do a refetch query.

Currently skip option seem to be completely ignored.

Version

  • react-apollo@<1.2.0>
feature

Most helpful comment

@HeatherZh currently skip is only managed by the react integration, not part of the core api. This does sound like a great feature though!

All 5 comments

Thanks @HeatherZh! I didn't know there even is a skip argument on refetchQueries! Where did you find that? It's definitely a feature we could add, if it would be useful.

Maybe it is my wishful thinking :) I figured if graphql query wrapper supports "skip" as documented in http://dev.apollodata.com/react/queries.html#graphql-skip, all the other query wrappers would support the same options.

I do think it could be very useful if one can conditionally control refetchQueries based on variables, results or errors returned from the mutation.

I am getting around this by doing a conditional client.query after a successful mutation for now.

Thanks for your response!

@HeatherZh currently skip is only managed by the react integration, not part of the core api. This does sound like a great feature though!

This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo!

@helfer what's the status of this feature?

Was this page helpful?
0 / 5 - 0 ratings