From 1c9b24096c96b39a4ca09a65c82b2d21d6048718 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:12:38 +0300 Subject: [PATCH 01/23] GraphQL v16 --- .github/workflows/canary.yml | 6 +++--- .github/workflows/release.yml | 6 +++--- .github/workflows/tests.yml | 24 +++++++++++++++--------- scripts/match-graphql.js | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 scripts/match-graphql.js diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index 97023285fb3..aea237c96f8 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -32,10 +32,10 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }} + key: ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }} - ${{ runner.os }}-16-node-modules- + ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} + ${{ runner.os }}-16-15-node-modules- - name: Install Dependencies using Yarn run: yarn install && git checkout yarn.lock && yarn patch-package - name: Release Canary diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d3a30a79e9e..d5a05f1eb42 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,10 +35,10 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }} + key: ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }} - ${{ runner.os }}-16-node-modules- + ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} + ${{ runner.os }}-16-15-node-modules- - name: Install Dependencies using Yarn run: yarn install && git checkout yarn.lock && yarn patch-package - name: Create Release Pull Request or Publish to npm diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 402c950139e..5f0c24148ec 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,10 +25,10 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }} + key: ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }} - ${{ runner.os }}-16-node-modules- + ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} + ${{ runner.os }}-16-15-node-modules- - name: Install Dependencies using Yarn run: yarn install && git checkout yarn.lock - name: Lint @@ -49,10 +49,10 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }} + key: ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-16-node-modules-${{ hashFiles('yarn.lock') }} - ${{ runner.os }}-16-node-modules- + ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} + ${{ runner.os }}-16-15-node-modules- - name: Install Dependencies using Yarn run: yarn install && git checkout yarn.lock - name: Build @@ -72,6 +72,10 @@ jobs: matrix: node_version: [12, 16] eslint_version: [7.32.0, 8] + graphql_version: + # - 14 + - 15 + - 16.0.0-rc.7 steps: - name: Checkout Master uses: actions/checkout@v2 @@ -85,10 +89,12 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{runner.os}}-${{matrix.node_version}}-${{matrix.eslint_version}}-node-modules-${{hashFiles('yarn.lock')}} + key: ${{runner.os}}-${{matrix.node_version}}-${{matrix.eslint_version}}-${{matrix.graphql_version}}-node-modules-${{hashFiles('yarn.lock')}} restore-keys: | - ${{runner.os}}-${{matrix.node_version}}-${{matrix.eslint_version}}-node-modules-${{hashFiles('yarn.lock')}} - ${{runner.os}}-${{matrix.node_version}}-${{matrix.eslint_version}}-node-modules- + ${{runner.os}}-${{matrix.node_version}}-${{matrix.eslint_version}}-${{matrix.graphql_version}}-node-modules-${{hashFiles('yarn.lock')}} + ${{runner.os}}-${{matrix.node_version}}-${{matrix.eslint_version}}-${{matrix.graphql_version}}-node-modules- + - name: Use GraphQL v${{matrix.graphql_version}} + run: node ./scripts/match-graphql.js ${{matrix.graphql_version}} - name: Use ESLint v${{matrix.eslint_version}} run: node scripts/match-eslint.mjs ${{matrix.eslint_version}} - name: Install Dependencies using Yarn diff --git a/scripts/match-graphql.js b/scripts/match-graphql.js new file mode 100644 index 00000000000..a1ef8bb391e --- /dev/null +++ b/scripts/match-graphql.js @@ -0,0 +1,19 @@ +const { writeFileSync } = require('fs'); +const { resolve } = require('path'); +const { argv, cwd } = require('process'); + +const pkgPath = resolve(cwd(), './packages/plugin/package.json'); + +const pkg = require(pkgPath); + +const version = argv[2]; + +pkg.devDependencies = pkg.devDependencies || {}; +if (pkg.devDependencies.graphql.startsWith(version)) { + console.info(`GraphQL v${version} already installed! Skipping.`); +} + +const npmVersion = version.includes('-') ? version : `^${version}`; +pkg.devDependencies.graphql = npmVersion; + +writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), 'utf8'); From abf4906901456d4352c45af5a5fa3dc01d982374 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:13:52 +0300 Subject: [PATCH 02/23] ... --- .github/workflows/tests.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5f0c24148ec..14bac952060 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,6 +36,12 @@ jobs: typecheck: name: TypeScript Type Checking runs-on: ubuntu-latest + strategy: + matrix: + graphql_version: + # - 14 + - 15 + - 16.0.0-rc.7 steps: - name: Checkout Master uses: actions/checkout@v2 @@ -49,10 +55,12 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} + key: ${{runner.os}}-${{matrix.node_version}}-${{matrix.eslint_version}}-${{matrix.graphql_version}}-node-modules-${{hashFiles('yarn.lock')}} restore-keys: | - ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} - ${{ runner.os }}-16-15-node-modules- + ${{runner.os}}-${{matrix.node_version}}-${{matrix.eslint_version}}-${{matrix.graphql_version}}-node-modules-${{hashFiles('yarn.lock')}} + ${{runner.os}}-${{matrix.node_version}}-${{matrix.eslint_version}}-${{matrix.graphql_version}}-node-modules- + - name: Use GraphQL v${{matrix.graphql_version}} + run: node ./scripts/match-graphql.js ${{matrix.graphql_version}} - name: Install Dependencies using Yarn run: yarn install && git checkout yarn.lock - name: Build From 39172c5681cb226b9e7e591bd488a8a033327324 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:14:28 +0300 Subject: [PATCH 03/23] Bypass lint --- scripts/match-graphql.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/match-graphql.js b/scripts/match-graphql.js index a1ef8bb391e..81721fd6c89 100644 --- a/scripts/match-graphql.js +++ b/scripts/match-graphql.js @@ -10,6 +10,7 @@ const version = argv[2]; pkg.devDependencies = pkg.devDependencies || {}; if (pkg.devDependencies.graphql.startsWith(version)) { + // eslint-disable-next-line no-console console.info(`GraphQL v${version} already installed! Skipping.`); } From d27e8a72e54ef0ea22b96f6b53429d9979fdd5f3 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:15:25 +0300 Subject: [PATCH 04/23] ... --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 14bac952060..52187b7a064 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -72,7 +72,7 @@ jobs: path: packages/plugin/dist test: - name: Testing on Node ${{matrix.node_version}} with ESLint v${{matrix.eslint_version}} + name: Testing on Node ${{matrix.node_version}} with ESLint v${{matrix.eslint_version}} and GraphQL v${{matrix.graphql_version}} timeout-minutes: 60 runs-on: ubuntu-latest needs: [lint, typecheck] From 87103d1bcaa1970baa1d80685b7f1a3240957c8b Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:15:55 +0300 Subject: [PATCH 05/23] ... --- babel.config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/babel.config.js b/babel.config.js index e6ffbd417e7..3e4899f4a74 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,6 @@ module.exports = { - presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'], + presets: [ + ['@babel/preset-env', { targets: { node: process.versions.node.split('.')[0] } }], + '@babel/preset-typescript', + ], }; From 8ef4b2f37e76bf0c3c289f93f70934400f94605e Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:16:59 +0300 Subject: [PATCH 06/23] Remove needs --- .github/workflows/tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 52187b7a064..adbae3c8b51 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -75,7 +75,6 @@ jobs: name: Testing on Node ${{matrix.node_version}} with ESLint v${{matrix.eslint_version}} and GraphQL v${{matrix.graphql_version}} timeout-minutes: 60 runs-on: ubuntu-latest - needs: [lint, typecheck] strategy: matrix: node_version: [12, 16] From 1d28d6f898104070af6309513ab5a2fb33c876d3 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:22:11 +0300 Subject: [PATCH 07/23] ... --- packages/plugin/src/estree-parser/converter.ts | 8 ++++---- packages/plugin/src/graphql-ast.ts | 5 ++--- packages/plugin/src/parser.ts | 4 ++-- packages/plugin/src/rules/graphql-js-validation.ts | 3 ++- packages/plugin/src/rules/no-deprecated.ts | 6 +++++- packages/plugin/src/rules/require-description.ts | 4 ++-- packages/plugin/src/sibling-operations.ts | 2 +- 7 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/plugin/src/estree-parser/converter.ts b/packages/plugin/src/estree-parser/converter.ts index 833fdf02221..23ed96b51aa 100644 --- a/packages/plugin/src/estree-parser/converter.ts +++ b/packages/plugin/src/estree-parser/converter.ts @@ -1,15 +1,15 @@ import { convertDescription, convertLocation, convertRange, extractCommentsFromAst } from './utils'; import { GraphQLESTreeNode, SafeGraphQLType } from './estree-ast'; -import { ASTNode, TypeNode, TypeInfo, visit, visitWithTypeInfo, Location, Kind, DocumentNode } from 'graphql'; +import { ASTNode, TypeNode, TypeInfo, visit, visitWithTypeInfo, Location, Kind, DocumentNode, ASTVisitor } from 'graphql'; import { Comment } from 'estree'; export function convertToESTree( node: T, typeInfo?: TypeInfo -): { rootTree: GraphQLESTreeNode; comments: Comment[] } { - const visitor = { leave: convertNode(typeInfo) }; +) { + const visitor: ASTVisitor = { leave: convertNode(typeInfo) }; return { - rootTree: visit(node, typeInfo ? visitWithTypeInfo(typeInfo, visitor) : visitor), + rootTree: visit(node, typeInfo ? visitWithTypeInfo(typeInfo, visitor) : visitor) as GraphQLESTreeNode, comments: extractCommentsFromAst(node.loc), }; } diff --git a/packages/plugin/src/graphql-ast.ts b/packages/plugin/src/graphql-ast.ts index 28eb0dc1e99..27cea4c2bea 100644 --- a/packages/plugin/src/graphql-ast.ts +++ b/packages/plugin/src/graphql-ast.ts @@ -1,9 +1,8 @@ import { ASTNode, - Visitor, + ASTVisitor, TypeInfo, GraphQLSchema, - ASTKindToNode, visit, isInterfaceType, visitWithTypeInfo, @@ -41,7 +40,7 @@ export function getReachableTypes(schema: GraphQLSchema): ReachableTypes { } }; - const visitor: Visitor = { + const visitor: ASTVisitor = { InterfaceTypeDefinition: collect, ObjectTypeDefinition: collect, InputValueDefinition: collect, diff --git a/packages/plugin/src/parser.ts b/packages/plugin/src/parser.ts index a5f3d8bcfb0..3ec5c6bfff9 100644 --- a/packages/plugin/src/parser.ts +++ b/packages/plugin/src/parser.ts @@ -1,5 +1,5 @@ import { parseGraphQLSDL } from '@graphql-tools/utils'; -import { GraphQLError, TypeInfo } from 'graphql'; +import { ASTNode, GraphQLError, TypeInfo } from 'graphql'; import { Linter } from 'eslint'; import { convertToESTree } from './estree-parser'; import { GraphQLESLintParseResult, ParserOptions, ParserServices } from './types'; @@ -32,7 +32,7 @@ export function parseForESLint(code: string, options: ParserOptions = {}): Graph noLocation: false, }); - const { rootTree, comments } = convertToESTree(graphqlAst.document, schema ? new TypeInfo(schema) : null); + const { rootTree, comments } = convertToESTree(graphqlAst.document as ASTNode, schema ? new TypeInfo(schema) : null); const tokens = extractTokens(code); return { diff --git a/packages/plugin/src/rules/graphql-js-validation.ts b/packages/plugin/src/rules/graphql-js-validation.ts index 6e40d31439a..977d4c3b72e 100644 --- a/packages/plugin/src/rules/graphql-js-validation.ts +++ b/packages/plugin/src/rules/graphql-js-validation.ts @@ -6,6 +6,7 @@ import { join, dirname } from 'path'; import { GraphQLESLintRule, GraphQLESLintRuleContext } from '../types'; import { getLocation, requireGraphQLSchemaFromContext, requireSiblingsOperations } from '../utils'; import { GraphQLESTreeNode } from '../estree-parser'; +import { SDLValidationRule } from 'graphql/validation/ValidationContext'; function extractRuleName(stack?: string): string | null { const match = (stack || '').match(/validation[/\\\\]rules[/\\\\](.*?)\.js:/) || []; @@ -17,7 +18,7 @@ export function validateDoc( context: GraphQLESLintRuleContext, schema: GraphQLSchema | null, documentNode: DocumentNode, - rules: ReadonlyArray, + rules: ReadonlyArray, ruleName: string | null = null ): void { if (documentNode?.definitions?.length > 0) { diff --git a/packages/plugin/src/rules/no-deprecated.ts b/packages/plugin/src/rules/no-deprecated.ts index 047472331f4..511b08552f1 100644 --- a/packages/plugin/src/rules/no-deprecated.ts +++ b/packages/plugin/src/rules/no-deprecated.ts @@ -86,7 +86,7 @@ const rule: GraphQLESLintRule<[], true> = { const typeInfo = node.typeInfo(); if (typeInfo && typeInfo.enumValue) { - if (typeInfo.enumValue.isDeprecated) { + if (typeInfo.enumValue.deprecationReason) { const enumValueName = node.value; context.report({ loc: getLocation(node.loc, enumValueName), @@ -104,8 +104,12 @@ const rule: GraphQLESLintRule<[], true> = { const typeInfo = node.typeInfo(); if (typeInfo && typeInfo.fieldDef) { +<<<<<<< HEAD if (typeInfo.fieldDef.isDeprecated) { const fieldName = node.name.value; +======= + if (typeInfo.fieldDef.deprecationReason) { +>>>>>>> ... context.report({ loc: getLocation(node.loc, fieldName), messageId: NO_DEPRECATED, diff --git a/packages/plugin/src/rules/require-description.ts b/packages/plugin/src/rules/require-description.ts index e50095dbc60..3125e166adf 100644 --- a/packages/plugin/src/rules/require-description.ts +++ b/packages/plugin/src/rules/require-description.ts @@ -49,7 +49,7 @@ const rule: GraphQLESLintRule = { examples: [ { title: 'Incorrect', - usage: [{ on: ['ObjectTypeDefinition', 'FieldDefinition'] }], + usage: [{ on: [Kind.OBJECT_TYPE_DEFINITION, Kind.FIELD_DEFINITION] }], code: /* GraphQL */ ` type someTypeName { name: String @@ -58,7 +58,7 @@ const rule: GraphQLESLintRule = { }, { title: 'Correct', - usage: [{ on: ['ObjectTypeDefinition', 'FieldDefinition'] }], + usage: [{ on: [Kind.OBJECT_TYPE_DEFINITION, Kind.FIELD_DEFINITION] }], code: /* GraphQL */ ` """ Some type description diff --git a/packages/plugin/src/sibling-operations.ts b/packages/plugin/src/sibling-operations.ts index 09989021a68..06c2961300a 100644 --- a/packages/plugin/src/sibling-operations.ts +++ b/packages/plugin/src/sibling-operations.ts @@ -141,7 +141,7 @@ export function getSiblingOperations(options: ParserOptions, gqlConfig: GraphQLC if (definition.kind === Kind.OPERATION_DEFINITION) { result.push({ filePath: source.location, - document: definition, + document: definition as OperationDefinitionNode, }); } } From bb081d2c8749e7207559fb613949bf783588052c Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:22:21 +0300 Subject: [PATCH 08/23] ... --- packages/plugin/src/estree-parser/converter.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/plugin/src/estree-parser/converter.ts b/packages/plugin/src/estree-parser/converter.ts index 23ed96b51aa..61aad877c7a 100644 --- a/packages/plugin/src/estree-parser/converter.ts +++ b/packages/plugin/src/estree-parser/converter.ts @@ -1,7 +1,6 @@ import { convertDescription, convertLocation, convertRange, extractCommentsFromAst } from './utils'; import { GraphQLESTreeNode, SafeGraphQLType } from './estree-ast'; import { ASTNode, TypeNode, TypeInfo, visit, visitWithTypeInfo, Location, Kind, DocumentNode, ASTVisitor } from 'graphql'; -import { Comment } from 'estree'; export function convertToESTree( node: T, From 1ed83ae076601bd6b26d51a79196f8d7961012ab Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:22:54 +0300 Subject: [PATCH 09/23] changeset --- .changeset/green-lions-grow.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/green-lions-grow.md diff --git a/.changeset/green-lions-grow.md b/.changeset/green-lions-grow.md new file mode 100644 index 00000000000..68392dcb38d --- /dev/null +++ b/.changeset/green-lions-grow.md @@ -0,0 +1,5 @@ +--- +'@graphql-eslint/eslint-plugin': minor +--- + +GraphQL v16 support From 7a89dddcbc8754ecc3efc63433f27fd347fc84e3 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:26:29 +0300 Subject: [PATCH 10/23] .. --- .github/workflows/tests.yml | 1 + packages/plugin/src/rules/graphql-js-validation.ts | 4 ++-- packages/plugin/src/sibling-operations.ts | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index adbae3c8b51..52187b7a064 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -75,6 +75,7 @@ jobs: name: Testing on Node ${{matrix.node_version}} with ESLint v${{matrix.eslint_version}} and GraphQL v${{matrix.graphql_version}} timeout-minutes: 60 runs-on: ubuntu-latest + needs: [lint, typecheck] strategy: matrix: node_version: [12, 16] diff --git a/packages/plugin/src/rules/graphql-js-validation.ts b/packages/plugin/src/rules/graphql-js-validation.ts index 977d4c3b72e..6992827a74a 100644 --- a/packages/plugin/src/rules/graphql-js-validation.ts +++ b/packages/plugin/src/rules/graphql-js-validation.ts @@ -18,12 +18,12 @@ export function validateDoc( context: GraphQLESLintRuleContext, schema: GraphQLSchema | null, documentNode: DocumentNode, - rules: ReadonlyArray, + rules: ReadonlyArray, ruleName: string | null = null ): void { if (documentNode?.definitions?.length > 0) { try { - const validationErrors = schema ? validate(schema, documentNode, rules) : validateSDL(documentNode, null, rules); + const validationErrors = schema ? validate(schema, documentNode, rules) : validateSDL(documentNode, null, rules as ReadonlyArray); for (const error of validationErrors) { const validateRuleName = ruleName || `[${extractRuleName(error.stack)}]`; diff --git a/packages/plugin/src/sibling-operations.ts b/packages/plugin/src/sibling-operations.ts index 06c2961300a..ee17368c69b 100644 --- a/packages/plugin/src/sibling-operations.ts +++ b/packages/plugin/src/sibling-operations.ts @@ -120,7 +120,7 @@ export function getSiblingOperations(options: ParserOptions, gqlConfig: GraphQLC if (definition.kind === Kind.FRAGMENT_DEFINITION) { result.push({ filePath: source.location, - document: definition, + document: definition as FragmentDefinitionNode, }); } } From 9dd6149a1afe2857cfe1fd85a5f64a63396545f7 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:27:13 +0300 Subject: [PATCH 11/23] ... --- scripts/match-graphql.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/match-graphql.js b/scripts/match-graphql.js index 81721fd6c89..d267c7368ef 100644 --- a/scripts/match-graphql.js +++ b/scripts/match-graphql.js @@ -11,7 +11,7 @@ const version = argv[2]; pkg.devDependencies = pkg.devDependencies || {}; if (pkg.devDependencies.graphql.startsWith(version)) { // eslint-disable-next-line no-console - console.info(`GraphQL v${version} already installed! Skipping.`); + console.info(`GraphQL v${version} is match! Skipping.`); } const npmVersion = version.includes('-') ? version : `^${version}`; From 0d403850bac0d9b19224833207648333e671e255 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:28:38 +0300 Subject: [PATCH 12/23] Add missing return --- scripts/match-graphql.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/match-graphql.js b/scripts/match-graphql.js index d267c7368ef..90c17556b9f 100644 --- a/scripts/match-graphql.js +++ b/scripts/match-graphql.js @@ -12,6 +12,7 @@ pkg.devDependencies = pkg.devDependencies || {}; if (pkg.devDependencies.graphql.startsWith(version)) { // eslint-disable-next-line no-console console.info(`GraphQL v${version} is match! Skipping.`); + return; } const npmVersion = version.includes('-') ? version : `^${version}`; From 3ecfd1723d4a61d1a39710c7007f4611c878172f Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:34:35 +0300 Subject: [PATCH 13/23] ... --- packages/plugin/src/rules/graphql-js-validation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin/src/rules/graphql-js-validation.ts b/packages/plugin/src/rules/graphql-js-validation.ts index 6992827a74a..6c7224c45ad 100644 --- a/packages/plugin/src/rules/graphql-js-validation.ts +++ b/packages/plugin/src/rules/graphql-js-validation.ts @@ -23,7 +23,7 @@ export function validateDoc( ): void { if (documentNode?.definitions?.length > 0) { try { - const validationErrors = schema ? validate(schema, documentNode, rules) : validateSDL(documentNode, null, rules as ReadonlyArray); + const validationErrors = schema ? validate(schema, documentNode, rules) : validateSDL(documentNode, null, rules as any); for (const error of validationErrors) { const validateRuleName = ruleName || `[${extractRuleName(error.stack)}]`; From ffa0c85fedbd6ddb2e5ea37f8e5fdb5ef3eb7345 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:39:59 +0300 Subject: [PATCH 14/23] Use resolutions --- .github/workflows/canary.yml | 6 +++--- .github/workflows/release.yml | 6 +++--- .github/workflows/tests.yml | 6 +++--- package.json | 3 ++- scripts/match-graphql.js | 8 ++++---- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index aea237c96f8..bf509e4967c 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -32,10 +32,10 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} + key: ${{ runner.os }}-16-8-15-node-modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} - ${{ runner.os }}-16-15-node-modules- + ${{ runner.os }}-16-8-15-node-modules-${{ hashFiles('yarn.lock') }} + ${{ runner.os }}-16-8-15-node-modules- - name: Install Dependencies using Yarn run: yarn install && git checkout yarn.lock && yarn patch-package - name: Release Canary diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d5a05f1eb42..d3aa82af4c0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,10 +35,10 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} + key: ${{ runner.os }}-16-8-15-node-modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} - ${{ runner.os }}-16-15-node-modules- + ${{ runner.os }}-16-8-15-node-modules-${{ hashFiles('yarn.lock') }} + ${{ runner.os }}-16-8-15-node-modules- - name: Install Dependencies using Yarn run: yarn install && git checkout yarn.lock && yarn patch-package - name: Create Release Pull Request or Publish to npm diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 52187b7a064..08ce054ab6e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -55,10 +55,10 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{runner.os}}-${{matrix.node_version}}-${{matrix.eslint_version}}-${{matrix.graphql_version}}-node-modules-${{hashFiles('yarn.lock')}} + key: ${{runner.os}}-16-8-${{matrix.graphql_version}}-node-modules-${{hashFiles('yarn.lock')}} restore-keys: | - ${{runner.os}}-${{matrix.node_version}}-${{matrix.eslint_version}}-${{matrix.graphql_version}}-node-modules-${{hashFiles('yarn.lock')}} - ${{runner.os}}-${{matrix.node_version}}-${{matrix.eslint_version}}-${{matrix.graphql_version}}-node-modules- + ${{runner.os}}-16-8-${{matrix.graphql_version}}-node-modules-${{hashFiles('yarn.lock')}} + ${{runner.os}}-16-8-${{matrix.graphql_version}}-node-modules- - name: Use GraphQL v${{matrix.graphql_version}} run: node ./scripts/match-graphql.js ${{matrix.graphql_version}} - name: Install Dependencies using Yarn diff --git a/package.json b/package.json index bc9f1dfed1b..482fc846e48 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,8 @@ "typescript": "4.4.4" }, "resolutions": { - "@changesets/git": "1.1.2" + "@changesets/git": "1.1.2", + "graphql": "15.7.1" }, "lint-staged": { "{packages,scripts}/**/*.{ts,tsx,js,jsx,cjs,mjs}": [ diff --git a/scripts/match-graphql.js b/scripts/match-graphql.js index 90c17556b9f..7b0c65ab4ce 100644 --- a/scripts/match-graphql.js +++ b/scripts/match-graphql.js @@ -2,20 +2,20 @@ const { writeFileSync } = require('fs'); const { resolve } = require('path'); const { argv, cwd } = require('process'); -const pkgPath = resolve(cwd(), './packages/plugin/package.json'); +const pkgPath = resolve(cwd(), '../package.json'); const pkg = require(pkgPath); const version = argv[2]; -pkg.devDependencies = pkg.devDependencies || {}; -if (pkg.devDependencies.graphql.startsWith(version)) { +pkg.resolutions = pkg.resolutions || {}; +if (pkg.resolutions.graphql.startsWith(version)) { // eslint-disable-next-line no-console console.info(`GraphQL v${version} is match! Skipping.`); return; } const npmVersion = version.includes('-') ? version : `^${version}`; -pkg.devDependencies.graphql = npmVersion; +pkg.resolutions.graphql = npmVersion; writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), 'utf8'); From 071617b0a4d2ba9a01322a0f0af06e35589bf918 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:41:00 +0300 Subject: [PATCH 15/23] Fix path --- scripts/match-graphql.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/match-graphql.js b/scripts/match-graphql.js index 7b0c65ab4ce..58eb40615eb 100644 --- a/scripts/match-graphql.js +++ b/scripts/match-graphql.js @@ -2,7 +2,7 @@ const { writeFileSync } = require('fs'); const { resolve } = require('path'); const { argv, cwd } = require('process'); -const pkgPath = resolve(cwd(), '../package.json'); +const pkgPath = resolve(__dirname, '../package.json'); const pkg = require(pkgPath); From 59acec49dc0e2e0a6dda914070f73469d8d1d20e Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:44:49 +0300 Subject: [PATCH 16/23] .. --- packages/plugin/tests/schema.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin/tests/schema.spec.ts b/packages/plugin/tests/schema.spec.ts index 9012a26acfd..246839cfa36 100644 --- a/packages/plugin/tests/schema.spec.ts +++ b/packages/plugin/tests/schema.spec.ts @@ -17,7 +17,7 @@ describe('schema', () => { expect(graphQLSchema).toBeInstanceOf(GraphQLSchema); const sdlString = printSchema(graphQLSchema); - expect(sdlString).toBe(schemaOnDisk); + expect(sdlString.trim()).toBe(schemaOnDisk.trim()); }; describe('GraphQLFileLoader', () => { From 2fa6992fb6555c1fb4e542b3c2428d5eed83dbea Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 27 Oct 2021 22:53:43 +0300 Subject: [PATCH 17/23] Update paatch and remove unused import --- .vscode/settings.json | 13 ++++++++++++- .../plugin/src/rules/graphql-js-validation.ts | 1 - patches/eslint+8.1.0.patch | 5 ++--- yarn.lock | 16 ++-------------- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 4718ffd990e..ed5e943f71d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,14 @@ { - "eslint.enable": true + "eslint.enable": true, + "files.exclude": { + "**/.git": true, + "**/.DS_Store": true, + "**/node_modules": true, + "test-lib": true, + "lib": true, + "coverage": true, + "npm": true, + "**/dist": true + }, + "typescript.tsdk": "node_modules/typescript/lib" } \ No newline at end of file diff --git a/packages/plugin/src/rules/graphql-js-validation.ts b/packages/plugin/src/rules/graphql-js-validation.ts index 6c7224c45ad..df13823f778 100644 --- a/packages/plugin/src/rules/graphql-js-validation.ts +++ b/packages/plugin/src/rules/graphql-js-validation.ts @@ -6,7 +6,6 @@ import { join, dirname } from 'path'; import { GraphQLESLintRule, GraphQLESLintRuleContext } from '../types'; import { getLocation, requireGraphQLSchemaFromContext, requireSiblingsOperations } from '../utils'; import { GraphQLESTreeNode } from '../estree-parser'; -import { SDLValidationRule } from 'graphql/validation/ValidationContext'; function extractRuleName(stack?: string): string | null { const match = (stack || '').match(/validation[/\\\\]rules[/\\\\](.*?)\.js:/) || []; diff --git a/patches/eslint+8.1.0.patch b/patches/eslint+8.1.0.patch index 8a892127602..bfaa9aa569f 100644 --- a/patches/eslint+8.1.0.patch +++ b/patches/eslint+8.1.0.patch @@ -1,8 +1,8 @@ diff --git a/node_modules/eslint/lib/rule-tester/rule-tester.js b/node_modules/eslint/lib/rule-tester/rule-tester.js -index 324af7b..e771420 100644 +index 7f590a5..5368321 100644 --- a/node_modules/eslint/lib/rule-tester/rule-tester.js +++ b/node_modules/eslint/lib/rule-tester/rule-tester.js -@@ -943,8 +943,18 @@ class RuleTester { +@@ -946,7 +946,17 @@ class RuleTester { "Expected no autofixes to be suggested" ); } else { @@ -21,4 +21,3 @@ index 324af7b..e771420 100644 } } else { assert.strictEqual( - result.output, diff --git a/yarn.lock b/yarn.lock index de7f038d7b6..e4fdba7c392 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3923,23 +3923,11 @@ graphql-ws@^5.0.0: resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-5.3.0.tgz#345f73686b639735f1f4ef0b9ea28e17c7f6a745" integrity sha512-53MbSTOmgx5i6hf3DHVD5PrXix1drDmt2ja8MW7NG+aTpKGzkXVLyNcyNpxme4SK8jVtIV6ZIHkiwirqN0efpw== -graphql@15.7.1: +graphql@15.7.1, graphql@15.7.2, graphql@^14.5.3: version "15.7.1" resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.7.1.tgz#c821a1741e04e2bc2c91e138f34c06a86c0464f1" integrity sha512-x34S6gC0/peBZnlK60zCJox/d45A7p6At9oN9EPA3qhoIAlR4LNZmXRLkICBckwwTMJzVdA8cx3QIQZMOl606A== -graphql@15.7.2: - version "15.7.2" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.7.2.tgz#85ab0eeb83722977151b3feb4d631b5f2ab287ef" - integrity sha512-AnnKk7hFQFmU/2I9YSQf3xw44ctnSFCfp3zE0N6W174gqe9fWG/2rKaKxROK7CcI3XtERpjEKFqts8o319Kf7A== - -graphql@^14.5.3: - version "14.7.0" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.7.0.tgz#7fa79a80a69be4a31c27dda824dc04dac2035a72" - integrity sha512-l0xWZpoPKpppFzMfvVyFmp9vLN7w/ZZJPefUicMCepfJeQ8sMcztloGYY9DfjVPo6tIUDzU5Hw3MUbIjj9AVVA== - dependencies: - iterall "^1.2.2" - hard-rejection@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/hard-rejection/-/hard-rejection-2.1.0.tgz#1c6eda5c1685c63942766d79bb40ae773cecd883" @@ -4373,7 +4361,7 @@ istanbul-reports@^3.0.2: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" -iterall@^1.2.1, iterall@^1.2.2: +iterall@^1.2.1: version "1.3.0" resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.3.0.tgz#afcb08492e2915cbd8a0884eb93a8c94d0d72fea" integrity sha512-QZ9qOMdF+QLHxy1QIpUHUU1D5pS2CG2P69LF6L6CPjPYA/XMOmKV3PZpawHoAjHNyB0swdVTRxdYT4tbBbxqwg== From 8acbb2abed9833c76c7a7cc86d9017213800ba59 Mon Sep 17 00:00:00 2001 From: dimitri Date: Wed, 27 Oct 2021 22:51:21 +0200 Subject: [PATCH 18/23] fix UrlLoader broken test on GraphQL v16 --- packages/plugin/tests/mocks/graphql-server.ts | 9 ++++++++- packages/plugin/tests/schema.spec.ts | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/plugin/tests/mocks/graphql-server.ts b/packages/plugin/tests/mocks/graphql-server.ts index 71b5050cbfa..a65d69c458d 100644 --- a/packages/plugin/tests/mocks/graphql-server.ts +++ b/packages/plugin/tests/mocks/graphql-server.ts @@ -1,3 +1,5 @@ +// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type errors from `graphql` package +// @ts-nocheck import { readFileSync } from 'fs'; import { resolve } from 'path'; import { createServer, Server, IncomingMessage, ServerResponse } from 'http'; @@ -5,7 +7,12 @@ import { buildSchema, getIntrospectionQuery, graphqlSync } from 'graphql'; const sdlSchema = readFileSync(resolve(__dirname, 'user-schema.graphql'), 'utf8'); const graphqlSchemaObj = buildSchema(sdlSchema); -const introspectionQueryResult = graphqlSync(graphqlSchemaObj, getIntrospectionQuery()); +const introspectionQueryResult = require('graphql/package.json').version.startsWith('16') + ? graphqlSync({ + schema: graphqlSchemaObj, + source: getIntrospectionQuery(), + }) + : graphqlSync(graphqlSchemaObj, getIntrospectionQuery()); class TestGraphQLServer { private server: Server; diff --git a/packages/plugin/tests/schema.spec.ts b/packages/plugin/tests/schema.spec.ts index 246839cfa36..7c533ca4127 100644 --- a/packages/plugin/tests/schema.spec.ts +++ b/packages/plugin/tests/schema.spec.ts @@ -54,6 +54,9 @@ describe('schema', () => { url = chunk.toString().trimRight(); done(); }); + local.stderr.on('data', chunk => { + throw new Error(chunk.toString().trimRight()); + }); }); afterAll(done => { From 8a87dcf9e0ad3de5f719528857e7842b707bfef5 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Thu, 28 Oct 2021 00:11:40 +0300 Subject: [PATCH 19/23] Use introspectioFromSchema --- packages/plugin/tests/mocks/graphql-server.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/plugin/tests/mocks/graphql-server.ts b/packages/plugin/tests/mocks/graphql-server.ts index a65d69c458d..9e7c0a27419 100644 --- a/packages/plugin/tests/mocks/graphql-server.ts +++ b/packages/plugin/tests/mocks/graphql-server.ts @@ -3,16 +3,11 @@ import { readFileSync } from 'fs'; import { resolve } from 'path'; import { createServer, Server, IncomingMessage, ServerResponse } from 'http'; -import { buildSchema, getIntrospectionQuery, graphqlSync } from 'graphql'; +import { buildSchema, introspectionFromSchema } from 'graphql'; const sdlSchema = readFileSync(resolve(__dirname, 'user-schema.graphql'), 'utf8'); const graphqlSchemaObj = buildSchema(sdlSchema); -const introspectionQueryResult = require('graphql/package.json').version.startsWith('16') - ? graphqlSync({ - schema: graphqlSchemaObj, - source: getIntrospectionQuery(), - }) - : graphqlSync(graphqlSchemaObj, getIntrospectionQuery()); +const introspectionQueryResult = introspectionFromSchema(graphqlSchemaObj); class TestGraphQLServer { private server: Server; From 27d5d67cb036c15eae84f86e1ef2a7d045d9702a Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Thu, 28 Oct 2021 00:15:50 +0300 Subject: [PATCH 20/23] ooops --- packages/plugin/tests/mocks/graphql-server.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/plugin/tests/mocks/graphql-server.ts b/packages/plugin/tests/mocks/graphql-server.ts index 9e7c0a27419..a1483adbfdc 100644 --- a/packages/plugin/tests/mocks/graphql-server.ts +++ b/packages/plugin/tests/mocks/graphql-server.ts @@ -40,7 +40,9 @@ class TestGraphQLServer { if (pathname === '/') { const { query } = await this.parseData(req); if (query.includes('query IntrospectionQuery')) { - res.end(JSON.stringify(introspectionQueryResult)); + res.end(JSON.stringify({ + data: introspectionQueryResult + })); } } else if (pathname === '/my-headers') { res.end(JSON.stringify(req.headers)); From b49ae42eeb08d3ca07e1d2e75ca09fcef4d291ce Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Mon, 1 Nov 2021 01:40:35 +0300 Subject: [PATCH 21/23] Bump GraphQLjs --- .github/workflows/canary.yml | 6 +++--- .github/workflows/release.yml | 6 +++--- .github/workflows/tests.yml | 10 +++++----- examples/basic/package.json | 2 +- examples/code-file/package.json | 2 +- examples/graphql-config-code-file/package.json | 2 +- examples/graphql-config/package.json | 2 +- examples/prettier/package.json | 2 +- package.json | 2 +- packages/plugin/package.json | 2 +- packages/plugin/src/rules/no-deprecated.ts | 6 +----- scripts/match-graphql.js | 2 +- yarn.lock | 8 ++++---- 13 files changed, 24 insertions(+), 28 deletions(-) diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index bf509e4967c..ad63dc4d065 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -32,10 +32,10 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{ runner.os }}-16-8-15-node-modules-${{ hashFiles('yarn.lock') }} + key: ${{ runner.os }}-16-8-16-node-modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-16-8-15-node-modules-${{ hashFiles('yarn.lock') }} - ${{ runner.os }}-16-8-15-node-modules- + ${{ runner.os }}-16-8-16-node-modules-${{ hashFiles('yarn.lock') }} + ${{ runner.os }}-16-8-16-node-modules- - name: Install Dependencies using Yarn run: yarn install && git checkout yarn.lock && yarn patch-package - name: Release Canary diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d3aa82af4c0..c7d2bd7dc9e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,10 +35,10 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{ runner.os }}-16-8-15-node-modules-${{ hashFiles('yarn.lock') }} + key: ${{ runner.os }}-16-8-16-node-modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-16-8-15-node-modules-${{ hashFiles('yarn.lock') }} - ${{ runner.os }}-16-8-15-node-modules- + ${{ runner.os }}-16-8-16-node-modules-${{ hashFiles('yarn.lock') }} + ${{ runner.os }}-16-8-16-node-modules- - name: Install Dependencies using Yarn run: yarn install && git checkout yarn.lock && yarn patch-package - name: Create Release Pull Request or Publish to npm diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 08ce054ab6e..626e3209e1b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,10 +25,10 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} + key: ${{ runner.os }}-16-16-node-modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-16-15-node-modules-${{ hashFiles('yarn.lock') }} - ${{ runner.os }}-16-15-node-modules- + ${{ runner.os }}-16-16-node-modules-${{ hashFiles('yarn.lock') }} + ${{ runner.os }}-16-16-node-modules- - name: Install Dependencies using Yarn run: yarn install && git checkout yarn.lock - name: Lint @@ -41,7 +41,7 @@ jobs: graphql_version: # - 14 - 15 - - 16.0.0-rc.7 + - 16 steps: - name: Checkout Master uses: actions/checkout@v2 @@ -83,7 +83,7 @@ jobs: graphql_version: # - 14 - 15 - - 16.0.0-rc.7 + - 16 steps: - name: Checkout Master uses: actions/checkout@v2 diff --git a/examples/basic/package.json b/examples/basic/package.json index ab2dc4f162b..340a97738ec 100644 --- a/examples/basic/package.json +++ b/examples/basic/package.json @@ -9,7 +9,7 @@ "lint": "eslint ." }, "dependencies": { - "graphql": "15.7.1" + "graphql": "16.0.0" }, "devDependencies": { "@graphql-eslint/eslint-plugin": "2.3.2", diff --git a/examples/code-file/package.json b/examples/code-file/package.json index 7ca15b2f0b8..29b6cc7468f 100644 --- a/examples/code-file/package.json +++ b/examples/code-file/package.json @@ -9,7 +9,7 @@ "lint": "eslint ." }, "dependencies": { - "graphql": "15.7.1" + "graphql": "16.0.0" }, "devDependencies": { "@graphql-eslint/eslint-plugin": "2.3.2", diff --git a/examples/graphql-config-code-file/package.json b/examples/graphql-config-code-file/package.json index d90638cd1f9..0160bef93fb 100644 --- a/examples/graphql-config-code-file/package.json +++ b/examples/graphql-config-code-file/package.json @@ -9,7 +9,7 @@ "lint": "eslint --ext graphql,js ." }, "dependencies": { - "graphql": "15.7.1", + "graphql": "16.0.0", "graphql-tag": "^2.12.5" }, "devDependencies": { diff --git a/examples/graphql-config/package.json b/examples/graphql-config/package.json index ddce1f40ace..a8328b2647c 100644 --- a/examples/graphql-config/package.json +++ b/examples/graphql-config/package.json @@ -9,7 +9,7 @@ "lint": "eslint ." }, "dependencies": { - "graphql": "15.7.1" + "graphql": "16.0.0" }, "devDependencies": { "@graphql-eslint/eslint-plugin": "2.3.2", diff --git a/examples/prettier/package.json b/examples/prettier/package.json index 7aebc6469c3..16f57aa0f44 100644 --- a/examples/prettier/package.json +++ b/examples/prettier/package.json @@ -9,7 +9,7 @@ "lint": "eslint ." }, "dependencies": { - "graphql": "15.7.1" + "graphql": "16.0.0" }, "devDependencies": { "@graphql-eslint/eslint-plugin": "2.3.2", diff --git a/package.json b/package.json index 482fc846e48..047ff57b1d6 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ }, "resolutions": { "@changesets/git": "1.1.2", - "graphql": "15.7.1" + "graphql": "16.0.0" }, "lint-staged": { "{packages,scripts}/**/*.{ts,tsx,js,jsx,cjs,mjs}": [ diff --git a/packages/plugin/package.json b/packages/plugin/package.json index 366448578e8..0751eef66f8 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -41,7 +41,7 @@ "@types/graphql-depth-limit": "1.1.3", "@types/lodash.lowercase": "4.3.6", "bob-the-bundler": "1.5.1", - "graphql": "15.7.2", + "graphql": "16.0.0", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/packages/plugin/src/rules/no-deprecated.ts b/packages/plugin/src/rules/no-deprecated.ts index 511b08552f1..6ca1b3466e5 100644 --- a/packages/plugin/src/rules/no-deprecated.ts +++ b/packages/plugin/src/rules/no-deprecated.ts @@ -104,12 +104,8 @@ const rule: GraphQLESLintRule<[], true> = { const typeInfo = node.typeInfo(); if (typeInfo && typeInfo.fieldDef) { -<<<<<<< HEAD - if (typeInfo.fieldDef.isDeprecated) { - const fieldName = node.name.value; -======= if (typeInfo.fieldDef.deprecationReason) { ->>>>>>> ... + const fieldName = node.name.value; context.report({ loc: getLocation(node.loc, fieldName), messageId: NO_DEPRECATED, diff --git a/scripts/match-graphql.js b/scripts/match-graphql.js index 58eb40615eb..c19a782ee92 100644 --- a/scripts/match-graphql.js +++ b/scripts/match-graphql.js @@ -1,6 +1,6 @@ const { writeFileSync } = require('fs'); const { resolve } = require('path'); -const { argv, cwd } = require('process'); +const { argv } = require('process'); const pkgPath = resolve(__dirname, '../package.json'); diff --git a/yarn.lock b/yarn.lock index e4fdba7c392..e88a93b7432 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3923,10 +3923,10 @@ graphql-ws@^5.0.0: resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-5.3.0.tgz#345f73686b639735f1f4ef0b9ea28e17c7f6a745" integrity sha512-53MbSTOmgx5i6hf3DHVD5PrXix1drDmt2ja8MW7NG+aTpKGzkXVLyNcyNpxme4SK8jVtIV6ZIHkiwirqN0efpw== -graphql@15.7.1, graphql@15.7.2, graphql@^14.5.3: - version "15.7.1" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.7.1.tgz#c821a1741e04e2bc2c91e138f34c06a86c0464f1" - integrity sha512-x34S6gC0/peBZnlK60zCJox/d45A7p6At9oN9EPA3qhoIAlR4LNZmXRLkICBckwwTMJzVdA8cx3QIQZMOl606A== +graphql@16.0.0, graphql@^14.5.3: + version "16.0.0" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.0.0.tgz#5724f2767aefa543418e83671372117c39408c8f" + integrity sha512-n9NxoRfwnpYBZB/WJ7L166gyrShuZ8qYgVaX8oxVyELcJfAwkvwPt6WlYIl90WRlzqDjaNWvLmNOSnKs5llZWQ== hard-rejection@^2.1.0: version "2.1.0" From 6485a71ebcab56a92ccf8d8b435bd562de2285da Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Mon, 1 Nov 2021 01:47:23 +0300 Subject: [PATCH 22/23] No need to wait for lint to run unit tests/Fix cache entry name --- .github/workflows/tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 626e3209e1b..c538690afec 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,10 +25,10 @@ jobs: uses: actions/cache@v2 with: path: '**/node_modules' - key: ${{ runner.os }}-16-16-node-modules-${{ hashFiles('yarn.lock') }} + key: ${{ runner.os }}-16-8-16-node-modules-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-16-16-node-modules-${{ hashFiles('yarn.lock') }} - ${{ runner.os }}-16-16-node-modules- + ${{ runner.os }}-16-8-16-node-modules-${{ hashFiles('yarn.lock') }} + ${{ runner.os }}-16-8-16-node-modules- - name: Install Dependencies using Yarn run: yarn install && git checkout yarn.lock - name: Lint @@ -75,7 +75,7 @@ jobs: name: Testing on Node ${{matrix.node_version}} with ESLint v${{matrix.eslint_version}} and GraphQL v${{matrix.graphql_version}} timeout-minutes: 60 runs-on: ubuntu-latest - needs: [lint, typecheck] + needs: [typecheck] strategy: matrix: node_version: [12, 16] From 3ad7c3fcf812c69b88a392a7861e578a80866c98 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Tue, 2 Nov 2021 00:56:20 +0300 Subject: [PATCH 23/23] Bump GraphQL v16 --- examples/basic/package.json | 2 +- examples/code-file/package.json | 2 +- examples/graphql-config-code-file/package.json | 2 +- examples/graphql-config/package.json | 2 +- examples/prettier/package.json | 2 +- package.json | 2 +- packages/plugin/package.json | 2 +- packages/plugin/src/parser.ts | 4 ++-- packages/plugin/src/utils.ts | 4 ++-- yarn.lock | 8 ++++---- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/basic/package.json b/examples/basic/package.json index 340a97738ec..041273240c1 100644 --- a/examples/basic/package.json +++ b/examples/basic/package.json @@ -9,7 +9,7 @@ "lint": "eslint ." }, "dependencies": { - "graphql": "16.0.0" + "graphql": "16.0.1" }, "devDependencies": { "@graphql-eslint/eslint-plugin": "2.3.2", diff --git a/examples/code-file/package.json b/examples/code-file/package.json index 29b6cc7468f..cc848ad97c7 100644 --- a/examples/code-file/package.json +++ b/examples/code-file/package.json @@ -9,7 +9,7 @@ "lint": "eslint ." }, "dependencies": { - "graphql": "16.0.0" + "graphql": "16.0.1" }, "devDependencies": { "@graphql-eslint/eslint-plugin": "2.3.2", diff --git a/examples/graphql-config-code-file/package.json b/examples/graphql-config-code-file/package.json index 0160bef93fb..d6dd566ada8 100644 --- a/examples/graphql-config-code-file/package.json +++ b/examples/graphql-config-code-file/package.json @@ -9,7 +9,7 @@ "lint": "eslint --ext graphql,js ." }, "dependencies": { - "graphql": "16.0.0", + "graphql": "16.0.1", "graphql-tag": "^2.12.5" }, "devDependencies": { diff --git a/examples/graphql-config/package.json b/examples/graphql-config/package.json index a8328b2647c..f48fb2e7327 100644 --- a/examples/graphql-config/package.json +++ b/examples/graphql-config/package.json @@ -9,7 +9,7 @@ "lint": "eslint ." }, "dependencies": { - "graphql": "16.0.0" + "graphql": "16.0.1" }, "devDependencies": { "@graphql-eslint/eslint-plugin": "2.3.2", diff --git a/examples/prettier/package.json b/examples/prettier/package.json index 16f57aa0f44..73baab240ba 100644 --- a/examples/prettier/package.json +++ b/examples/prettier/package.json @@ -9,7 +9,7 @@ "lint": "eslint ." }, "dependencies": { - "graphql": "16.0.0" + "graphql": "16.0.1" }, "devDependencies": { "@graphql-eslint/eslint-plugin": "2.3.2", diff --git a/package.json b/package.json index 047ff57b1d6..628b325bddb 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ }, "resolutions": { "@changesets/git": "1.1.2", - "graphql": "16.0.0" + "graphql": "16.0.1" }, "lint-staged": { "{packages,scripts}/**/*.{ts,tsx,js,jsx,cjs,mjs}": [ diff --git a/packages/plugin/package.json b/packages/plugin/package.json index 0751eef66f8..a7ddb471971 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -41,7 +41,7 @@ "@types/graphql-depth-limit": "1.1.3", "@types/lodash.lowercase": "4.3.6", "bob-the-bundler": "1.5.1", - "graphql": "16.0.0", + "graphql": "16.0.1", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/packages/plugin/src/parser.ts b/packages/plugin/src/parser.ts index 3ec5c6bfff9..6f18761bb83 100644 --- a/packages/plugin/src/parser.ts +++ b/packages/plugin/src/parser.ts @@ -1,5 +1,5 @@ import { parseGraphQLSDL } from '@graphql-tools/utils'; -import { ASTNode, GraphQLError, TypeInfo } from 'graphql'; +import { ASTNode, GraphQLError, TypeInfo, Source } from 'graphql'; import { Linter } from 'eslint'; import { convertToESTree } from './estree-parser'; import { GraphQLESLintParseResult, ParserOptions, ParserServices } from './types'; @@ -33,7 +33,7 @@ export function parseForESLint(code: string, options: ParserOptions = {}): Graph }); const { rootTree, comments } = convertToESTree(graphqlAst.document as ASTNode, schema ? new TypeInfo(schema) : null); - const tokens = extractTokens(code); + const tokens = extractTokens(new Source(code, filePath)); return { services: parserServices, diff --git a/packages/plugin/src/utils.ts b/packages/plugin/src/utils.ts index 82a268481a1..182b299f798 100644 --- a/packages/plugin/src/utils.ts +++ b/packages/plugin/src/utils.ts @@ -77,8 +77,8 @@ function getLexer(source: Source): Lexer { throw new Error(`Unsupported GraphQL version! Please make sure to use GraphQL v14 or newer!`); } -export function extractTokens(source: string): AST.Token[] { - const lexer = getLexer(new Source(source)); +export function extractTokens(source: Source): AST.Token[] { + const lexer = getLexer(source); const tokens: AST.Token[] = []; let token = lexer.advance(); diff --git a/yarn.lock b/yarn.lock index e88a93b7432..3d75cd9b800 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3923,10 +3923,10 @@ graphql-ws@^5.0.0: resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-5.3.0.tgz#345f73686b639735f1f4ef0b9ea28e17c7f6a745" integrity sha512-53MbSTOmgx5i6hf3DHVD5PrXix1drDmt2ja8MW7NG+aTpKGzkXVLyNcyNpxme4SK8jVtIV6ZIHkiwirqN0efpw== -graphql@16.0.0, graphql@^14.5.3: - version "16.0.0" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.0.0.tgz#5724f2767aefa543418e83671372117c39408c8f" - integrity sha512-n9NxoRfwnpYBZB/WJ7L166gyrShuZ8qYgVaX8oxVyELcJfAwkvwPt6WlYIl90WRlzqDjaNWvLmNOSnKs5llZWQ== +graphql@16.0.1, graphql@^14.5.3: + version "16.0.1" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.0.1.tgz#93a13cd4e0e38ca8d0832e79614c8578bfd34f10" + integrity sha512-oPvCuu6dlLdiz8gZupJ47o1clgb72r1u8NDBcQYjcV6G/iEdmE11B1bBlkhXRvV0LisP/SXRFP7tT6AgaTjpzg== hard-rejection@^2.1.0: version "2.1.0"