Skip to content

Commit 07382b8

Browse files
committed
Proposition to change README examples to ES2015 style due to GraphQL is also written in ES2015.
1 parent a033219 commit 07382b8

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ JavaScript can be produced by running:
1414
npm run build
1515
```
1616

17-
Once `npm run build` has run, you may `require()` directly from node.
17+
Once `npm run build` has run, you may `import` or `require()` directly from
18+
node.
1819

1920
The full test suite can be evaluated by running:
2021

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,20 @@ serving queries against that type schema.
5555
First, build a GraphQL type schema which maps to your code base.
5656

5757
```js
58-
var GraphQL = require('graphql');
59-
60-
var schema = new GraphQL.GraphQLSchema({
61-
query: new GraphQL.GraphQLObjectType({
58+
import {
59+
graphql,
60+
GraphQLSchema,
61+
GraphQLObjectType,
62+
GraphQLString
63+
} from 'graphql';
64+
65+
var schema = new GraphQLSchema({
66+
query: new GraphQLObjectType({
6267
name: 'RootQueryType',
6368
fields: {
6469
hello: {
65-
type: GraphQL.GraphQLString,
66-
resolve: function() { return 'world'; }
70+
type: GraphQLString,
71+
resolve: () => { return 'world'; }
6772
}
6873
}
6974
})
@@ -79,7 +84,7 @@ Then, serve the result of a query against that type schema.
7984
```js
8085
var query = '{ hello }';
8186

82-
GraphQL.graphql(schema, query).then(function (result) {
87+
graphql(schema, query).then(function (result) {
8388

8489
// Prints
8590
// {
@@ -97,7 +102,7 @@ it, reporting errors otherwise.
97102
```js
98103
var query = '{ boyhowdy }';
99104

100-
GraphQL.graphql(schema, query).then(function (result) {
105+
graphql(schema, query).then(function (result) {
101106

102107
// Prints
103108
// {
@@ -126,7 +131,8 @@ JavaScript can be produced by running:
126131
npm run build
127132
```
128133

129-
Once `npm run build` has run, you may `require()` directly from node.
134+
Once `npm run build` has run, you may `import` or `require()` directly from
135+
node.
130136

131137
After developing, the full test suite can be evaluated by running:
132138

0 commit comments

Comments
 (0)