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

Mutation will throw a missing store field if a query before errored or was canceled #647

Closed
rricard opened this issue Sep 14, 2016 · 2 comments
Assignees
Labels

Comments

@rricard
Copy link
Contributor

rricard commented Sep 14, 2016

This following line will throw: https://github.com/apollostack/apollo-client/blob/master/src/data/diffAgainstStore.ts#L339 on a mutation if a query before was canceled or errored. This is bad since it makes fail every mutation even the unrelated ones! I had hard time pinpointing this one but we should find an elegant solution to it. For now I'll try to set globally throwOnMissingField to false but I think we have ways to be smarter (preventing to register a failed or canceled result is one of those)

The stack I got is here:

Can't find field searchNodes({"query":"TEST","limit":40,"cursor":null}) on object ($ROOT_QUERY.connection({"id":"xxx"})) {
  "service": {
    "type": "id",
    "id": "$ROOT_QUERY.connection({\"id\":\"xxx\"}).service",
    "generated": true
  },
  "disconnected": false,
  "pins": [
    "$ROOT_QUERY.connection({\"id\":\"xxx\"}).pins.0",
    "$ROOT_QUERY.connection({\"id\":\"xxx\"}).pins.1",
    "$ROOT_QUERY.connection({\"id\":\"xxx\"}).pins.2",
    "$ROOT_QUERY.connection({\"id\":\"xxx\"}).pins.3"
  ],
  "user": {
    "type": "id",
    "id": "$ROOT_QUERY.connection({\"id\":\"xxx\"}).user",
    "generated": true
  },
  "id": "xxx",
  "handle": "xxx",
  "node({\"id\":\"root\"})": {
    "type": "id",
    "id": "$ROOT_QUERY.connection({\"id\":\"xxx\"}).node({\"id\":\"root\"})",
    "generated": true
  },
  "nodeChildren({\"id\":\"root\",\"limit\":40,\"cursor\":null,\"sortBy\":null})": {
    "type": "id",
    "id": "$ROOT_QUERY.connection({\"id\":\"xxx\"}).nodeChildren({\"id\":\"root\",\"limit\":40,\"cursor\":null,\"sortBy\":null})",
    "generated": true
  }
}.
Perhaps you want to use the `returnPartialData` option?"

Error
    at new ApolloError (webpack:///./~/apollo-client/errors.js?:14:22)
    at diffFieldAgainstStore (webpack:///./~/apollo-client/data/diffAgainstStore.js?:201:19)
    at eval (webpack:///./~/apollo-client/data/diffAgainstStore.js?:73:30)
    at Array.forEach (native)
    at diffSelectionSetAgainstStore (webpack:///./~/apollo-client/data/diffAgainstStore.js?:61:29)
    at diffFieldAgainstStore (webpack:///./~/apollo-client/data/diffAgainstStore.js?:256:16)
    at eval (webpack:///./~/apollo-client/data/diffAgainstStore.js?:73:30)
    at Array.forEach (native)
    at Object.diffSelectionSetAgainstStore (webpack:///./~/apollo-client/data/diffAgainstStore.js?:61:29)
    at Object.readSelectionSetFromStore (webpack:///./~/apollo-client/data/readFromStore.js?:31:37)
@rricard rricard changed the title Client will throw a missing store field if a request errored or was canceled Mutaion will throw a missing store field if a query before errored or was canceled Sep 14, 2016
@rricard rricard changed the title Mutaion will throw a missing store field if a query before errored or was canceled Mutation will throw a missing store field if a query before errored or was canceled Sep 14, 2016
@rricard
Copy link
Contributor Author

rricard commented Sep 15, 2016

Well! Got the source of the bug: when the mutation applies an updateQueries, a read in the store gets triggered and at this point, no returnPartialData is set. Now the question is what to do to fix it?

  • Proposition 1: we should find a way to have updateQueries ignore errored/cancelled queries
  • Proposition 2: execute updateQueries's store read using returnPartialData. This one can have nasty side effects in the implemented updateQueries reducers...

rricard added a commit that referenced this issue Sep 15, 2016
Post-mutation failing store reading during updateQueries.
@rricard
Copy link
Contributor Author

rricard commented Sep 15, 2016

I reproduced the bug in a test in #651

rricard added a commit that referenced this issue Sep 15, 2016
We avoid running the reducer on those cases

Fixes #647
rricard added a commit that referenced this issue Sep 16, 2016
Post-mutation failing store reading during updateQueries.
rricard added a commit that referenced this issue Sep 16, 2016
We avoid running the reducer on those cases

Fixes #647
rricard added a commit that referenced this issue Sep 19, 2016
Post-mutation failing store reading during updateQueries.
rricard added a commit that referenced this issue Sep 19, 2016
We avoid running the reducer on those cases

Fixes #647
rricard added a commit that referenced this issue Sep 20, 2016
Post-mutation failing store reading during updateQueries.
rricard added a commit that referenced this issue Sep 20, 2016
We avoid running the reducer on those cases

Fixes #647
rricard added a commit that referenced this issue Sep 21, 2016
Post-mutation failing store reading during updateQueries.
rricard added a commit that referenced this issue Sep 21, 2016
We avoid running the reducer on those cases

Fixes #647
rricard added a commit that referenced this issue Sep 22, 2016
Post-mutation failing store reading during updateQueries.
rricard added a commit that referenced this issue Sep 27, 2016
Post-mutation failing store reading during updateQueries.
rricard added a commit that referenced this issue Sep 28, 2016
Post-mutation failing store reading during updateQueries.
helfer added a commit that referenced this issue Sep 29, 2016
Fix #647 - Read store in returnPartialData mode if the previous queries failed or were cancelled
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants