From d6298a3d567774c5a59d0efd0f8d33f4c43fcb0b Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Mon, 30 Oct 2023 13:53:15 +0100 Subject: [PATCH] fix: refactor code so linter no longer produces warnings (#605) --- examples/typescript-typed-document-node.ts | 4 ++-- src/resolveRequestDocument.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/typescript-typed-document-node.ts b/examples/typescript-typed-document-node.ts index 6ba92aaa2..c165930a7 100644 --- a/examples/typescript-typed-document-node.ts +++ b/examples/typescript-typed-document-node.ts @@ -5,7 +5,7 @@ import { parse } from 'graphql' { const endpoint = `https://graphql-yoga.com/api/graphql` - const query: TypedDocumentNode<{ greetings: string }, never | Record> = parse(gql` + const query: TypedDocumentNode<{ greetings: string }, Record> = parse(gql` query greetings { greetings } @@ -23,7 +23,7 @@ import { parse } from 'graphql' const client = new GraphQLClient(endpoint) - const query: TypedDocumentNode<{ greetings: string }, never | Record> = parse(gql` + const query: TypedDocumentNode<{ greetings: string }, Record> = parse(gql` query greetings { greetings } diff --git a/src/resolveRequestDocument.ts b/src/resolveRequestDocument.ts index 6d73cc3a6..e6369e6ff 100644 --- a/src/resolveRequestDocument.ts +++ b/src/resolveRequestDocument.ts @@ -1,10 +1,11 @@ import type { RequestDocument } from './types.js' /** * Refactored imports from `graphql` to be more specific, this helps import only the required files (100KiB) - * instead of the entire package (>500KiB) where tree-shaking is not supported. + * instead of the entire package (greater than 500KiB) where tree-shaking is not supported. * @see https://github.com/jasonkuhrt/graphql-request/pull/543 */ import type { DocumentNode, OperationDefinitionNode } from 'graphql/language/ast.js' +import { Kind } from 'graphql/language/kinds.js' import { parse } from 'graphql/language/parser.js' import { print } from 'graphql/language/printer.js' @@ -16,7 +17,7 @@ const extractOperationName = (document: DocumentNode): string | undefined => { let operationName = undefined const operationDefinitions = document.definitions.filter( - (definition) => definition.kind === `OperationDefinition`, + (definition) => definition.kind === Kind.OPERATION_DEFINITION, ) as OperationDefinitionNode[] if (operationDefinitions.length === 1) {