graphql - 在 Relay.js 中, `Client Mutation Identifier` 是什么?

标签 graphql graphql-js relayjs relay relaymodern

在中继文档中 here ,它说:

Relay uses a common pattern for mutations, where there are root fields on the mutation type with a single argument, input, and where the input and output both contain a client mutation identifier used to reconcile requests and responses.



但在他们提供的示例中,输入和输出分别如下所示:
// IntroducedShipInput
{
  "input": {
    "shipName": "B-Wing",
    "factionId": "1"
  }
}

// IntroducedShipPayload
{
  "introduceShip": {
    "ship": {
      "id": "U2hpcDo5",
      "name": "B-Wing"
    },
    "faction": {
      "name": "Alliance to Restore the Republic"
    }
  }
}

那么什么是client mutation标识符?为什么以及如何使用它来协调请求和响应?

最佳答案

我仍然不能 100% 确定“客户端突变标识符”究竟发生了什么,但是经过一些研究,它似乎是 Relay 以前版本中的一个要求。 This PR apparently removed the requirement通过用其他一些机制替换它,但我不清楚其他机制的作用。 I left a comment requesting more clarification around the documentation ,这似乎已经过时了。

无论如何,客户端突变标识符appears to have been related to some assumptions about mutation idempotency in Facebook's implementation of GraphQL .

关于graphql - 在 Relay.js 中, `Client Mutation Identifier` 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60389096/

相关文章:

react-native - 将 Relay 与 React-Native 结合使用时的条件片段或嵌入的根容器

java - GraphQL Java 客户端库

mysql - 如何在 sequelize 中执行事务和回滚?

javascript - apollo-client 可以在 node.js 上运行吗?

graphql - 如何使用graphql查询一系列值

node.js - 使用 Mongoose 和 GraphQL 保存实体后数据为空

node.js - GraphQL-js Node/Express : How to pass a stringed object in a GraphQL Query?

javascript - 在 native 应用程序中使用中继

reactjs - GraphQL 和中继过滤 UI

javascript - React Relay (react-relay) 与 Typescript 抛出 TypeError : Object prototype may only be an Object or null: undefined