From ec48bb54f27cd4aeb4e2f958c2708ae66ccf6e5a Mon Sep 17 00:00:00 2001 From: Jamie Barton Date: Wed, 15 Dec 2021 11:28:47 +0000 Subject: [PATCH 1/3] fix: use correct args --- site/graphql-js/Tutorial-GettingStarted.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/site/graphql-js/Tutorial-GettingStarted.md b/site/graphql-js/Tutorial-GettingStarted.md index 0e492ae00d..367fbc5cca 100644 --- a/site/graphql-js/Tutorial-GettingStarted.md +++ b/site/graphql-js/Tutorial-GettingStarted.md @@ -23,7 +23,7 @@ npm install graphql --save To handle GraphQL queries, we need a schema that defines the `Query` type, and we need an API root with a function called a “resolver” for each API endpoint. For an API that just returns “Hello world!”, we can put this code in a file named `server.js`: ```javascript -var { graphql, buildSchema } = require('graphql'); +var { graphql, buildSchema } = require("graphql"); // Construct a schema, using GraphQL schema language var schema = buildSchema(` @@ -33,14 +33,14 @@ var schema = buildSchema(` `); // The root provides a resolver function for each API endpoint -var root = { +var rootValue = { hello: () => { - return 'Hello world!'; + return "Hello world!"; }, }; // Run the GraphQL query '{ hello }' and print out the response -graphql(schema, '{ hello }', root).then((response) => { +graphql({ schema, source: "{ hello }", rootValue }).then((response) => { console.log(response); }); ``` @@ -54,7 +54,11 @@ node server.js You should see the GraphQL response printed out: ```javascript -{ data: { hello: 'Hello world!' } } +{ + data: { + hello: "Hello world!"; + } +} ``` Congratulations - you just executed a GraphQL query! From aef6219e7df1a0aa9735dc3ca248b3772b0be608 Mon Sep 17 00:00:00 2001 From: Jamie Barton Date: Wed, 15 Dec 2021 11:33:11 +0000 Subject: [PATCH 2/3] chore: revert formatting --- site/graphql-js/Tutorial-GettingStarted.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/site/graphql-js/Tutorial-GettingStarted.md b/site/graphql-js/Tutorial-GettingStarted.md index 367fbc5cca..7ed33c9b76 100644 --- a/site/graphql-js/Tutorial-GettingStarted.md +++ b/site/graphql-js/Tutorial-GettingStarted.md @@ -23,7 +23,7 @@ npm install graphql --save To handle GraphQL queries, we need a schema that defines the `Query` type, and we need an API root with a function called a “resolver” for each API endpoint. For an API that just returns “Hello world!”, we can put this code in a file named `server.js`: ```javascript -var { graphql, buildSchema } = require("graphql"); +var { graphql, buildSchema } = require('graphql'); // Construct a schema, using GraphQL schema language var schema = buildSchema(` @@ -35,7 +35,7 @@ var schema = buildSchema(` // The root provides a resolver function for each API endpoint var rootValue = { hello: () => { - return "Hello world!"; + return 'Hello world!'; }, }; @@ -54,11 +54,7 @@ node server.js You should see the GraphQL response printed out: ```javascript -{ - data: { - hello: "Hello world!"; - } -} +{ data: { hello: 'Hello world!' } } ``` Congratulations - you just executed a GraphQL query! From 27ba2a54856d9280011ba63d0200dde91ab6e426 Mon Sep 17 00:00:00 2001 From: Jamie Barton Date: Wed, 15 Dec 2021 11:34:34 +0000 Subject: [PATCH 3/3] chore: revert formatting for source --- site/graphql-js/Tutorial-GettingStarted.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/graphql-js/Tutorial-GettingStarted.md b/site/graphql-js/Tutorial-GettingStarted.md index 7ed33c9b76..751a83d1a1 100644 --- a/site/graphql-js/Tutorial-GettingStarted.md +++ b/site/graphql-js/Tutorial-GettingStarted.md @@ -40,7 +40,7 @@ var rootValue = { }; // Run the GraphQL query '{ hello }' and print out the response -graphql({ schema, source: "{ hello }", rootValue }).then((response) => { +graphql({ schema, source: '{ hello }', rootValue }).then((response) => { console.log(response); }); ```