gpt4 book ai didi

node.js - 如何从导致突变失败的 graphql 响应中删除 `__typename` 字段

转载 作者:行者123 更新时间:2023-12-02 14:50:01 26 4
gpt4 key购买 nike

我尝试在 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 }), 由于突变中存在不需要的类型名,突变也会开始失败

有什么办法可以解决这个问题

最佳答案

Cleaning Unwanted Fields From GraphQL Responses

在上面的帖子中,我已经发布了这个问题的答案,请引用

关于node.js - 如何从导致突变失败的 graphql 响应中删除 `__typename` 字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55259856/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com