Jan Wilmake's Blog

Chat with This Blog

[Notes of a programmer]: Apollo store updates

These are my notes. Fuck you. It's just what I do. If you want a complete overview, better read the original documentation, haha :D https://www.apollographql.com/docs/react/features/cache-updates.html

Apollo store can be seen in RND

apollo identifies an objet by its __typename and id (must be _id or id) let's call it object-id htey call it dataIDFromObject) __typename is automatically added

Apollo 2.0 store is 5-10x faster because it doesn't need redux cache

There are 4 ways to get/change data from the store

  1. Automatic store updates happen if mutation results contain the ID and the affected field! Figure out a way to do this with sequelize!

  2. refetchQueries: [{query, variables }] supply that to mutate

  3. update: (store, {data: {....} }) => { full cotrol over the store via store.readquery, store.readfragment, store.writequery, store.writefragment with ({query, ?data}) as options }

  4. optimisticResponse { optimisticObject } <-- See docs for good examples

3/6/2018
apollographqlprogrammingnodejscoding