/*** IMPORT ------------------------------------------- ***/ import type { GraphQLArgs, GraphQLSchema } from "graphql"; /*** UTILITY ------------------------------------------ ***/ import type { RenderPageOptions } from "../graphiql/render.ts"; interface MutationParams { mutation: string; operationName?: string; query?: never; variables?: Record; } interface QueryParams { mutation?: never; operationName?: string; query: string; variables?: Record; } /*** EXPORT ------------------------------------------- ***/ /** * Configuration accepted by `GraphQLHTTP` and `runHttpQuery`. * * Extends `GraphQLArgs` from `graphql-js` minus `source` (supplied per request). */ export interface GQLOptions extends Omit { /** Builds the context value passed to resolvers. Runs per request. */ context?: (val: Req) => Context | Promise; /** Serve the GraphQL Playground on `GET` + `Accept: text/html`. */ graphiql?: boolean; /** Extra headers merged into every response. */ headers?: HeadersInit; /** Passthrough options for the Playground renderer (minus `endpoint`). */ playgroundOptions?: Omit; /** The executable schema to query against. */ schema: GraphQLSchema; } /** A single GraphQL operation — either a `query` or a `mutation`, never both. */ export type GraphQLParams = QueryParams | MutationParams; /** Minimal Fetch-shaped request accepted by the HTTP handler. */ export type GQLRequest = { headers: Headers; json: () => Promise; method: string; url: string; };