您好,我正在尝试使用以下代码从突变查询中获取数据
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