@graphql-mesh/transport-common
Version:
54 lines (49 loc) • 2.25 kB
TypeScript
import { GraphQLSchema, GraphQLScalarType, DocumentNode } from 'graphql';
import { MeshFetch, MeshPubSub, Logger, KeyValueCache } from '@graphql-mesh/types';
import { MaybePromise, Executor } from '@graphql-tools/utils';
export { Executor } from '@graphql-tools/utils';
export { createDefaultExecutor } from '@graphql-tools/delegate';
export { getDocumentString } from '@envelop/core';
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?: MeshPubSub;
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;
}
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>;
interface UpstreamErrorExtensions {
subgraph?: string;
request: {
url?: string;
method?: string;
body?: unknown;
};
response: {
status?: number;
statusText?: string;
headers?: Record<string, string>;
body?: unknown;
};
}
declare const ObjMapScalar: GraphQLScalarType<any, string>;
declare const defaultPrintFn: (document: DocumentNode) => string;
export { type DisposableExecutor, ObjMapScalar, type Transport, type TransportContext, type TransportEntry, type TransportExecutorFactoryGetter, type TransportGetSubgraphExecutor, type TransportGetSubgraphExecutorOptions, type UpstreamErrorExtensions, defaultPrintFn };