Files
relay/docs/GraphQL-RelaySpecification.md
Andreas Savvides e7b9b3f616 Docs improvements
Summary: I just went through the docs and tutorials as I was introducing GraphQL & Relay to a project and found a few places that the docs could be improved on - let me know what you think, feedback is obviously welcome :)

In summary:
- Linked to Conference pages where videos came through & added dates so that people have a little more context on a video's recency
- Added reference to [Relay and Routing medium post](https://medium.com/@cpojer/relay-and-routing-36b5439bad9)
- Changed a couple of sentences at the end of some guides referencing what's coming up next; for example, at the end of the Tutorial section it says you'll be taken to the Guides, but actually you get to the Videos section first
- Added links to external dependencies / plugins / functions that are mentioned and I had to look for rather than click on and be taken there
Closes https://github.com/facebook/relay/pull/389

Reviewed By: @yungsters

Differential Revision: D2481599
2015-09-25 14:30:01 -07:00

2.3 KiB

id, title, layout, category, permalink, next
id title layout category permalink next
graphql-relay-specification GraphQL Relay Specification docs GraphQL docs/graphql-relay-specification.html graphql-object-identification

Getting Started

The three core assumptions that Relay makes about a GraphQL server are that it provides:

  1. A mechanism for refetching an object.
  2. A description of how to page through connections.
  3. Structure around mutations to make them predictable.

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.

It is assumed that the reader is already familiar with GraphQL; if not, the README for GraphQL.js is a good place to start.

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.

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.

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
}