Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing field error from writeToStore.js in v2.5 #4419

Closed
borisyordanov opened this issue Feb 7, 2019 · 5 comments
Closed

Missing field error from writeToStore.js in v2.5 #4419

borisyordanov opened this issue Feb 7, 2019 · 5 comments
Assignees
Milestone

Comments

@borisyordanov
Copy link

Intended outcome:
I expected that cache.writeData() would change the client's cache.

Actual outcome:
I got a Missing field error from writeToStore.js.

How to reproduce the issue:

I was not able to reproduce this in the error-template. But here's what i have in my local setup

This is how i've set up the cache defaults

const localCache = new InMemoryCache();

const cacheDefaults = {
    investAmount: 999,
    investId: '123',
    investReferenceId: 'ABC'
};

localCache.writeData({
    data: cacheDefaults
});

If i try to write to the cache afterwards like so:

localCache.writeData({
            data: {
                investAmount: 1000,
                investId: 'newId',
                investReferenceId: 'newReference'
            }
        });

I get the error.

I normally wouldn't bother you with a bug that can't be reproduced, but seeing as how the packages are in beta i thought you might find the information useful

Versions

  System:
    OS: Windows 10
  Binaries:
    Node: 8.12.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.12.1 - C:\Users\by\AppData\Roaming\npm\yarn.CMD
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 44.17763.1.0
  npmPackages:
    apollo-cache: ^1.1.22 => 1.1.23
    apollo-cache-inmemory: 1.3.12 => 1.3.12
    apollo-client: ^2.5.0-beta.0 => 2.5.0-beta.0
    apollo-link: ^1.2.6 => 1.2.6
    apollo-link-error: ^1.1.5 => 1.1.5
    apollo-link-http: ^1.5.9 => 1.5.9
    react-apollo: ^2.5.0-beta.1 => 2.5.0-beta.1
@borisyordanov borisyordanov changed the title Missing field error from writeToStore.js in v2.5 Missing field error from writeToStore.js in v2.5 Feb 7, 2019
@benjamn benjamn added this to the Release 2.5.0 milestone Feb 7, 2019
@hwillson hwillson self-assigned this Feb 22, 2019
@lorensr
Copy link
Contributor

lorensr commented Mar 2, 2019

I get this warning after upgrading to 2.5 with:

export const USER_QUERY = gql`
  query UserQuery {
    currentUser {
      id
      firstName
    }
    loginInProgress @client
  }
`

My app makes this query on render, and the user isn't logged in, so currentUser returns null. It works fine w/ apollo-link-state.

Missing field loginInProgress in {
  "currentUser": null
}
(anonymous) @ writeToStore.js:83
./node_modules/apollo-cache-inmemory/lib/writeToStore.js.StoreWriter.writeSelectionSetToStore @ writeToStore.js:62
./node_modules/apollo-cache-inmemory/lib/writeToStore.js.StoreWriter.writeResultToStore @ writeToStore.js:40
./node_modules/apollo-cache-inmemory/lib/inMemoryCache.js.InMemoryCache.write @ inMemoryCache.js:119
./node_modules/apollo-client/bundle.esm.js.DataStore.markQueryResult @ bundle.esm.js:1926
(anonymous) @ bundle.esm.js:1704
step @ tslib.es6.js:97
(anonymous) @ tslib.es6.js:78
fulfilled @ tslib.es6.js:68
Promise.then (async)
step @ tslib.es6.js:70
(anonymous) @ tslib.es6.js:71
__awaiter @ tslib.es6.js:67
next @ bundle.esm.js:1676
notifySubscription @ Observable.js:130
onNotify @ Observable.js:165
next @ Observable.js:219
(anonymous) @ bundle.esm.js:69
next @ bundle.esm.js:69
notifySubscription @ Observable.js:126
onNotify @ Observable.js:161
next @ Observable.js:215
next @ index.js:26
notifySubscription @ Observable.js:126
onNotify @ Observable.js:161
next @ Observable.js:215
notifySubscription @ Observable.js:126
onNotify @ Observable.js:161
next @ Observable.js:215
(anonymous) @ httpLink.js:78
Promise.then (async)
(anonymous) @ httpLink.js:77
Subscription @ Observable.js:179
subscribe @ Observable.js:258
(anonymous) @ index.js:20
Promise.then (async)
(anonymous) @ index.js:19
Subscription @ Observable.js:179
subscribe @ Observable.js:258
(anonymous) @ index.js:17
Subscription @ Observable.js:179
subscribe @ Observable.js:258
(anonymous) @ bundle.esm.js:64
Subscription @ Observable.js:183
subscribe @ Observable.js:262
(anonymous) @ bundle.esm.js:1783
./node_modules/apollo-client/bundle.esm.js.QueryManager.fetchRequest @ bundle.esm.js:1658
(anonymous) @ bundle.esm.js:1112
step @ tslib.es6.js:97
(anonymous) @ tslib.es6.js:78
(anonymous) @ tslib.es6.js:71
__awaiter @ tslib.es6.js:67
./node_modules/apollo-client/bundle.esm.js.QueryManager.fetchQuery @ bundle.esm.js:1049
./node_modules/apollo-client/bundle.esm.js.QueryManager.startQuery @ bundle.esm.js:1443
./node_modules/apollo-client/bundle.esm.js.ObservableQuery.setUpQuery @ bundle.esm.js:393
./node_modules/apollo-client/bundle.esm.js.ObservableQuery.onSubscribe @ bundle.esm.js:365
(anonymous) @ bundle.esm.js:96
Subscription @ Observable.js:179
subscribe @ Observable.js:258
Query._this.startQuerySubscription @ react-apollo.esm.js:214
./node_modules/react-apollo/react-apollo.esm.js.Query.componentDidMount @ react-apollo.esm.js:327
commitLifeCycles @ react-dom.development.js:9784
commitAllLifeCycles @ react-dom.development.js:11455
callCallback @ react-dom.development.js:100
invokeGuardedCallbackDev @ react-dom.development.js:138
invokeGuardedCallback @ react-dom.development.js:187
commitRoot @ react-dom.development.js:11594
completeRoot @ react-dom.development.js:12502
performWorkOnRoot @ react-dom.development.js:12452
performWork @ react-dom.development.js:12370
performSyncWork @ react-dom.development.js:12347
requestWork @ react-dom.development.js:12247
scheduleWorkImpl @ react-dom.development.js:12122
scheduleWork @ react-dom.development.js:12082
scheduleRootUpdate @ react-dom.development.js:12710
updateContainerAtExpirationTime @ react-dom.development.js:12738
updateContainer @ react-dom.development.js:12765
./node_modules/react-dom/cjs/react-dom.development.js.ReactRoot.render @ react-dom.development.js:16069
(anonymous) @ react-dom.development.js:16488
unbatchedUpdates @ react-dom.development.js:12557
legacyRenderSubtreeIntoContainer @ react-dom.development.js:16484
render @ react-dom.development.js:16543
./src/index.js @ index.js:19
__webpack_require__ @ bootstrap 9f8cb37eb9ee3eb10bbd:678
fn @ bootstrap 9f8cb37eb9ee3eb10bbd:88
0 @ registerServiceWorker.js:108
__webpack_require__ @ bootstrap 9f8cb37eb9ee3eb10bbd:678
(anonymous) @ bootstrap 9f8cb37eb9ee3eb10bbd:724
(anonymous) @ bootstrap 9f8cb37eb9ee3eb10bbd:724

And when I'm logged in, I get this:

writeToStore.js:83 Missing field loginInProgress in {
  "currentUser": {
    "__typename": "User",
    "email": "fridayrah@gmail.com",
    "favoriteRevi

@borisyordanov
Copy link
Author

@lorensr Have you set up a resolver for the loginInProgress query?

@lorensr
Copy link
Contributor

lorensr commented Mar 2, 2019

No. Adding one removes the warning.

  resolvers: {
    Query: {
      loginInProgress: () => false
    }
  }

So the question is: is this intended behavior? Migration guide didn't mention the need for it:

https://www.apollographql.com/docs/react/essentials/local-state.html#migrating

@borisyordanov
Copy link
Author

I'm pretty sure that's how you were supposed to use it with apollo-link-state. Not sure why you weren't getting that error before

@borisyordanov
Copy link
Author

@hwillson I'm not longer able to reproduce this after upgrading to 2.5 so I'll close this

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants