我的突变适用于 Amplify,但不适用于 Apollo。为什么?

My mutations works properly with Amplify but not with Apollo. Why?

我正在使用 AWS AppSyncApollo。到目前为止,一切都很好,除了我刚刚意识到我所有的突变都没有正常工作:

在devtool中,我可以看到返回的数据是这样的:

{
  "data": {
    "getProduct": {
      "productId": "xxxxxxxxxxxxxxxxxxx",
      "title": "my title",
      "slug": "my slug"
    }
  }
}

...但是当我尝试 console.log 这些相同的数据时,我得到空值。 它只对我的突变执行此操作(查询工作正常)。

{
  "data": {
    "getProduct": null
  }
}

这是我正在做的事情:

addProduct(variables): Observable<Product> {
  return this.apollo.mutate({
    mutation: gql`
      mutation addProduct($product: AddProductInput) {
        addProduct(product: $product) {
          productId
          title
          slug
        }
      }
    `,
    variables
  }).pipe(
    tap(console.log)
  )
}

在尝试找到解决方案几个小时后,我尝试用 AWS Amplify 替换 Apollo 并且它按预期工作。

问题是我不想使用 AWS Amplify。我不会用 fragments/offline/optimistic UI/fetchPolicy... 我真的需要这些。

所以我想知道是否应该像这样或者我在这里遗漏了什么?

Kamil Kisiela 的帮助下,我们发现将 disableOffline: true 添加到 AWSAppSyncClient 时它再次起作用。 所以我寻找看起来像这样的错误并找到 this。 然后我将 aws-appsync 升级到 1.3.3,它一直有效,即使没有 disableOffline: true。耶!