Skip to content

Commit db98379

Browse files
committed
Unwrap README.md
We do this in our other projects in order to make it easier to consistently deal with long lines (often happens with lines containing links), so we may as well do it here too.
1 parent 7bf9bbb commit db98379

File tree

1 file changed

+32
-89
lines changed

1 file changed

+32
-89
lines changed

README.md

Lines changed: 32 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
11
# Relay Library for GraphQL.js
22

3-
This is a library to allow the easy creation of Relay-compliant servers using
4-
the [GraphQL.js](https://github.com/graphql/graphql-js) reference implementation
5-
of a GraphQL server.
3+
This is a library to allow the easy creation of Relay-compliant servers using the [GraphQL.js](https://github.com/graphql/graphql-js) reference implementation of a GraphQL server.
64

75
[![Build Status](https://travis-ci.org/graphql/graphql-relay-js.svg?branch=master)](https://travis-ci.org/graphql/graphql-relay-js)
86
[![Coverage Status](https://coveralls.io/repos/graphql/graphql-relay-js/badge.svg?branch=master&service=github)](https://coveralls.io/github/graphql/graphql-relay-js?branch=master)
97

108
## Getting Started
119

12-
A basic understanding of GraphQL and of the GraphQL.js implementation is needed
13-
to provide context for this library.
10+
A basic understanding of GraphQL and of the GraphQL.js implementation is needed to provide context for this library.
1411

15-
An overview of GraphQL in general is available in the
16-
[README](https://github.com/facebook/graphql/blob/master/README.md) for the
17-
[Specification for GraphQL](https://github.com/facebook/graphql).
12+
An overview of GraphQL in general is available in the [README](https://github.com/facebook/graphql/blob/master/README.md) for the [Specification for GraphQL](https://github.com/facebook/graphql).
1813

19-
This library is designed to work with the
20-
[GraphQL.js](https://github.com/graphql/graphql-js) reference implementation
21-
of a GraphQL server.
14+
This library is designed to work with the [GraphQL.js](https://github.com/graphql/graphql-js) reference implementation of a GraphQL server.
2215

23-
An overview of the functionality that a Relay-compliant GraphQL server should
24-
provide is in the [GraphQL Relay Specification](https://facebook.github.io/relay/docs/graphql-relay-specification.html)
25-
on the [Relay website](https://facebook.github.io/relay/). That overview
26-
describes a simple set of examples that exist as [tests](src/__tests__) in this
27-
repository. A good way to get started with this repository is to walk through
28-
that documentation and the corresponding tests in this library together.
16+
An overview of the functionality that a Relay-compliant GraphQL server should provide is in the [GraphQL Relay Specification](https://facebook.github.io/relay/docs/graphql-relay-specification.html) on the [Relay website](https://facebook.github.io/relay/). That overview describes a simple set of examples that exist as [tests](src/__tests__) in this repository. A good way to get started with this repository is to walk through that documentation and the corresponding tests in this library together.
2917

3018
## Using Relay Library for GraphQL.js
3119

@@ -35,36 +23,21 @@ Install Relay Library for GraphQL.js
3523
npm install graphql-relay
3624
```
3725

38-
When building a schema for [GraphQL.js](https://github.com/graphql/graphql-js),
39-
the provided library functions can be used to simplify the creation of Relay
40-
patterns.
26+
When building a schema for [GraphQL.js](https://github.com/graphql/graphql-js), the provided library functions can be used to simplify the creation of Relay patterns.
4127

4228
### Connections
4329

44-
Helper functions are provided for both building the GraphQL types
45-
for connections and for implementing the `resolve` method for fields
46-
returning those types.
47-
48-
- `connectionArgs` returns the arguments that fields should provide when they
49-
return a connection type that supports bidirectional pagination.
50-
- `forwardConnectionArgs` returns the arguments that fields should provide
51-
when they return a connection type that only supports forward pagination.
52-
- `backwardConnectionArgs` returns the arguments that fields should provide
53-
when they return a connection type that only supports backward pagination.
54-
- `connectionDefinitions` returns a `connectionType` and its associated
55-
`edgeType`, given a node type.
56-
- `connectionFromArray` is a helper method that takes an array and the
57-
arguments from `connectionArgs`, does pagination and filtering, and returns
58-
an object in the shape expected by a `connectionType`'s `resolve` function.
59-
- `connectionFromPromisedArray` is similar to `connectionFromArray`, but
60-
it takes a promise that resolves to an array, and returns a promise that
61-
resolves to the expected shape by `connectionType`.
62-
- `cursorForObjectInConnection` is a helper method that takes an array and a
63-
member object, and returns a cursor for use in the mutation payload.
64-
- `offsetToCursor` takes the index of a member object in an array and
65-
returns an opaque cursor for use in the mutation payload.
66-
- `cursorToOffset` takes an opaque cursor (created with `offsetToCursor`)
67-
and returns the corresponding array index.
30+
Helper functions are provided for both building the GraphQL types for connections and for implementing the `resolve` method for fields returning those types.
31+
32+
- `connectionArgs` returns the arguments that fields should provide when they return a connection type that supports bidirectional pagination.
33+
- `forwardConnectionArgs` returns the arguments that fields should provide when they return a connection type that only supports forward pagination.
34+
- `backwardConnectionArgs` returns the arguments that fields should provide when they return a connection type that only supports backward pagination.
35+
- `connectionDefinitions` returns a `connectionType` and its associated `edgeType`, given a node type.
36+
- `connectionFromArray` is a helper method that takes an array and the arguments from `connectionArgs`, does pagination and filtering, and returns an object in the shape expected by a `connectionType`'s `resolve` function.
37+
- `connectionFromPromisedArray` is similar to `connectionFromArray`, but it takes a promise that resolves to an array, and returns a promise that resolves to the expected shape by `connectionType`.
38+
- `cursorForObjectInConnection` is a helper method that takes an array and a member object, and returns a cursor for use in the mutation payload.
39+
- `offsetToCursor` takes the index of a member object in an array and returns an opaque cursor for use in the mutation payload.
40+
- `cursorToOffset` takes an opaque cursor (created with `offsetToCursor`) and returns the corresponding array index.
6841

6942
An example usage of these methods from the [test schema](src/__tests__/starWarsSchema.js):
7043

@@ -86,29 +59,17 @@ var factionType = new GraphQLObjectType({
8659
});
8760
```
8861

89-
This shows adding a `ships` field to the `Faction` object that is a connection.
90-
It uses `connectionDefinitions({nodeType: shipType})` to create the connection
91-
type, adds `connectionArgs` as arguments on this function, and then implements
92-
the resolve function by passing the array of ships and the arguments to
93-
`connectionFromArray`.
62+
This shows adding a `ships` field to the `Faction` object that is a connection. It uses `connectionDefinitions({nodeType: shipType})` to create the connection type, adds `connectionArgs` as arguments on this function, and then implements the resolve function by passing the array of ships and the arguments to `connectionFromArray`.
9463

9564
### Object Identification
9665

97-
Helper functions are provided for both building the GraphQL types
98-
for nodes and for implementing global IDs around local IDs.
99-
100-
- `nodeDefinitions` returns the `Node` interface that objects can implement,
101-
and returns the `node` root field to include on the query type. To implement
102-
this, it takes a function to resolve an ID to an object, and to determine
103-
the type of a given object.
104-
- `toGlobalId` takes a type name and an ID specific to that type name,
105-
and returns a "global ID" that is unique among all types.
106-
- `fromGlobalId` takes the "global ID" created by `toGlobalID`, and returns
107-
the type name and ID used to create it.
66+
Helper functions are provided for both building the GraphQL types for nodes and for implementing global IDs around local IDs.
67+
68+
- `nodeDefinitions` returns the `Node` interface that objects can implement, and returns the `node` root field to include on the query type. To implement this, it takes a function to resolve an ID to an object, and to determine the type of a given object.
69+
- `toGlobalId` takes a type name and an ID specific to that type name, and returns a "global ID" that is unique among all types.
70+
- `fromGlobalId` takes the "global ID" created by `toGlobalID`, and returns the type name and ID used to create it.
10871
- `globalIdField` creates the configuration for an `id` field on a node.
109-
- `pluralIdentifyingRootField` creates a field that accepts a list of
110-
non-ID identifiers (like a username) and maps them to their corresponding
111-
objects.
72+
- `pluralIdentifyingRootField` creates a field that accepts a list of non-ID identifiers (like a username) and maps them to their corresponding objects.
11273

11374
An example usage of these methods from the [test schema](src/__tests__/starWarsSchema.js):
11475

@@ -139,22 +100,13 @@ var queryType = new GraphQLObjectType({
139100
});
140101
```
141102

142-
This uses `nodeDefinitions` to construct the `Node` interface and the `node`
143-
field; it uses `fromGlobalId` to resolve the IDs passed in the implementation
144-
of the function mapping ID to object. It then uses the `globalIdField` method to
145-
create the `id` field on `Faction`, which also ensures implements the
146-
`nodeInterface`. Finally, it adds the `node` field to the query type, using the
147-
`nodeField` returned by `nodeDefinitions`.
103+
This uses `nodeDefinitions` to construct the `Node` interface and the `node` field; it uses `fromGlobalId` to resolve the IDs passed in the implementation of the function mapping ID to object. It then uses the `globalIdField` method to create the `id` field on `Faction`, which also ensures implements the `nodeInterface`. Finally, it adds the `node` field to the query type, using the `nodeField` returned by `nodeDefinitions`.
148104

149105
### Mutations
150106

151-
A helper function is provided for building mutations with
152-
single inputs and client mutation IDs.
107+
A helper function is provided for building mutations with single inputs and client mutation IDs.
153108

154-
- `mutationWithClientMutationId` takes a name, input fields, output fields,
155-
and a mutation method to map from the input fields to the output fields,
156-
performing the mutation along the way. It then creates and returns a field
157-
configuration that can be used as a top-level field on the mutation type.
109+
- `mutationWithClientMutationId` takes a name, input fields, output fields, and a mutation method to map from the input fields to the output fields, performing the mutation along the way. It then creates and returns a field configuration that can be used as a top-level field on the mutation type.
158110

159111
An example usage of these methods from the [test schema](src/__tests__/starWarsSchema.js):
160112

@@ -201,14 +153,9 @@ var mutationType = new GraphQLObjectType({
201153
});
202154
```
203155

204-
This code creates a mutation named `IntroduceShip`, which takes a faction
205-
ID and a ship name as input. It outputs the `Faction` and the `Ship` in
206-
question. `mutateAndGetPayload` then gets an object with a property for
207-
each input field, performs the mutation by constructing the new ship, then
208-
returns an object that will be resolved by the output fields.
156+
This code creates a mutation named `IntroduceShip`, which takes a faction ID and a ship name as input. It outputs the `Faction` and the `Ship` in question. `mutateAndGetPayload` then gets an object with a property for each input field, performs the mutation by constructing the new ship, then returns an object that will be resolved by the output fields.
209157

210-
Our mutation type then creates the `introduceShip` field using the return
211-
value of `mutationWithClientMutationId`.
158+
Our mutation type then creates the `introduceShip` field using the return value of `mutationWithClientMutationId`.
212159

213160
## Contributing
214161

@@ -218,16 +165,13 @@ After cloning this repo, ensure dependencies are installed by running:
218165
npm install
219166
```
220167

221-
This library is written in ES6 and uses [Babel](http://babeljs.io/) for ES5
222-
transpilation and [Flow](http://flowtype.org/) for type safety. Widely
223-
consumable JavaScript can be produced by running:
168+
This library is written in ES6 and uses [Babel](http://babeljs.io/) for ES5 transpilation and [Flow](http://flowtype.org/) for type safety. Widely consumable JavaScript can be produced by running:
224169

225170
```sh
226171
npm run build
227172
```
228173

229-
Once `npm run build` has run, you may `import` or `require()` directly from
230-
node.
174+
Once `npm run build` has run, you may `import` or `require()` directly from node.
231175

232176
After developing, the full test suite can be evaluated by running:
233177

@@ -241,7 +185,6 @@ While actively developing, we recommend running
241185
npm run watch
242186
```
243187

244-
in a terminal. This will watch the file system run lint, tests, and type
245-
checking automatically whenever you save a js file.
188+
in a terminal. This will watch the file system run lint, tests, and type checking automatically whenever you save a js file.
246189

247190
To lint the JS files and run type interface checks run `npm run lint`.

0 commit comments

Comments
 (0)