Skip to content

Commit

Permalink
fix: refactor code so linter no longer produces warnings (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkoops committed Oct 30, 2023
1 parent 0d72c58 commit d6298a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/typescript-typed-document-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { parse } from 'graphql'
{
const endpoint = `https://graphql-yoga.com/api/graphql`

const query: TypedDocumentNode<{ greetings: string }, never | Record<any, never>> = parse(gql`
const query: TypedDocumentNode<{ greetings: string }, Record<any, never>> = parse(gql`
query greetings {
greetings
}
Expand All @@ -23,7 +23,7 @@ import { parse } from 'graphql'

const client = new GraphQLClient(endpoint)

const query: TypedDocumentNode<{ greetings: string }, never | Record<any, never>> = parse(gql`
const query: TypedDocumentNode<{ greetings: string }, Record<any, never>> = parse(gql`
query greetings {
greetings
}
Expand Down
5 changes: 3 additions & 2 deletions src/resolveRequestDocument.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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) {
Expand Down

0 comments on commit d6298a3

Please sign in to comment.