Apollo-client: Bad "Perhaps you want to use the 'returnPartialData' option?" error.

Created on 18 Oct 2016  路  13Comments  路  Source: apollographql/apollo-client

I've been seeing Perhaps you want to use the 'returnPartialData' option? errors since upgrading to 0.4.21. This seems to happen when props change while the previous a query is in flight.

The issue seems to be that the previous query is still in flight but the variables change so the QueryManager thinks data should already been in the store and it bails trying to find that data.
https://github.com/apollostack/apollo-client/blob/master/src/core/QueryManager.ts#L341

queryStoreValue.previousVariables is populated so it tries to read the resultFromStore but that data doesn't exist in the store since the original query is still in flight.

I don't have a minimal test case repo for this.

馃悶 bug

Most helpful comment

@helfer It does seem to be fixed in 0.5.0-preview.3.

All 13 comments

Can you try with version 0.5.0-1?

Trying to run with 0.5.0-1 gives me the following error:
"Network error: this.queryObservable._setOptionsNoResult is not a function"
I suspect that [email protected] isn't compatible with this release.

Oh, that's true. We're almost done updating it.

FYI: This is still an issue using "apollo-client": "^0.5.0-1" and "react-apollo": "^0.5.13".

I think we might be seeing this in galaxy-server (though I only see it when I turn on "pause on thrown exceptions"; I see a different TypeError when I don't)

I think this would be a lot easier to address with a test case - we'll try to get to it soon, but I think it should be possible to reproduce by using ObservableQuery#setVariables while a query is in flight (that can be mocked using the delay option in mockNetworkInterface).

@NeoPhi are you saying you got the error with 0.4.21 and above, but not with 0.4.20?

@helfer I jumped from "apollo-client": "^0.4.14" and "react-apollo": "^0.5.1" to "apollo-client": "^0.4.21" and "react-apollo": "^0.5.10".

@stubailo This is a failing test that can be added to ObservableQuery.ts. I may not have the assertions correct.

    it('handles variables changing while in-flight', (done) => {
      const observable: ObservableQuery = mockWatchQuery({
        request: { query, variables },
        result: { data: dataOne },
        delay: 100,
      }, {
        request: { query, variables: differentVariables },
        result: { data: dataTwo },
        delay: 100,
      });

      setTimeout(() => observable.setVariables(differentVariables), 10);

      subscribeAndCount(done, observable, (handleCount, result) => {
        if (handleCount === 1) {
          assert.isTrue(result.loading);
        } else if (handleCount === 2) {
          assert.isFalse(result.loading);
          assert.deepEqual(result.data, dataTwo);
          done();
        }
      });
    });

At present on master this generates the error:

  1) ObservableQuery setVariables handles variables changing while in-flight:
     Network error: Can't find field people_one({"id":1}) on object (ROOT_QUERY) undefined.
Perhaps you want to use the `returnPartialData` option?

@NeoPhi awesome, thanks! I'll try to fix this today.

I think I have this fixed in #827 now, which we'll release as soon as it's merged into master.

@NeoPhi can you confirm that this is fixed in 0.5.0-preview.3?

@helfer It does seem to be fixed in 0.5.0-preview.3.

Was this page helpful?
0 / 5 - 0 ratings