首页 文章

Apollo混合了React中的GraphQL查询结果

提问于
浏览
0

我打电话回复问题和答案 . 当我直接将其发送到服务器时,响应符合预期 . 此外,当react进行调用并且我检查开发人员工具时,响应是预期的 .

一旦我收到阿波罗的回复,数据就会混杂在一起,结果会相互渗透 .

您将注意到在这两个图像中,在扩展了一些结果后结果是相同的 . 我不确定是什么原因引起的 .

enter image description here

enter image description here

为什么自由形式会合并?

我的设置是这样的:

我导入查询,然后在Apollo客户端上运行它:

this.props.client.query({ query: getCoreObjectsQuery, variables: { companyId: 1}})
              .then((result) => {
                console.log(result, 'getCoreObjectsQuery')

从那里,当我去看看getCoreObjectsQuery时,它看起来像上面的图像!

1 回答

  • 0

    哇!原来是一个Apollo客户端缓存错误 .

    Kamranicus.com有一篇非常有用的文章,但是对于任何寻求快速修复的人来说:

    __typename @skip(if:true)

    questions{
          id
          __typename @skip(if: true)
          coreId
          question
          isCore
          type
          answer:answerForCoreId{
             id
             __typename @skip(if: true)
             freeform
             url
             choice {
               id
               __typename @skip(if: true)
             }
           }
        }
    

    id和_id缓存!

相关问题