Node.js 如何从失败的graphql响应中删除“%uuuuTypeName”字段
我尝试在GraphQL中更改Apollo客户端中的addTypeName:falseNode.js 如何从失败的graphql响应中删除“%uuuuTypeName”字段,node.js,graphql,apollo,apollo-client,express-graphql,Node.js,Graphql,Apollo,Apollo Client,Express Graphql,我尝试在GraphQL中更改Apollo客户端中的addTypeName:false apollo.create({ link: httpLinkWithErrorHandling, cache: new InMemoryCache({ addTypename: false }), defaultOptions: { watchQuery: { fetchPolicy: 'network-only', errorPolicy: 'all' }
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.
,
及
即使我在MemoryCache({addTypename:true})中将false更改为truenew,由于突变中不需要的typename,突变也会开始失败
有没有办法解决这个问题
在上面的帖子中,我已经发布了这个问题的答案,请参考这里的提问和回答:。如果使用查询结果作为初始状态,则需要首先对其进行转换,以去掉\uu typename
字段(以及可能不是有效输入字段的任何其他字段)。可能值得注意的是,除非进行调整,否则这可能会中断缓存。这个问题更具普遍性,但得到了更多的关注,答案也更具回顾性。
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.