aboutsummaryrefslogtreecommitdiff
path: root/source/utility/types.ts
diff options
context:
space:
mode:
authornetop://ウィビ <paul@webb.page>2026-04-24 07:43:33 -0700
committernetop://ウィビ <paul@webb.page>2026-04-24 07:43:33 -0700
commit4c6194c4c2b5506f6d482347b0c13033ef17b5c7 (patch)
tree310b315b23487b9a44da94cd21a970f6cc95c831 /source/utility/types.ts
downloadgq-4c6194c4c2b5506f6d482347b0c13033ef17b5c7.tar.gz
gq-4c6194c4c2b5506f6d482347b0c13033ef17b5c7.zip
initial commit
Diffstat (limited to 'source/utility/types.ts')
-rwxr-xr-xsource/utility/types.ts55
1 files changed, 55 insertions, 0 deletions
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<string, unknown>;
+}
+
+interface QueryParams {
+ mutation?: never;
+ operationName?: string;
+ query: string;
+ variables?: Record<string, unknown>;
+}
+
+/*** EXPORT ------------------------------------------- ***/
+
+/**
+ * Configuration accepted by `GraphQLHTTP` and `runHttpQuery`.
+ *
+ * Extends `GraphQLArgs` from `graphql-js` minus `source` (supplied per request).
+ */
+export interface GQLOptions<Context, Req extends GQLRequest = GQLRequest> extends Omit<GraphQLArgs, "source"> {
+ /** Builds the context value passed to resolvers. Runs per request. */
+ context?: (val: Req) => Context | Promise<Context>;
+ /** 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<RenderPageOptions, "endpoint">;
+ /** 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<GraphQLParams>;
+ method: string;
+ url: string;
+};