2

const GET_QUESTION = gql `
query getQuestion($id:String!){
    question(id:$id) {
    id
    text
    title
  }
  isEditMode @client
}
`

I am running this above query where isEditMode is from Apollo Link State and in this situtation the cache is empty and therefore isEditMode is not defined in the cache so the whole query comes back undefined. Is this always the case with Apollo Batching. Solutions?

Eli
  • 827
  • 1
  • 7
  • 21
  • is not editMode part of your question query? it should be inside the question `{}` – Pavan Aug 21 '19 at 18:06
  • @Pavan editMode is not part of the question query its an apollo-link-state that I am batching in the query – Eli Aug 21 '19 at 19:36
  • It's not clear what you're asking here. By "batching" do you mean just requesting multiple fields on the `Query` type? Or are you actually [batching your requests](https://www.apollographql.com/docs/link/links/batch-http)? – Daniel Rearden Aug 21 '19 at 20:42
  • It's also not totally clear what the actual result you're seeing is. The returned `data` will always be undefined until the query finishes loading. At this point, it may be `null` if you encountered some error, but it should never be `undefined`. Please edit your question to show how you're actually calling the query and using the result and provide as much detail as to the data you're getting back and if you are also seeing any errors. – Daniel Rearden Aug 21 '19 at 20:45
  • Also, bear in mind that `apollo-link-state` is effectively deprecated since local state management has been integrated into `apollo-client` since version 2.5. Any troubleshooting around `apollo-link-state` will be difficult. It's highly advisable that you migrate to using the newer API. – Daniel Rearden Aug 21 '19 at 20:47

0 Answers0