From f87519fd5aa5399719cf485e6889a6bcc8c9966c Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Fri, 29 May 2020 08:58:29 +0000 Subject: [PATCH] Rename `isGraphQL15` to `isAtLeastGraphQL15`. While we will still have to reevaluate this in the future, we're testing for versions `>= 15` so this name matches up a bit more precisely. --- test/customTagName.js | 4 ++-- test/default.js | 4 ++-- test/env/apollo.js | 4 ++-- test/env/lokka.js | 4 ++-- test/helpers.js | 2 +- test/schemaTests/index.js | 4 ++-- test/updateSchemaJson.js | 4 ++-- test/validationRules/built-in.js | 12 ++++++------ 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/test/customTagName.js b/test/customTagName.js index 6c5b4f9..2e27b7e 100644 --- a/test/customTagName.js +++ b/test/customTagName.js @@ -1,5 +1,5 @@ import schemaJson from './schema.json'; -import { isGraphQL15 } from './helpers'; +import { isAtLeastGraphQL15 } from './helpers'; import { rule, @@ -26,7 +26,7 @@ ruleTester.run('custom tag name', rule, { parserOptions, code: 'const x = myGraphQLTag``', errors: [{ - message: isGraphQL15 ? 'Syntax Error: Unexpected .' : 'Syntax Error: Unexpected ', + message: isAtLeastGraphQL15 ? 'Syntax Error: Unexpected .' : 'Syntax Error: Unexpected ', type: 'TaggedTemplateExpression' }] }, diff --git a/test/default.js b/test/default.js index 8fa92e5..8afac50 100644 --- a/test/default.js +++ b/test/default.js @@ -1,4 +1,4 @@ -import { isGraphQL15 } from './helpers'; +import { isAtLeastGraphQL15 } from './helpers'; import schemaJson from './schema.json'; import { @@ -46,7 +46,7 @@ ruleTester.run('default options', rule, { parserOptions, code: 'const x = gql``', errors: [{ - message: isGraphQL15 ? 'Syntax Error: Unexpected .' : 'Syntax Error: Unexpected ', + message: isAtLeastGraphQL15 ? 'Syntax Error: Unexpected .' : 'Syntax Error: Unexpected ', type: 'TaggedTemplateExpression' }] }, diff --git a/test/env/apollo.js b/test/env/apollo.js index f8ac699..5a2ca79 100644 --- a/test/env/apollo.js +++ b/test/env/apollo.js @@ -1,4 +1,4 @@ -import { isGraphQL15 } from '../helpers'; +import { isAtLeastGraphQL15 } from '../helpers'; import schemaJson from '../schema.json'; import { @@ -35,7 +35,7 @@ ruleTester.run('apollo', rule, { parserOptions, code: 'const x = gql`query }{ ${x}`', errors: [{ - message: isGraphQL15 ? 'Syntax Error: Expected "{", found "}".' : 'Syntax Error: Expected {, found }', + message: isAtLeastGraphQL15 ? 'Syntax Error: Expected "{", found "}".' : 'Syntax Error: Expected {, found }', type: 'TaggedTemplateExpression' }] } diff --git a/test/env/lokka.js b/test/env/lokka.js index 9deb1ae..9d46afc 100644 --- a/test/env/lokka.js +++ b/test/env/lokka.js @@ -1,4 +1,4 @@ -import { isGraphQL15 } from '../helpers'; +import { isAtLeastGraphQL15 } from '../helpers'; import schemaJson from '../schema.json'; import { @@ -112,7 +112,7 @@ ruleTester.run('lokka', rule, { \`); `, errors: [{ - message: isGraphQL15 ? + message: isAtLeastGraphQL15 ? 'Unknown argument "wrongArg" on field "Film.director".' : 'Unknown argument "wrongArg" on field "director" of type "Film".', type: 'TaggedTemplateExpression', diff --git a/test/helpers.js b/test/helpers.js index f4afc56..c79c1e5 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -6,7 +6,7 @@ import * as graphql from 'graphql'; const { printSchema, buildClientSchema, specifiedRules: allGraphQLValidators } = graphql; -export const isGraphQL15 = graphql.versionInfo && graphql.versionInfo.major >= 15; +export const isAtLeastGraphQL15 = graphql.versionInfo && graphql.versionInfo.major >= 15; export const schemaJsonFilepath = path.resolve(__dirname, './schema.json'); export const secondSchemaJsonFilepath = path.resolve(__dirname, './second-schema.json'); diff --git a/test/schemaTests/index.js b/test/schemaTests/index.js index 027e91d..c9b1379 100644 --- a/test/schemaTests/index.js +++ b/test/schemaTests/index.js @@ -1,5 +1,5 @@ import { - isGraphQL15, + isAtLeastGraphQL15, schemaJsonFilepath, secondSchemaJsonFilepath, schemaString, @@ -48,7 +48,7 @@ import { parserOptions, code: 'const x = gql``', errors: [{ - message: isGraphQL15 ? 'Syntax Error: Unexpected .' : 'Syntax Error: Unexpected ', + message: isAtLeastGraphQL15 ? 'Syntax Error: Unexpected .' : 'Syntax Error: Unexpected ', type: 'TaggedTemplateExpression' }] }, diff --git a/test/updateSchemaJson.js b/test/updateSchemaJson.js index 598200c..d604c03 100644 --- a/test/updateSchemaJson.js +++ b/test/updateSchemaJson.js @@ -3,13 +3,13 @@ const path = require('path'); const graphql = require('graphql'); const process = require('process'); -const isGraphQL15 = graphql.versionInfo && graphql.versionInfo.major >= 15; +const isAtLeastGraphQL15 = graphql.versionInfo && graphql.versionInfo.major >= 15; Promise.all(['schema', 'second-schema'].map(schemaName => { const typeDefinition = fs.readFileSync(path.join(__dirname, schemaName + '.graphql'), 'utf8'); const schema = graphql.buildASTSchema(graphql.parse(typeDefinition)); const outputPath = path.join(__dirname, schemaName + '.json'); - const introspectionQuery = isGraphQL15 ? graphql.getIntrospectionQuery() : graphql.introspectionQuery; + const introspectionQuery = isAtLeastGraphQL15 ? graphql.getIntrospectionQuery() : graphql.introspectionQuery; return graphql.graphql(schema, introspectionQuery) .then(result => fs.writeFileSync(outputPath, JSON.stringify(result, null, 2))); diff --git a/test/validationRules/built-in.js b/test/validationRules/built-in.js index d4b045a..d1c2ab2 100644 --- a/test/validationRules/built-in.js +++ b/test/validationRules/built-in.js @@ -1,7 +1,7 @@ import schemaJson from "../schema.json"; import { - isGraphQL15, + isAtLeastGraphQL15, requiredArgumentRuleName, rule, ruleTester, @@ -12,7 +12,7 @@ const setRuleName = name => { if (name === requiredArgumentRuleName) { return name; } - return isGraphQL15 ? `${name}Rule` : name; + return isAtLeastGraphQL15 ? `${name}Rule` : name; }; const validatorCases = { @@ -43,7 +43,7 @@ const validatorCases = { alsoBreaks: [requiredArgumentRuleName], errors: [ { - message: isGraphQL15 ? + message: isAtLeastGraphQL15 ? 'Unknown argument "c" on field "Query.sum". Did you mean "a" or "b"?' : 'Unknown argument "c" on field "sum" of type "Query". Did you mean "a" or "b"?', type: "TaggedTemplateExpression" @@ -57,7 +57,7 @@ const validatorCases = { "const x = gql`{ number, allFilms @goofy(if: false) { films { title } } }`", errors: [ { - message: isGraphQL15 ? 'Unknown directive "@goofy".' : 'Unknown directive "goofy".', + message: isAtLeastGraphQL15 ? 'Unknown directive "@goofy".' : 'Unknown directive "goofy".', type: "TaggedTemplateExpression" } ] @@ -239,7 +239,7 @@ const validatorCases = { fail: "const x = gql`query($a: Int!, $a: Int!) { sum(a: $a, b: $a) }`", errors: [ { - message: isGraphQL15 ? + message: isAtLeastGraphQL15 ? 'There can be only one variable named "$a".' : 'There can be only one variable named "a".', type: "TaggedTemplateExpression" @@ -249,7 +249,7 @@ const validatorCases = { VariablesAreInputTypes: { pass: "const x = gql`query($a: Int!, $b: Int!) { sum(a: $a, b: $b) }`", fail: "const x = gql`query($a: Film!) { sum(a: 1, b: 1) }`", - alsoBreaks: [isGraphQL15 ? "NoUnusedVariablesRule" : "NoUnusedVariables"], + alsoBreaks: [isAtLeastGraphQL15 ? "NoUnusedVariablesRule" : "NoUnusedVariables"], errors: [ { message: 'Variable "$a" cannot be non-input type "Film!".',