UNPKG

@graphql-mesh/transport-common

Version:
47 lines (43 loc) 2.32 kB
import { Logger } from '@graphql-hive/logger'; import { HivePubSub } from '@graphql-hive/pubsub'; import { Logger as Logger$1, MeshFetch, KeyValueCache } from '@graphql-mesh/types'; import { MaybePromise, Executor } from '@graphql-tools/utils'; export { Executor } from '@graphql-tools/utils'; import { GraphQLSchema, GraphQLError, GraphQLScalarType } from 'graphql'; export { executorFromSchema as createDefaultExecutor } from '@graphql-tools/executor'; export { getDocumentString } from '@envelop/core'; export { UpstreamErrorExtensions, defaultPrintFn } from '@graphql-tools/executor-common'; export { abortSignalAny } from '@graphql-hive/signal'; interface Transport<Options extends Record<string, any> = Record<string, any>> { getSubgraphExecutor: TransportGetSubgraphExecutor<Options>; } interface TransportEntry<Options extends Record<string, any> = Record<string, any>> { kind: string; subgraph: string; location?: string; headers?: [string, string][]; options?: Options; } interface TransportContext { log: Logger; /** @deprecated Please migrate to using the {@link log}. */ logger: Logger$1; /** The fetch API to use. */ fetch?: MeshFetch; /** Will be empty when run on serverless. */ cwd?: string; pubsub?: HivePubSub; cache?: KeyValueCache; } interface TransportGetSubgraphExecutorOptions<Options extends Record<string, any> = Record<string, any>> extends TransportContext { subgraphName: string; transportEntry: TransportEntry<Options>; getTransportExecutor(transportEntry: TransportEntry): MaybePromise<Executor>; subgraph: GraphQLSchema; getDisposeReason?: () => GraphQLError | undefined; } type TransportExecutorFactoryGetter = (kind: string) => MaybePromise<TransportGetSubgraphExecutor>; type TransportGetSubgraphExecutor<Options extends Record<string, any> = Record<string, any>> = (opts: TransportGetSubgraphExecutorOptions<Options>) => MaybePromise<Executor>; type DisposableExecutor = Executor & Partial<Disposable | AsyncDisposable>; declare const ObjMapScalar: GraphQLScalarType<any, string>; export { type DisposableExecutor, ObjMapScalar, type Transport, type TransportContext, type TransportEntry, type TransportExecutorFactoryGetter, type TransportGetSubgraphExecutor, type TransportGetSubgraphExecutorOptions };