0

我正在尝试以这种格式创建两个单独的突变:

import gql from 'graphql-tag';

const MUTATION = gql`
  mutation setItem($item:String!) {
    setItem(item:$item)
  },
  mutation setAnotherItem($setAnotherItem:Bool) {
    setAnotherItem(setAnotherItem:$setAnotherItem)
  }
`;

但我收到此错误:

Invariant Violation: react-apollo only supports a query, subscription, or a mutation per HOC. [object Object] had 0 queries, 0 subscriptions and 2 mutations. You can use 'compose' to join multiple operation types to a component

什么是构造它以使两个突变都可用的正确方法?

4

1 回答 1

0

您只需键入一次mutation并嵌套在 (mutation) 字段中:

import gql from 'graphql-tag';

const MUTATION = gql`
  mutation MyMutation ($item: String, $setAnotherItem: Book) {
    setItem(item: $item) { ...}
    setAnotherItem(setAnotherItem: $setAnotherItem) {...}
  }
`;
于 2021-02-18T06:53:50.950 回答