From 517a7d94491837b5cda064432a063c0b3a0a1664 Mon Sep 17 00:00:00 2001 From: Suyash Das <71306286+suyashdas@users.noreply.github.com> Date: Sat, 12 Apr 2025 06:13:19 +0530 Subject: [PATCH 1/2] Imported GraphQLString and fixed the resolver part as per code first approach. --- website/pages/docs/getting-started.mdx | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/website/pages/docs/getting-started.mdx b/website/pages/docs/getting-started.mdx index 5a9349879e..2fa245fabf 100644 --- a/website/pages/docs/getting-started.mdx +++ b/website/pages/docs/getting-started.mdx @@ -58,30 +58,25 @@ graphql({ ```javascript -const { graphql, GraphQLSchema, GraphQLObjectType } = require('graphql'); - -// Construct a schema +const { graphql, GraphQLSchema, GraphQLObjectType, GraphQLString } = require('graphql'); + +// Construct a schema and resolver const schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'Query', fields: { - hello: { type: GraphQLString }, + hello: { + type: GraphQLString, + resolve: () => 'Hello world!' + }, }, }), }); - -// The rootValue provides a resolver function for each API endpoint -const rootValue = { - hello() { - return 'Hello world!'; - }, -}; - + // Run the GraphQL query '{ hello }' and print out the response graphql({ schema, source: '{ hello }', - rootValue, }).then((response) => { console.log(response); }); From 18a887303a7262d1aa0a9488e4159ee3e536b052 Mon Sep 17 00:00:00 2001 From: Suyash Das <71306286+suyashdas@users.noreply.github.com> Date: Sat, 12 Apr 2025 11:44:46 +0530 Subject: [PATCH 2/2] Imported GraphQLString and fixed error. --- website/pages/docs/getting-started.mdx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/website/pages/docs/getting-started.mdx b/website/pages/docs/getting-started.mdx index 2fa245fabf..4079738fc0 100644 --- a/website/pages/docs/getting-started.mdx +++ b/website/pages/docs/getting-started.mdx @@ -59,24 +59,29 @@ graphql({ ```javascript const { graphql, GraphQLSchema, GraphQLObjectType, GraphQLString } = require('graphql'); - -// Construct a schema and resolver + +// Construct a schema const schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'Query', fields: { - hello: { - type: GraphQLString, - resolve: () => 'Hello world!' - }, + hello: { type: GraphQLString }, }, }), }); - + +// The rootValue provides a resolver function for each API endpoint +const rootValue = { + hello() { + return 'Hello world!'; + }, +}; + // Run the GraphQL query '{ hello }' and print out the response graphql({ schema, source: '{ hello }', + rootValue, }).then((response) => { console.log(response); });