我正在使用Apollo Client创建一个应用程序来使用Graphql查询我的服务器 . 我有一个python服务器,我在其上执行我的graphql查询,从数据库中获取数据,然后将其返回给客户端 .
我为客户端创建了一个自定义NetworkInterface,帮助我制作定制服务器请求(默认情况下,ApolloClient对我们指定的URL进行POST调用) . 网络接口只需要有一个query()方法,其中我们返回表单 Promise<ExecutionResult>
的结果的promise .
我能够进行服务器调用并获取所请求的数据但仍然收到以下错误 .
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)
如果可能的话,我想知道错误和解决方案的可能原因 .
1 回答
我有一个类似的问题 .
也许你的应用程序试图用错误的商店地址写入(网络响应数据)到商店?
解决我的问题
将
player
添加到team
后,我正在更新商店:我开始上面遇到类似的错误(我在Apollo 2.0.2上)
在深入商店后,我意识到我的
QUERY_TEAM
请求是用一个变量meta
默认为null
. 商店"address"似乎使用* stringifiedaddr
来识别记录 . 所以我改变了上面的代码来模仿包括null:这解决了我的问题 .
*默认为undefined而不是null可能会避免这个讨厌的bug(未经验证)
更多信息
我的问题可能只是切线相关,所以如果这没有帮助我有两个建议:
First ,将这3行添加到
node_modules/apollo-cache-inmemory/lib/writeToStore.js
,以便在"record"为空时提醒您 . 然后调查_a
以了解出了什么问题 .Second ,确保使用您期望的变量保存所有查询,突变和手动存储更新