我对 GraphQL 和 Apollo 非常陌生,我不明白下面的“aliasEmail”字段有什么问题。当我将此添加到查询时,我收到此错误消息。当我从查询中删除它时,一切正常。它在 'types.graphql' 中有很好的定义,只是一个简单的字符串字段。
index.js:2178 Unhandled (in react apollo:Apollo(withRouter(EmailSettingsContainer))) Error: Network
error: Error writing result to store for query:
query getCompanyForAliasEmailEditForm($companyId: ID) {
Company(id: $companyId) {
name
isTaxActive
telFixe
aliasEmail
telMobile
__typename
}
}
Store error: the application attempted to write an object with no
provided id but the store already contains an id of
Company:cje6xkcnxl83u01353a20p1t6 for this object. The selectionSet
that was trying to be written is:
Company(id: $companyId) {
name
isTaxActive
telFixe
aliasEmail
telMobile
__typename
}
Run Code Online (Sandbox Code Playgroud)
听起来在应用程序的其他地方已经有另一个查询,该查询也返回 Company 对象,并且该查询包括id(or _id) 字段,而本例中的查询没有。Apollo 使用 typename 和 id 为您的查询结果生成缓存键(除非使用 dataIdFromObject 修改此行为),因此当它检测到上述差异时会抛出错误。尝试在您的getCompanyForAliasEmailEditForm查询中包含 id 字段。
| 归档时间: |
|
| 查看次数: |
1138 次 |
| 最近记录: |