【问题标题】:How to remove the `__typename` field from the graphql response which fails the mutations如何从导致突变失败的graphql响应中删除`__typename`字段
【发布时间】:2019-08-11 02:14:33
【问题描述】:

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

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

【问题讨论】:

标签: node.js graphql apollo apollo-client express-graphql


【解决方案1】:

Cleaning Unwanted Fields From GraphQL Responses

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

【讨论】:

猜你喜欢
  • 2021-08-08
  • 2017-07-26
  • 2023-01-10
  • 2019-01-31
  • 2019-08-21
  • 2018-04-23
  • 1970-01-01
  • 1970-01-01
  • 2016-01-14
相关资源
最近更新 更多