import { execute , ExecutionResult , GraphQLError , subscribe } from "graphql" ; import { CompileQuery } from "./types" ; export function isAsyncIterator < T = unknown > ( val ) { return typeof Object ( val ) [ Symbol . asyncIterator ] === "function" ; } returns export function makeCompileQuery ( ) { return function compileQuery ( schema ) { return { execute ( args ) { return execute ( { ... args , schema } ) ; } , subscribe ( args ) { return subscribe ( { ... args , schema } ) ; } , } ; } ; } export function isExecutionResult ( val ) { return ( typeof val === "object" && val !== null && ( Array . isArray ( ( val as ExecutionResult ) . errors ) || ( typeof ( val as ExecutionResult ) . data === "object" && ! Array . isArray ( ( val as ExecutionResult ) . data ) ) ) ) ; } param operation param operationName export function validateOperationName ( operation , operationName ) { if ( operation ) return [ ] ; if ( ! operationName ) { return [ new GraphQLError ( "Must provide operation name if query contains multiple operations." ) , ] ; } return [ new GraphQLError ( `Unknown operation named "${ operationName }".` ) ] ; }