From 4c6194c4c2b5506f6d482347b0c13033ef17b5c7 Mon Sep 17 00:00:00 2001 From: "netop://ウィビ" Date: Fri, 24 Apr 2026 07:43:33 -0700 Subject: initial commit --- source/utility/types.ts | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 source/utility/types.ts (limited to 'source/utility/types.ts') diff --git a/source/utility/types.ts b/source/utility/types.ts new file mode 100755 index 0000000..0d8b443 --- /dev/null +++ b/source/utility/types.ts @@ -0,0 +1,55 @@ + + + +/*** 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; +}; -- cgit v1.2.3