opened
thomasttvo
username_0
When you have a query like this and prop1 has NEVER been set, while prop2 IS set, then the query returns undefined.
```graphql
  {
    prop1 @client
    prop2 @client
  }
```

**Intended outcome:**
it returns:
```
{ prop1: undefined, prop2: 'someValue' }
```

**Actual outcome:**
it returns
```
undefined
```   

**How to reproduce the issue:**
- set up a graphql query with the details above
- call apolloClient.writeData({data: {prop2: 'someValue' }})
- Notice the query returns data as `undefined`

**Versions**
  System:
    OS: macOS 10.15.4
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.19.1 - ~/.yarn/bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
  Browsers:
    Chrome: 84.0.4147.135
    Firefox: 72.0.2
    Safari: 13.1
  npmPackages:
    apollo-cache-persist: ^0.1.1 => 0.1.1
    apollo-client: 2.6.8
Query with multiple @client variables returned as undefined if one of them is not set
issue
created
sirugh
username_1
We ran into this problem as well and while I do think the error could be surfaced better, Apollo does document that if you do not define a type policy/read function for a `@client` field it will read the value directly from the cache. If the value is undefined, as in the property does not even exist, then the entire query fails.

So a solution would be to define a `read` function for `prop1` and try to read it from cache. Wrap the read in a try-catch and return your default state if it doesn't exist.

Alternatively you have to initialize your cache with default field entries for client side variables.
comment
created
lensbart
username_2
Just ran into the same issue as well. It seems like a good idea to provide a console warning in development mode when the query fails. Now it appears to happen silently, but I can’t think of a use case where this would be the desired behaviour?
comment
closed
hwillson
username_3
issue