Skip to content

Commit 517a7d9

Browse files
authored
Imported GraphQLString and fixed the resolver part as per code first approach.
1 parent 7dd7812 commit 517a7d9

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

website/pages/docs/getting-started.mdx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,25 @@ graphql({
5858
</Tabs.Tab>
5959
<Tabs.Tab>
6060
```javascript
61-
const { graphql, GraphQLSchema, GraphQLObjectType } = require('graphql');
62-
63-
// Construct a schema
61+
const { graphql, GraphQLSchema, GraphQLObjectType, GraphQLString } = require('graphql');
62+
63+
// Construct a schema and resolver
6464
const schema = new GraphQLSchema({
6565
query: new GraphQLObjectType({
6666
name: 'Query',
6767
fields: {
68-
hello: { type: GraphQLString },
68+
hello: {
69+
type: GraphQLString,
70+
resolve: () => 'Hello world!'
71+
},
6972
},
7073
}),
7174
});
72-
73-
// The rootValue provides a resolver function for each API endpoint
74-
const rootValue = {
75-
hello() {
76-
return 'Hello world!';
77-
},
78-
};
79-
75+
8076
// Run the GraphQL query '{ hello }' and print out the response
8177
graphql({
8278
schema,
8379
source: '{ hello }',
84-
rootValue,
8580
}).then((response) => {
8681
console.log(response);
8782
});

0 commit comments

Comments
 (0)