Skip to content

Commit

Permalink
Rename isGraphQL15 to isAtLeastGraphQL15.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
abernix committed May 29, 2020
1 parent a689360 commit f87519f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions test/customTagName.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import schemaJson from './schema.json';
import { isGraphQL15 } from './helpers';
import { isAtLeastGraphQL15 } from './helpers';

import {
rule,
Expand All @@ -26,7 +26,7 @@ ruleTester.run('custom tag name', rule, {
parserOptions,
code: 'const x = myGraphQLTag``',
errors: [{
message: isGraphQL15 ? 'Syntax Error: Unexpected <EOF>.' : 'Syntax Error: Unexpected <EOF>',
message: isAtLeastGraphQL15 ? 'Syntax Error: Unexpected <EOF>.' : 'Syntax Error: Unexpected <EOF>',
type: 'TaggedTemplateExpression'
}]
},
Expand Down
4 changes: 2 additions & 2 deletions test/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isGraphQL15 } from './helpers';
import { isAtLeastGraphQL15 } from './helpers';
import schemaJson from './schema.json';

import {
Expand Down Expand Up @@ -46,7 +46,7 @@ ruleTester.run('default options', rule, {
parserOptions,
code: 'const x = gql``',
errors: [{
message: isGraphQL15 ? 'Syntax Error: Unexpected <EOF>.' : 'Syntax Error: Unexpected <EOF>',
message: isAtLeastGraphQL15 ? 'Syntax Error: Unexpected <EOF>.' : 'Syntax Error: Unexpected <EOF>',
type: 'TaggedTemplateExpression'
}]
},
Expand Down
4 changes: 2 additions & 2 deletions test/env/apollo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isGraphQL15 } from '../helpers';
import { isAtLeastGraphQL15 } from '../helpers';
import schemaJson from '../schema.json';

import {
Expand Down Expand Up @@ -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'
}]
}
Expand Down
4 changes: 2 additions & 2 deletions test/env/lokka.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isGraphQL15 } from '../helpers';
import { isAtLeastGraphQL15 } from '../helpers';
import schemaJson from '../schema.json';

import {
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions test/schemaTests/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
isGraphQL15,
isAtLeastGraphQL15,
schemaJsonFilepath,
secondSchemaJsonFilepath,
schemaString,
Expand Down Expand Up @@ -48,7 +48,7 @@ import {
parserOptions,
code: 'const x = gql``',
errors: [{
message: isGraphQL15 ? 'Syntax Error: Unexpected <EOF>.' : 'Syntax Error: Unexpected <EOF>',
message: isAtLeastGraphQL15 ? 'Syntax Error: Unexpected <EOF>.' : 'Syntax Error: Unexpected <EOF>',
type: 'TaggedTemplateExpression'
}]
},
Expand Down
4 changes: 2 additions & 2 deletions test/updateSchemaJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
12 changes: 6 additions & 6 deletions test/validationRules/built-in.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import schemaJson from "../schema.json";

import {
isGraphQL15,
isAtLeastGraphQL15,
requiredArgumentRuleName,
rule,
ruleTester,
Expand All @@ -12,7 +12,7 @@ const setRuleName = name => {
if (name === requiredArgumentRuleName) {
return name;
}
return isGraphQL15 ? `${name}Rule` : name;
return isAtLeastGraphQL15 ? `${name}Rule` : name;
};

const validatorCases = {
Expand Down Expand Up @@ -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"
Expand All @@ -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"
}
]
Expand Down Expand Up @@ -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"
Expand All @@ -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!".',
Expand Down

0 comments on commit f87519f

Please sign in to comment.