React-apollo: updateQueries is not updating queries for mutations

Created on 4 Aug 2016  路  6Comments  路  Source: apollographql/react-apollo

We had a debugging session on the slack Apollo Stack #general channel. We were unable to get updateQueries to fire and update the queries.

I tried several approaches but the two main one were:

Both of those approaches are on separate commits for reference:

mapMutationsToProps: https://github.com/scottmcpherson/meteor-starter-kit/tree/51084e6064ab825d9ad99b8b6baf807e2e2d05df

client.mutate: https://github.com/scottmcpherson/meteor-starter-kit

bug

All 6 comments

It seems like your query is unnamed? https://github.com/scottmcpherson/meteor-starter-kit/blob/master/imports/ui/Tasks.js#L74-L80

Your query name should match what you are updating. So in your case it will be:

            query tasks {
              tasks {
                _id
                title
              }
            }

@scottmcpherson were you able to get updateQueries working by naming your query? I could not get it run either. updateQueries never fired for me, even with named query.

No, unfortunately not @sntran. Instead, I used a combination of polling and calling refetch on the data. My repo is up to date if you want to check it out

@scottmcpherson I would like to dig into the origin of your problem. Can you please help me to gather more information? A smaller reproduction demonstrating the issue would help a lot.

@scottmcpherson @sntran would it be possible for you to update to the newest build (it is a new API btw!). I've documented via testing how to get updateQueries to work: https://github.com/apollostack/react-apollo/blob/master/test/react-web/client/graphql/mutations.tsx#L314-L405

@jbaxleyiii , I have updated to 0.4.x and can verify that updateQueries work as expected. Thanks for the update!

Was this page helpful?
0 / 5 - 0 ratings