From dfe6e5e0259fc1ec4f4ffb4faae4a7246119cde6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BD=D1=87=D0=B0=D1=80=D0=BE=D0=B2?= Date: Sun, 22 May 2022 00:57:17 +0300 Subject: [PATCH] Fixed javascript code snippet The snippet was not correct, it throws this error: Error: Expected undefined to be a GraphQL schema. The reason is that we passed configuration as params of qraphql function, but the function takes only one param - an object of the parameters. See type declaration of the function by permalink bellow https://github.com/graphql/graphql-js/blob/c7d7026982ceee536900a24ae31235127560297a/src/graphql.ts#L70 --- .../code/language-support/javascript/server/graphql-js.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/content/code/language-support/javascript/server/graphql-js.md b/src/content/code/language-support/javascript/server/graphql-js.md index 9769b78e39..39e3e596e6 100644 --- a/src/content/code/language-support/javascript/server/graphql-js.md +++ b/src/content/code/language-support/javascript/server/graphql-js.md @@ -23,9 +23,11 @@ var schema = buildSchema(` } `); -var root = { hello: () => 'Hello world!' }; +var rootValue = { hello: () => 'Hello world!' }; -graphql(schema, '{ hello }', root).then((response) => { +var source = '{ hello }'; + +graphql({ schema, source, rootValue }).then((response) => { console.log(response); }); ```