@@ -55,15 +55,20 @@ serving queries against that type schema.
55
55
First, build a GraphQL type schema which maps to your code base.
56
56
57
57
``` 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 ({
62
67
name: ' RootQueryType' ,
63
68
fields: {
64
69
hello: {
65
- type: GraphQL . GraphQLString ,
66
- resolve : function () { return ' world' ; }
70
+ type: GraphQLString,
71
+ resolve : () => { return ' world' ; }
67
72
}
68
73
}
69
74
})
@@ -79,7 +84,7 @@ Then, serve the result of a query against that type schema.
79
84
``` js
80
85
var query = ' { hello }' ;
81
86
82
- GraphQL . graphql (schema, query).then (function (result ) {
87
+ graphql (schema, query).then (function (result ) {
83
88
84
89
// Prints
85
90
// {
@@ -97,7 +102,7 @@ it, reporting errors otherwise.
97
102
``` js
98
103
var query = ' { boyhowdy }' ;
99
104
100
- GraphQL . graphql (schema, query).then (function (result ) {
105
+ graphql (schema, query).then (function (result ) {
101
106
102
107
// Prints
103
108
// {
@@ -126,7 +131,8 @@ JavaScript can be produced by running:
126
131
npm run build
127
132
```
128
133
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.
130
136
131
137
After developing, the full test suite can be evaluated by running:
132
138
0 commit comments