React-apollo: updateQuery removes data from original result

Created on 23 Apr 2017  路  3Comments  路  Source: apollographql/react-apollo

The issue is when data is sent down via a subscription, updateQuery is ran and the new data is merged into old data. The result is removed from the object.

Steps to Reproduce

I've created a reproduction of the issue I'm having https://github.com/jakelacey2012/react-apollo-subscription-problem here.

I've included the server and the front end, the front end is where I feel the issue is and here is the main bulk of the code which I've put into one file.

https://github.com/jakelacey2012/react-apollo-subscription-problem/blob/master/experiment-frontend/src/App.js

Frontend

Is just a create-react-app, just yarn & yarn start should get you going there.

Server

yarn & yarn start

Buggy Behavior

so this

initial query

after updateQuery results in this

result after updateQuery

Expected Behavior

I would expect the new data to be merge in, because that is what I'm returning from the updateQuery in the subscribe to more function

Version

Thank you in advance, any help would be massively appreciated.

Most helpful comment

@jakelacey2012 it looks like your subscription onNoteAdded is not returning the same fields as NotesQuery (created is missing). Let me know if that helps!

All 3 comments

@jakelacey2012 it looks like your subscription onNoteAdded is not returning the same fields as NotesQuery (created is missing). Let me know if that helps!

Thank you!! It worked!!

I guess this actually makes sense because you want the new data to be the same 'shape' at the old data. Is there any documentation that expresses this?

I think it's not in the docs because this issue has been coming up a few times lately 馃槃

related: apollographql/apollo-client#1611

Was this page helpful?
0 / 5 - 0 ratings