diff options
| author | netop://ウィビ <paul@webb.page> | 2026-04-11 14:19:10 -0700 |
|---|---|---|
| committer | netop://ウィビ <paul@webb.page> | 2026-04-11 14:19:10 -0700 |
| commit | ca16dcf93922d63dd1783dc471b2ac0c61f8d11f (patch) | |
| tree | 4568cfda773657f01030747b2e2b804abc092901 /src/utility/types.ts | |
Diffstat (limited to 'src/utility/types.ts')
| -rwxr-xr-x | src/utility/types.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/utility/types.ts b/src/utility/types.ts new file mode 100755 index 0000000..c96910c --- /dev/null +++ b/src/utility/types.ts @@ -0,0 +1,48 @@ + + + +/// import + +import type { GraphQLArgs, GraphQLSchema } from "npm:graphql@16.6.0"; + +/// util + +import type { RenderPageOptions } from "../graphiql/render.ts"; + +interface MutationParams { + mutation: string; + operationName?: string; + query?: never; + variables?: Record<string, unknown>; +} + +interface QueryParams { + mutation?: never; + operationName?: string; + query: string; + variables?: Record<string, unknown>; +} + + + +/// export + +export interface GQLOptions<Context = any, Req extends GQLRequest = GQLRequest> extends Omit<GraphQLArgs, "source"> { + context?: (val: Req) => Context | Promise<Context>; + /// GraphQL playground + graphiql?: boolean; + /// Custom headers for responses + headers?: HeadersInit; + /// Custom options for GraphQL Playground + playgroundOptions?: Omit<RenderPageOptions, "endpoint">; + schema: GraphQLSchema; +} + +export type GraphQLParams = QueryParams | MutationParams; + +export type GQLRequest = { + headers: Headers; + json: () => Promise<GraphQLParams>; + method: string; + url: string; +}; |
