Mutations #Facebook Relay文档翻译#
2015-09-28 10:48
821 查看
原文地址
上一篇 Connection
Relay文档翻译目录
Relay uses a common pattern for mutations, where they are root fields on the
mutation type with a single argument,
both contain a client mutation identifier used to reconcile requests and
responses.
Relay使用通用模式来处理mutation,定义为mutation type带有一个参数input的根字段,这里的输入输出都包含客户端mutation标识符用于撮合请求与响应。
By convention, mutations are named as verbs, their inputs are the name with
“Input” appended at the end, and they return an object that is the name with
“Payload” appended.
按照约定,mutation的名字用动词,他们的输入名字以’Input’结尾,返回的对象的名字以’Payload’结尾。
So for our
and
With this input and payload, we can issue the following mutation:
with these params:
and we’ll get this result:
Complete details on how the server should behave are
available in the GraphQL Input Object Mutations
spec.
服务器端应该如何处理的详细说明请见GraphQL Input Object Mutations
spec.
上一篇 Connection
Relay文档翻译目录
Relay uses a common pattern for mutations, where they 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.
Relay使用通用模式来处理mutation,定义为mutation type带有一个参数input的根字段,这里的输入输出都包含客户端mutation标识符用于撮合请求与响应。
By convention, mutations are named as verbs, their inputs are the name with
“Input” appended at the end, and they return an object that is the name with
“Payload” appended.
按照约定,mutation的名字用动词,他们的输入名字以’Input’结尾,返回的对象的名字以’Payload’结尾。
So for our
introduceShipmutation, we create two types:
IntroduceShipInput
and
IntroduceShipPayload:
input IntroduceShipInput { factionId: ID! shipName: String! clientMutationId: String! } type IntroduceShipPayload { faction: Faction ship: Ship clientMutationId: String! }
With this input and payload, we can issue the following mutation:
mutation AddBWingQuery($input: IntroduceShipInput!) { introduceShip(input: $input) { ship { id name } faction { name } clientMutationId } }
with these params:
{ "input": { "shipName": "B-Wing", "factionId": "1", "clientMutationId": "abcde" } }
and we’ll get this result:
{ "introduceShip": { "ship": { "id": "U2hpcDo5", "name": "B-Wing" }, "faction": { "name": "Alliance to Restore the Republic" }, "clientMutationId": "abcde" } }
Complete details on how the server should behave are
available in the GraphQL Input Object Mutations
spec.
服务器端应该如何处理的详细说明请见GraphQL Input Object Mutations
spec.
相关文章推荐
- Facebook's New Real-time Messaging System: HBase to Store 135+ Billion Messages a Month
- Facebook获得TechCrunch Crunchies 2009最佳奖
- 网页上facebook分享功能具体实现
- JSONP获取Twitter和Facebook文章数的具体步骤
- iOS 5 cocos2d 游戏开发 3ff8 实战:第4章 你的第一个游戏
- 7月国外最新技术文章翻译汇总(IT技术)
- windows phone 8 的新特性
- Facebook图片存储架构技术全解析
- Facebook揭秘HipHop项目 PHP程序大提速
- 使用Html5开发Android和iOS应用:HBuilder、Html5Plus、MUI
- 基于 Facebook 的开发笔记
- Titanium 快速入门
- Titanium 用户界面之布局结构及核心代码块
- 月光微博客
- 月光微博客
- 月光微博客
- 月光微博客
- 月光微博客