node.js - 如何从导致突变失败的graphql响应中删除`__typename`字段
问题描述
我尝试在 GraphQL 的 Apollo 客户端中更改 addTypeName: false
apollo.create({
link: httpLinkWithErrorHandling,
cache: new InMemoryCache({ addTypename: false }),
defaultOptions: {
watchQuery: {
fetchPolicy: 'network-only',
errorPolicy: 'all'
}
}
但它有效,它在控制台中抛出以下消息
fragmentMatcher.js:26 You're using fragments in your queries, but either don't have the addTypename:true option set in Apollo Client, or you are trying to write a fragment to the store without the __typename.Please turn on the addTypename option and include __typename when writing fragments so that Apollo Clientcan accurately match fragments.
,
Could not find __typename on Fragment PopulatedOutageType
和
fragmentMatcher.js:28 DEPRECATION WARNING: using fragments without __typename is unsupported behavior and will be removed in future versions of Apollo client. You should fix this and set addTypename to true now.
即使我将 false 更改为 true new InMemoryCache({ addTypename: true }),
,由于突变中不需要的类型名,突变也会开始失败
有什么办法可以解决这个问题
解决方案
在上面的帖子中,我已经发布了这个问题的答案,请参考它
推荐阅读
- javascript - 无论如何,为什么从多个文件导入时 Firebase 会重新初始化?
- ios - Swift 中“vanilla”枚举上的 switch 语句是否在恒定时间内执行?
- flutter - Flutter:如何将变量从 statefulwidget 传递给其他 statefulwidget
- regex - PowerShell\Regex 删除字符串中特定字符集之前的所有变量字符
- android - 如果文本是从另一个 Activity 和 OnBackpressed 函数获取的,我想在 TextView 上使用 Shared Preferences
- docker - 使用 docker-compose 实现零停机时间部署?
- jvm - UnknowHostException 网络恢复时无法恢复,但重启 JVM 解决了它
- c# - NReco.PdfToImageConverter 将 PDF 转换为图像时出现警告消息框
- c++ - 使用 fopen 写入 UTF-16LE 内容时防止写入 BOM
- python - Python不和谐机器人烫发