在最后插入的ID上未定义

时间:2019-12-16 21:36:36

标签: reactjs graphql apollo react-apollo apollo-client

您好,我正在尝试使用以下代码从突变查询中获取数据

const [LocalCodeMutation, mutationData ] = useMutation(LOCALCODE_MUTATION, {
onCompleted: () => {
  history.push(`/Viewchange/${mutationData.insertedId}`);
   },
});

这将是我正在发送的实际graphql查询

export const LOCALCODE_MUTATION = gql`
mutation LocalCodeMutation($localCodeInputParam: LocalCodeInput, $requestInputParam: RequestInput) 
{
     localCodeMutation(localCodeInputs: $localCodeInputParam, requestInputs: $requestInputParam) {
      ok
      errors
      insertedId
     }
 }
`;

这将是我将值传递给上述方法的方法

  LocalCodeMutation({
      variables: {
        localCodeInputParam: {
          id: null,
          city: values.city,
          country: values.country,
          description: values.description,
          edition: values.edition,
          name: values.name,
          note: values.note,
          state: values.state,
          revision: 0,
        },
        requestInputParam: {
          createdBy: 'test@test.com',
          masterSection: 'Local Code',
          requestType: 'NEW',
          description: values.description,
        },
      },
    });

即使有mutationData.insertedId的价值,我也得到了不确定的价值,请问任何一个让我感激不尽的insertid发生了什么事。

非常感谢 我正在使用带有Apollo graphql的react JS

0 个答案:

没有答案