diff --git a/package.json b/package.json index 0e6b321258..008505c53f 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1" }, "dependencies": { + "@graphql-tools/schema": "^6.2.1", "codemirror": "^5.6.0", "codemirror-graphql": "^0.5.7", "gatsby": "^2.24.41", @@ -21,8 +22,7 @@ "gatsby-plugin-webfonts": "^1.1.3", "gatsby-source-filesystem": "^2.3.24", "gatsby-transformer-remark": "^2.8.28", - "graphql": "^0.7.0", - "graphql-tools": "^0.6.6", + "graphql": "^15.3.0", "marked": "^0.3.5", "prism-react-renderer": "^1.1.1", "prismjs": "^1.21.0", diff --git a/src/components/Marked/MiniGraphiQL.tsx b/src/components/Marked/MiniGraphiQL.tsx index 6173cd65a8..7e6bf5f97b 100644 --- a/src/components/Marked/MiniGraphiQL.tsx +++ b/src/components/Marked/MiniGraphiQL.tsx @@ -78,26 +78,26 @@ class MiniGraphiQL extends React.Component { _runQuery() { this._editorQueryID++; var queryID = this._editorQueryID; + try { + const result = await graphql({ + schema: this.props.schema, + source: this.state.query, + variableValues: JSON.parse(this.state.variables || "{}"), + rootValue: this.props.rootValue, + }) - - graphql( - this.props.schema, - this.state.query, - this.props.rootValue, - null, // context - this.state.variables && JSON.parse(this.state.variables) - ).then(result => { if (result.errors) { - result.errors = result.errors.map(formatError); + result.errors = result.errors.map(formatError) } + if (queryID === this._editorQueryID) { - this.setState({ response: JSON.stringify(result, null, 2) }); + this.setState({ response: JSON.stringify(result, null, 2) }) } - }).catch(error => { + } catch (error) { if (queryID === this._editorQueryID) { - this.setState({ response: JSON.stringify(error, null, 2) }); + this.setState({ response: JSON.stringify(error, null, 2) }) } - }); + } } _handleEditQuery(value) { diff --git a/src/components/Marked/swapiSchema.tsx b/src/components/Marked/swapiSchema.tsx index 0d4a608ee8..2bde45ad02 100644 --- a/src/components/Marked/swapiSchema.tsx +++ b/src/components/Marked/swapiSchema.tsx @@ -17,9 +17,9 @@ import { GraphQLString } from 'graphql'; -import { makeExecutableSchema } from 'graphql-tools'; +import { makeExecutableSchema } from '@graphql-tools/schema'; -const schemaString = ` +const typeDefs = /* GraphQL */` schema { query: Query mutation: Mutation @@ -483,6 +483,6 @@ const resolvers = { * type we defined above) and export it. */ export const StarWarsSchema = makeExecutableSchema({ - typeDefs: [schemaString], + typeDefs, resolvers }); diff --git a/yarn.lock b/yarn.lock index 5393c5203a..7462f2472f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,6 +7,13 @@ resolved "https://registry.yarnpkg.com/@ardatan/aggregate-error/-/aggregate-error-0.0.1.tgz#1403ac5de10d8ca689fc1f65844c27179ae1d44f" integrity sha512-UQ9BequOTIavs0pTHLMwQwKQF8tTV1oezY/H2O9chA+JNPFZSua55xpU5dPSjAU9/jLJ1VwU+HJuTVN8u7S6Fg== +"@ardatan/aggregate-error@0.0.6": + version "0.0.6" + resolved "https://registry.yarnpkg.com/@ardatan/aggregate-error/-/aggregate-error-0.0.6.tgz#fe6924771ea40fc98dc7a7045c2e872dc8527609" + integrity sha512-vyrkEHG1jrukmzTPtyWB4NLPauUw5bQeg4uhn8f+1SSynmrOcyvlb1GKQjjgoBzElLdfXCRYX8UnBlhklOHYRQ== + dependencies: + tslib "~2.0.1" + "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.3", "@babel/code-frame@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" @@ -1108,6 +1115,14 @@ "@graphql-tools/utils" "6.0.18" tslib "~2.0.0" +"@graphql-tools/schema@^6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-6.2.1.tgz#6b584defa37d6649180491ae32e1bb737b1d33e5" + integrity sha512-SKoZmxlLwOq08/NZ8Y5aShgEHneTJ8Ksw4gU1WBSWVJGf64ROoxIxN4Uc47F0cZxwOBqVqUy/EdXWZ8Jt97uQQ== + dependencies: + "@graphql-tools/utils" "6.2.1" + tslib "~2.0.1" + "@graphql-tools/utils@6.0.18", "@graphql-tools/utils@^6.0.14": version "6.0.18" resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-6.0.18.tgz#bba960f0ab327c8304089d41da0b7a3e00fe430f" @@ -1116,6 +1131,15 @@ "@ardatan/aggregate-error" "0.0.1" camel-case "4.1.1" +"@graphql-tools/utils@6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-6.2.1.tgz#07774dbcc7657d9f9b898721f10fc613ce116b56" + integrity sha512-DZ6a2bjOH4sWKhNUachvYy+3ocXDvDcTtComOD/z7ncszdlZPU6RXNOgBTxh/bMVHBPqlEh/VjCVMwBysZRbJw== + dependencies: + "@ardatan/aggregate-error" "0.0.6" + camel-case "4.1.1" + tslib "~2.0.1" + "@hapi/address@2.x.x": version "2.1.4" resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5" @@ -6137,14 +6161,6 @@ graphql-subscriptions@^1.1.0: dependencies: iterall "^1.2.1" -graphql-tools@^0.6.6: - version "0.6.6" - resolved "https://registry.yarnpkg.com/graphql-tools/-/graphql-tools-0.6.6.tgz#a1cacae206f8c10b860dc345d130898568e4d0dc" - integrity sha1-ocrK4gb4wQuGDcNF0TCJhWjk0Nw= - dependencies: - lodash.uniq "^4.3.0" - node-uuid "^1.4.7" - graphql-type-json@^0.2.4: version "0.2.4" resolved "https://registry.yarnpkg.com/graphql-type-json/-/graphql-type-json-0.2.4.tgz#545af27903e40c061edd30840a272ea0a49992f9" @@ -6155,13 +6171,6 @@ graphql-type-json@^0.3.2: resolved "https://registry.yarnpkg.com/graphql-type-json/-/graphql-type-json-0.3.2.tgz#f53a851dbfe07bd1c8157d24150064baab41e115" integrity sha512-J+vjof74oMlCWXSvt0DOf2APEdZOCdubEvGDUAlqH//VBYcOYsGgRW7Xzorr44LvkjiuvecWc8fChxuZZbChtg== -graphql@^0.7.0: - version "0.7.2" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.7.2.tgz#cc894a32823399b8a0cb012b9e9ecad35cd00f72" - integrity sha1-zIlKMoIzmbigywErnp7K01zQD3I= - dependencies: - iterall "1.0.2" - graphql@^14.6.0: version "14.7.0" resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.7.0.tgz#7fa79a80a69be4a31c27dda824dc04dac2035a72" @@ -6169,6 +6178,11 @@ graphql@^14.6.0: dependencies: iterall "^1.2.2" +graphql@^15.3.0: + version "15.3.0" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.3.0.tgz#3ad2b0caab0d110e3be4a5a9b2aa281e362b5278" + integrity sha512-GTCJtzJmkFLWRfFJuoo9RWWa/FfamUHgiFosxi/X1Ani4AVWbeyBenZTNX6dM+7WSbbFfTo/25eh0LLkwHMw2w== + gray-matter@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/gray-matter/-/gray-matter-4.0.2.tgz#9aa379e3acaf421193fce7d2a28cebd4518ac454" @@ -7442,11 +7456,6 @@ isurl@^1.0.0-alpha5: has-to-string-tag-x "^1.2.0" is-object "^1.0.1" -iterall@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.0.2.tgz#41a2e96ce9eda5e61c767ee5dc312373bb046e91" - integrity sha1-QaLpbOntpeYcdn7l3DEjc7sEbpE= - iterall@^1.2.1, iterall@^1.2.2: version "1.3.0" resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.3.0.tgz#afcb08492e2915cbd8a0884eb93a8c94d0d72fea" @@ -7843,7 +7852,7 @@ lodash.toarray@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz#24c4bfcd6b2fba38bfd0594db1179d8e9b656561" integrity sha1-JMS/zWsvuji/0FlNsRedjptlZWE= -lodash.uniq@4.5.0, lodash.uniq@^4.3.0, lodash.uniq@^4.5.0: +lodash.uniq@4.5.0, lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= @@ -8539,11 +8548,6 @@ node-releases@^1.1.60: resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.60.tgz#6948bdfce8286f0b5d0e5a88e8384e954dfe7084" integrity sha512-gsO4vjEdQaTusZAEebUWp2a5d7dF5DYoIpDG7WySnk7BuZDW+GPpHXoXXuYawRBr/9t5q54tirPz79kFIWg4dA== -node-uuid@^1.4.7: - version "1.4.8" - resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907" - integrity sha1-sEDrCSOWivq/jTL7HxfxFn/auQc= - noms@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/noms/-/noms-0.0.0.tgz#da8ebd9f3af9d6760919b27d9cdc8092a7332859" @@ -11928,7 +11932,7 @@ tslib@^1.0.0, tslib@^1.10.0, tslib@^1.11.2, tslib@^1.8.1, tslib@^1.9.0, tslib@^1 resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== -tslib@^2.0.0, tslib@~2.0.0: +tslib@^2.0.0, tslib@~2.0.0, tslib@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e" integrity sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==