@graphql-mesh/transport-common
Version:
42 lines (38 loc) • 2.1 kB
TypeScript
import { HivePubSub } from '@graphql-hive/pubsub';
import { MeshFetch, Logger, 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 {
fetch?: MeshFetch;
pubsub?: HivePubSub;
logger?: Logger;
cwd?: string;
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 };