@chillicream/nitro-server-adapter-plugin
Version:
Server Adapter Plugin for Nitro GraphQL IDE
41 lines (40 loc) • 1.47 kB
text/typescript
import { ServerAdapterPlugin } from "@whatwg-node/server";
interface HttpHeaderDictionary {
readonly [key: string]: string | string[];
}
type SubscriptionProtocol = "auto" | "graphql-transport-ws" | "graphql-ws" | "graphql-sse";
interface Options {
readonly title?: string;
readonly disableTelemetry?: boolean;
readonly gaTrackingId?: string;
readonly useBrowserUrlAsEndpoint: boolean;
readonly includeCookies?: boolean;
readonly useGet?: boolean;
readonly subscriptionProtocol?: SubscriptionProtocol;
readonly sdlEndpoint?: string;
readonly endpoint?: string;
readonly httpHeaders?: HttpHeaderDictionary;
readonly graphQLDocument?: string;
readonly variables?: Record<string, any>;
}
type Config = {
readonly mode: "cdn";
/** Endpoint **url** for the `cdn` hosted version. */
readonly target?: {
baseUrl: string;
version?: string;
} | string;
readonly options?: Options;
} | {
readonly mode: "embedded";
/** Package **id** or **path** for the `embedded` version. */
readonly target?: string;
readonly options?: Options;
};
type NitroConfig = Config & {
/** a path on this plugin is hosted; default is `/graphql` */
readonly path?: string;
};
declare function useNitro<TServerContext>(config?: NitroConfig): ServerAdapterPlugin<TServerContext>;
declare function resolveBasePath(path?: string): string;
export { NitroConfig, useNitro, resolveBasePath };