Error: Network error: Error writing result to store request (Apollo Client)

I use Apollo Client to make an application to query my server using Graphql. I have a python server on which I execute my graphql queries that retrieve data from a database and then return it to the client.

I created a custom NetworkInterface for the client that helps me make an individual server request (by default, ApolloClient makes a POST call to the specified URL). The network interface must have a query () method in which we return a promise for the form result Promise<ExecutionResult>.

I can make a server call and get the requested data, but still get the following error.

Error: Network error: Error writing result to store for query 
{
   query something{
      row{
         data
      }
   }
}
Cannot read property 'row' of undefined
    at new ApolloError (ApolloError.js:32)
    at ObservableQuery.currentResult (ObservableQuery.js:76)
    at GraphQL.dataForChild (react-apollo.browser.umd.js:410)
    at GraphQL.render (react-apollo.browser.umd.js:448)
    at ReactCompositeComponent.js:796
    at measureLifeCyclePerf (ReactCompositeComponent.js:75)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:795)
    at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js:822)
    at ReactCompositeComponentWrapper._updateRenderedComponent (ReactCompositeComponent.js:746)
    at ReactCompositeComponentWrapper._performComponentUpdate (ReactCompositeComponent.js:724)
    at ReactCompositeComponentWrapper.updateComponent (ReactCompositeComponent.js:645)
    at ReactCompositeComponentWrapper.performUpdateIfNecessary (ReactCompositeComponent.js:561)
    at Object.performUpdateIfNecessary (ReactReconciler.js:157)
    at runBatchedUpdates (ReactUpdates.js:150)
    at ReactReconcileTransaction.perform (Transaction.js:140)
    at ReactUpdatesFlushTransaction.perform (Transaction.js:140)
    at ReactUpdatesFlushTransaction.perform (ReactUpdates.js:89)
    at Object.flushBatchedUpdates (ReactUpdates.js:172)
    at ReactDefaultBatchingStrategyTransaction.closeAll (Transaction.js:206)
    at ReactDefaultBatchingStrategyTransaction.perform (Transaction.js:153)
    at Object.batchedUpdates (ReactDefaultBatchingStrategy.js:62)
    at Object.enqueueUpdate (ReactUpdates.js:200)

I want to know the possible cause of the error and the solution, if possible.

+15
4

. , . ,

query  {
  service:me {
    productServices {
      id
      title
    }
  }
}

query  {
  service:me {
    **id**
    productServices {
      id
      title
    }
  }
}
+9

id, .

{
   query something {
      id
      row {
         id
         data
      }
   }
}
+3

.

, ( ) ?

player team:

// Apollo option object for `mutation AddPlayer`
update: (store, response) => {
  const addr = { query: gql(QUERY_TEAM), variables: { _id } };
  const data = store.readQuery(addr);
  stored.teams.players.push(response.data.player));
  store.writeQuery({...addr, data});
}

( Apollo 2.0.2)

, QUERY_TEAM meta null. , "" * stringified addr . , include: null:

// Apollo option object for `mutation AddPlayer`
update: (store, response) => {
  const addr = { query: gql(QUERY_TEAM), variables: { _id, meta: null } };
  const data = store.readQuery(addr);
  data.teams.players.push(response.data.player));
  store.writeQuery({...addr, data});
}

.

* undefined null ()

, , , :

, 3 node_modules/apollo-cache-inmemory/lib/writeToStore.js, , "" . _a, , .

exports.writeResultToStore = writeResultToStore;
function writeSelectionSetToStore(_a) {

    var result = _a.result, dataId = _a.dataId, selectionSet = _a.selectionSet, context = _a.context;
    var variables = context.variables, store = context.store, fragmentMap = context.fragmentMap;

    +if (typeof result === 'undefined') {
    +    debugger;
    +}

, , ,

+2

- , . , , apollo-cache-inmemory apollo-cache-hermes.

, , , , , apollo-cache-inmemory. , , apollo-cache-inmemory, hermes . , , , , . apollo-cache-inmemory , . id , . id , . , .

This is not a mistake - it works as intended, it is simply not documented anywhere - see this specification spec . I really would like Apollo to document this restriction somewhere.

+1
source

All Articles