graphql 突变负载中缺少字段

Mis*_*ime 6 reactjs graphql relaymodern

我是 graphql 的新手。我需要在 React 应用程序中使用 Relay Modern 执行突变。根据文档,突变有效负载可能与成功响应到错误响应不同。成功响应一切顺利,但错误响应我在控制台中收到此警告:

警告:RelayResponseNormalizer:有效负载不包含字段 的值objectId: objectId。检查您是否使用与获取有效负载相同的查询进行解析。

因为错误响应不包含 objectId 字段。除此之外,脚本行为正确。以下是文档中的一些示例.. 突变示例:

mutation{
    createObject(name: 'john') {
        objectId
        error
    }
}
Run Code Online (Sandbox Code Playgroud)

成功响应:

{
    "data": {
        "createObject": {
            "objectId": "123456",
            "error": null
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

和错误响应:

{
    "data": {
        "createObject": {
            "error": "[Name should not be Empty]"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是反应组件中的代码:

const mutation = graphql`
    mutation ComponentCreateObjectMutation($name: String) {
        createObject(name: $name) {
            objectId
            error
        }
    }
`;

commitMutation(
    environment,
    {
        mutation,
        variables,
        onCompleted: (response, errors) => {

            /* error is in response.error */
        },
        onError: (err) => {...}
    }
);
Run Code Online (Sandbox Code Playgroud)

这是 schema.graphql 内容:

type ObjectResponse {
    objectId: ID,
    error: String
}

type Mutation {
    createObject(name: String): ObjectResponse
}
Run Code Online (Sandbox Code Playgroud)

解决这个问题的最佳方法是什么?在此先感谢您的帮助!