GraphQL Relay Specification #Facebook Relay文档翻译#

原文地址
上一篇 Babel Relay Plugin
Relay文档翻译目录

The three core assumptions that Relay makes about a GraphQL server are that it
provides:
Relay使用的GraphQL server得满足以下三点核心假设:

  1. A mechanism for refetching an object.
    重新获取对象的机制
  2. A description of how to page through connections.
    如何在connection上进行分页描述
  3. Structure around mutations to make them predictable.
    对mutation进行结构化,让他们变得可预测

This example demonstrates all three of these assumptions.
下面的例子说明了这三点假设。

This example is not comprehensive, but it is designed to quickly introduce
these core assumptions, to provide some context before diving into
the more detailed specification or the library.
这个例子并不深刻,只是给你可以快速的预览,有助于你日后深入了解。

The premise of the example is that we want to use GraphQL to query for
information about ships and factions in the original Star Wars
trilogy.
例子的前提是我们希望用GraphQL来查询在星球大战三部曲中ships和factions的信息。

It is assumed that the reader is already familiar with GraphQL; if not,
the README for GraphQL.js is a
good place to start.
这里假设您已经熟悉GraphQL,如果不请阅读README GraphQL.js

It is also assumed that the reader is already familiar with Star Wars; if not,
the 1977 version of Star Wars is a good place to start, though the 1997
Special Edition will serve for the purposes of this document.
当然还希望您是了解星球大战的,如果不,1977、1997的版本您可以看看。

Schema

The schema described below will be used to demonstrate the functionality
that a GraphQL server used by Relay should implement. The two core types
are a faction and a ship in the Star Wars universe, where a faction
has many ships associated with it. The schema below is the output of the
GraphQL.js schemaPrinter.
下面的schema被用于说明Relay使用的GraphQL server应该实现哪些功能。在星球大战中有两个核心类型faction和ship,一个faction可以有很多ship。以下schema是用过GraphQL.js schemaPrinter打印输出的。

interface Node {
  id: ID!
}

type Faction : Node {
  id: ID!
  name: String
  ships: ShipConnection
}

type Ship : Node {
  id: ID!
  name: String
}

type ShipConnection {
  edges: [ShipEdge]
  pageInfo: PageInfo!
}

type ShipEdge {
  cursor: String!
  node: Ship
}

type PageInfo {
  hasNextPage: Boolean!
  hasPreviousPage: Boolean!
  startCursor: String
  endCursor: String
}

type Query {
  rebels: Faction
  empire: Faction
  node(id: ID!): Node
}

input IntroduceShipInput {
  factionId: String!
  shipNamed: String!
  clientMutationId: String!
}

type IntroduceShipPayload {
  faction: Faction
  ship: Ship
  clientMutationId: String!
}

type Mutation {
  introduceShip(input: IntroduceShipInput!): IntroduceShipPayload
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值