diff --git a/packages/core/src/runtime/context.ts b/packages/core/src/runtime/context.ts deleted file mode 100644 index 414a93b..0000000 --- a/packages/core/src/runtime/context.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { DefinitionNode } from 'graphql' - -export interface Context { - pushDefinitionNode: (node: DefinitionNode) => void -} diff --git a/packages/core/src/runtime/query-func.ts b/packages/core/src/runtime/query-func.ts index 3402ff8..6a0c1e4 100644 --- a/packages/core/src/runtime/query-func.ts +++ b/packages/core/src/runtime/query-func.ts @@ -10,7 +10,6 @@ import { parseVariables } from './variable' import type { DirectivesInputWithDollar } from './directive' import { parseDirective } from './directive' import { initDirectiveDollar } from './dollar' -import type { Context } from './context' export function gqfn( selection: TypeSelection, @@ -82,11 +81,8 @@ function graphQueryFunction< const directivesNodes = parseDirective(directives(initDirectiveDollar())) const definitions: DefinitionNode[] = [] - const ctx: Context = { - pushDefinitionNode: node => definitions.push(node), - } - ctx.pushDefinitionNode({ + definitions.push({ kind: Kind.OPERATION_DEFINITION, directives: directivesNodes, operation: { @@ -101,7 +97,7 @@ function graphQueryFunction< value: operationName, } : undefined, - selectionSet: parseTypeSelection(selection, ctx), + selectionSet: parseTypeSelection(selection), }) return { diff --git a/packages/core/src/runtime/select.ts b/packages/core/src/runtime/select.ts index 2285b3a..eba6636 100644 --- a/packages/core/src/runtime/select.ts +++ b/packages/core/src/runtime/select.ts @@ -4,7 +4,6 @@ import type { DollarContext, DollarPayload, SelectionDollar } from './dollar' import { initSelectionDollar } from './dollar' import { parseArgs } from './arg' import { parseDirective } from './directive' -import type { Context } from './context' export type TypeSelection = Array< | SelectionField @@ -30,7 +29,6 @@ export function parseTypeSelection< Vars extends DollarPayload, >( selectionSet: TypeSelection, - ctx: Context, ): SelectionSetNode { const selects: SelectionObject = {} selectionSet.forEach((item) => { @@ -49,7 +47,7 @@ export function parseTypeSelection< const selections: Array = Object .entries(selects) - .map(([key, select]) => parseSelectionSet(key, select, ctx)) + .map(([key, select]) => parseSelectionSet(key, select)) // Empty selection set is not allowed if (selections.length === 0) { @@ -77,10 +75,9 @@ export function parseSelectionSet< >( key: string, selection: SelectionSet, - ctx: Context, ): SelectionNode { const { args, directives, content } = parseSelectionFunc(selection) - const childNode = parseSelectionContext(content, ctx) + const childNode = parseSelectionContext(content) const argNodes = parseArgs(args) const directiveNodes = parseDirective(directives) @@ -161,11 +158,10 @@ export function parseSelectionContext< Vars extends DollarPayload, >( selectionSet: SelectionContext, - context: Context, ): SelectionSetNode | undefined { if (selectionSet === true) { return undefined } - return parseTypeSelection(selectionSet, context) + return parseTypeSelection(selectionSet) }