grafserv 0.0.1-0.2 → 0.0.1-0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +220 -0
  2. package/README.md +248 -3
  3. package/dist/accept.d.ts +8 -0
  4. package/dist/accept.d.ts.map +1 -0
  5. package/dist/accept.js +419 -0
  6. package/dist/accept.js.map +1 -0
  7. package/dist/core/base.d.ts +38 -0
  8. package/dist/core/base.d.ts.map +1 -0
  9. package/dist/core/base.js +440 -0
  10. package/dist/core/base.js.map +1 -0
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +3 -3
  14. package/dist/index.js.map +1 -1
  15. package/dist/interfaces.d.ts +176 -23
  16. package/dist/interfaces.d.ts.map +1 -1
  17. package/dist/interfaces.js +2 -0
  18. package/dist/interfaces.js.map +1 -1
  19. package/dist/mapIterator.d.ts +2 -0
  20. package/dist/mapIterator.d.ts.map +1 -0
  21. package/dist/mapIterator.js +65 -0
  22. package/dist/mapIterator.js.map +1 -0
  23. package/dist/middleware/graphiql.d.ts +3 -3
  24. package/dist/middleware/graphiql.d.ts.map +1 -1
  25. package/dist/middleware/graphiql.js +14 -4
  26. package/dist/middleware/graphiql.js.map +1 -1
  27. package/dist/middleware/graphql.d.ts +8 -3
  28. package/dist/middleware/graphql.d.ts.map +1 -1
  29. package/dist/middleware/graphql.js +325 -23
  30. package/dist/middleware/graphql.js.map +1 -1
  31. package/dist/options.d.ts +23 -0
  32. package/dist/options.d.ts.map +1 -0
  33. package/dist/options.js +114 -0
  34. package/dist/options.js.map +1 -0
  35. package/dist/servers/express/v4/index.d.ts +24 -0
  36. package/dist/servers/express/v4/index.d.ts.map +1 -0
  37. package/dist/servers/express/v4/index.js +62 -0
  38. package/dist/servers/express/v4/index.js.map +1 -0
  39. package/dist/servers/fastify/v4/index.d.ts +21 -0
  40. package/dist/servers/fastify/v4/index.d.ts.map +1 -0
  41. package/dist/servers/fastify/v4/index.js +198 -0
  42. package/dist/servers/fastify/v4/index.js.map +1 -0
  43. package/dist/servers/koa/v2/index.d.ts +25 -0
  44. package/dist/servers/koa/v2/index.d.ts.map +1 -0
  45. package/dist/servers/koa/v2/index.js +137 -0
  46. package/dist/servers/koa/v2/index.js.map +1 -0
  47. package/dist/servers/node/index.d.ts +32 -0
  48. package/dist/servers/node/index.d.ts.map +1 -0
  49. package/dist/servers/node/index.js +269 -0
  50. package/dist/servers/node/index.js.map +1 -0
  51. package/dist/utils.d.ts +19 -0
  52. package/dist/utils.d.ts.map +1 -0
  53. package/dist/utils.js +145 -0
  54. package/dist/utils.js.map +1 -0
  55. package/package.json +42 -8
  56. package/dist/middleware/index.d.ts +0 -12
  57. package/dist/middleware/index.d.ts.map +0 -1
  58. package/dist/middleware/index.js +0 -431
  59. package/dist/middleware/index.js.map +0 -1
  60. package/dist/middleware/interfaces.d.ts +0 -40
  61. package/dist/middleware/interfaces.d.ts.map +0 -1
  62. package/dist/middleware/interfaces.js +0 -3
  63. package/dist/middleware/interfaces.js.map +0 -1
@@ -1,15 +1,14 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import "graphile-config";
4
- import type { GraphQLSchema } from "graphql";
5
- import type { IncomingMessage } from "node:http";
6
- import type { Socket } from "node:net";
7
- export declare type ContextCallback = (graphqlRequestContext: GraphileConfig.GraphQLRequestContext) => object;
8
- export interface ServerParams {
9
- schema: GraphQLSchema;
10
- resolvedPreset: GraphileConfig.ResolvedPreset;
11
- }
12
- export interface ServerOptions {
3
+ import type { PromiseOrDirect } from "grafast";
4
+ import type { AsyncExecutionResult, ExecutionResult, GraphQLError, GraphQLSchema } from "graphql";
5
+ import type { OptionsFromConfig } from "./options";
6
+ export type ContextCallback = (requestContext: Grafast.RequestContext) => Grafast.Context;
7
+ export interface GrafservConfig {
8
+ schema: GraphQLSchema | PromiseLike<GraphQLSchema>;
9
+ preset?: GraphileConfig.Preset;
10
+ }
11
+ export interface GrafservOptions {
13
12
  /** Port number to listen on */
14
13
  port?: number;
15
14
  /** Host to listen on */
@@ -18,6 +17,8 @@ export interface ServerOptions {
18
17
  graphqlPath?: string;
19
18
  /** The path at which the GraphQL event stream would be made available; usually /graphql/stream */
20
19
  eventStreamRoute?: string;
20
+ /** If true, allow GraphQL over GET requests. This has security ramifications, exercise caution. */
21
+ graphqlOverGET?: boolean;
21
22
  graphiql?: boolean;
22
23
  /** If true, then we will render GraphiQL on GET requests to the /graphql endpoint */
23
24
  graphiqlOnGraphQLGET?: boolean;
@@ -25,25 +26,177 @@ export interface ServerOptions {
25
26
  graphiqlPath?: string;
26
27
  /** Set true to enable watch mode */
27
28
  watch?: boolean;
28
- /** The length, in bytes, for the largest request body that the server will accept */
29
+ /** The length, in bytes, for the largest request body that grafserv will accept */
29
30
  maxRequestLength?: number;
31
+ /** How long (in milliseconds) should we wait for a schema promise to resolve before sending a failure to the client? */
32
+ schemaWaitTime?: number;
33
+ /**
34
+ * Use grafast 'string' optimization - response will be partially stringified
35
+ * already, use `stringifyPayload` before sending to the user
36
+ *
37
+ * @remarks
38
+ *
39
+ * This is a `grafserv` option rather than a `grafast` option because the
40
+ * server is responsible for stringifying the body before sending it to the
41
+ * user, via `stringifyPayload`. If we were to make this a `grafast` option
42
+ * then everything using grafast would be affected by it, and code expecting
43
+ * objects would break.
44
+ */
45
+ outputDataAsString?: boolean;
46
+ /**
47
+ * Temporary hack to allow easy testing with graphql-http.com
48
+ */
49
+ dangerouslyAllowAllCORSRequests?: boolean;
50
+ /**
51
+ * Should we enable a websockets transport if available?
52
+ */
53
+ websockets?: boolean;
54
+ /**
55
+ * If you would like to customize the way in which errors are masked, you may
56
+ * pass your own error masking function here. You can also import
57
+ * `defaultMaskError` from `grafserv`.
58
+ */
59
+ maskError?: (error: GraphQLError) => GraphQLError;
30
60
  }
31
61
  declare global {
32
- namespace GraphileConfig {
33
- /**
34
- * Details about the incoming GraphQL request - e.g. if it was sent over an
35
- * HTTP request, the request itself so headers can be interrogated.
36
- *
37
- * It's anticipated this will be expanded via declaration merging, e.g. if
38
- * your server is Koa then a `koaCtx` might be added.
39
- */
40
- interface GraphQLRequestContext {
41
- httpRequest?: IncomingMessage;
42
- socket?: Socket;
62
+ namespace Grafast {
63
+ interface RequestContext {
64
+ http?: NormalizedRequestDigest;
43
65
  }
66
+ }
67
+ namespace GraphileConfig {
44
68
  interface Preset {
45
- server?: ServerOptions;
69
+ /**
70
+ * Configuration options for Grafserv
71
+ */
72
+ grafserv?: GrafservOptions;
46
73
  }
47
74
  }
48
75
  }
76
+ export interface GrafservBodyBuffer {
77
+ type: "buffer";
78
+ buffer: Buffer;
79
+ }
80
+ export interface GrafservBodyText {
81
+ type: "text";
82
+ text: string;
83
+ }
84
+ export interface GrafservBodyJSON {
85
+ type: "json";
86
+ json: JSONValue;
87
+ }
88
+ export type GrafservBody = GrafservBodyBuffer | GrafservBodyText | GrafservBodyJSON;
89
+ export declare const $$normalizedHeaders: unique symbol;
90
+ export interface RequestDigest {
91
+ method: "HEAD" | "GET" | "POST" | string;
92
+ httpVersionMajor: number;
93
+ httpVersionMinor: number;
94
+ isSecure: boolean;
95
+ path: string;
96
+ headers: Record<string, string>;
97
+ getQueryParams: () => PromiseOrDirect<Record<string, string | string[]>>;
98
+ getBody(): PromiseOrDirect<GrafservBody>;
99
+ requestContext: Partial<Grafast.RequestContext>;
100
+ preferJSON?: boolean;
101
+ [$$normalizedHeaders]?: any;
102
+ }
103
+ export interface NormalizedRequestDigest extends RequestDigest {
104
+ method: "GET" | "POST" | string;
105
+ preferJSON: boolean;
106
+ /**
107
+ * As 'headers', but with the keys lowercased
108
+ * @internal
109
+ */
110
+ [$$normalizedHeaders]: Record<string, string>;
111
+ getHeader(name: string): string | undefined;
112
+ /** @deprecated use getHeader unless the original case is essential. */
113
+ headers: Record<string, string>;
114
+ }
115
+ interface IHandlerResult {
116
+ type: string;
117
+ request: NormalizedRequestDigest;
118
+ dynamicOptions: OptionsFromConfig;
119
+ statusCode?: number;
120
+ }
121
+ export interface HTMLHandlerResult extends IHandlerResult {
122
+ type: "html";
123
+ payload: Buffer;
124
+ }
125
+ export interface TextHandlerResult extends IHandlerResult {
126
+ type: "text";
127
+ payload: Buffer;
128
+ }
129
+ export interface GraphQLHandlerResult extends IHandlerResult {
130
+ type: "graphql";
131
+ contentType: string;
132
+ payload: ExecutionResult;
133
+ outputDataAsString?: boolean;
134
+ }
135
+ /** @see {@link https://github.com/glasser/graphql-over-http/blob/dac9638459bb17dd3ade889334fc2fadee9d11e5/rfcs/IncrementalDelivery.md} */
136
+ export interface GraphQLIncrementalHandlerResult extends IHandlerResult {
137
+ type: "graphqlIncremental";
138
+ iterator: AsyncGenerator<AsyncExecutionResult, void, undefined>;
139
+ outputDataAsString?: boolean;
140
+ }
141
+ export interface NoContentHandlerResult extends IHandlerResult {
142
+ type: "noContent";
143
+ }
144
+ export interface EventStreamEvent {
145
+ /** The name of the event. Use simple names. Don't put newlines in it! */
146
+ event: string;
147
+ /** The data for this event. We'll automatically split this on newlines for you */
148
+ data?: string;
149
+ id?: string;
150
+ /** integer number of milliseconds indicating how long to wait before reconnecting if connection is lost */
151
+ retry?: number;
152
+ }
153
+ export interface EventStreamHeandlerResult extends IHandlerResult {
154
+ type: "event-stream";
155
+ payload: AsyncIterable<EventStreamEvent>;
156
+ }
157
+ export type HandlerResult = HTMLHandlerResult | GraphQLHandlerResult | GraphQLIncrementalHandlerResult | TextHandlerResult | EventStreamHeandlerResult | NoContentHandlerResult;
158
+ export type SchemaChangeEvent = {
159
+ event: "change";
160
+ data: "schema";
161
+ };
162
+ export type JSONValue = null | boolean | number | string | JSONValue[] | JSONObject;
163
+ export interface JSONObject {
164
+ [key: string]: JSONValue;
165
+ }
166
+ export interface ErrorResult {
167
+ type: "error";
168
+ statusCode: number;
169
+ headers: Record<string, string>;
170
+ error: Error & {
171
+ statusCode?: number;
172
+ safeMessage?: boolean;
173
+ };
174
+ }
175
+ export interface BufferResult {
176
+ type: "buffer";
177
+ statusCode: number;
178
+ headers: Record<string, string>;
179
+ buffer: Buffer;
180
+ }
181
+ export interface JSONResult {
182
+ type: "json";
183
+ statusCode: number;
184
+ headers: Record<string, string>;
185
+ json: JSONValue;
186
+ }
187
+ export interface BufferStreamResult {
188
+ type: "bufferStream";
189
+ statusCode: number;
190
+ headers: Record<string, string>;
191
+ /** If true, setNoDelay, etc */
192
+ lowLatency: boolean;
193
+ bufferIterator: AsyncGenerator<Buffer, void, undefined>;
194
+ }
195
+ export interface NoContentResult {
196
+ type: "noContent";
197
+ statusCode: 204;
198
+ headers: Record<string, string>;
199
+ }
200
+ export type Result = ErrorResult | BufferResult | JSONResult | BufferStreamResult | NoContentResult;
201
+ export {};
49
202
  //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;AAAA,OAAO,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,oBAAY,eAAe,GAAG,CAC5B,qBAAqB,EAAE,cAAc,CAAC,qBAAqB,KACxD,MAAM,CAAC;AAEZ,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,aAAa,CAAC;IACtB,cAAc,EAAE,cAAc,CAAC,cAAc,CAAC;CAC/C;AAED,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kGAAkG;IAClG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,q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normalizedHeaders = void 0;
3
4
  require("graphile-config");
5
+ exports.$$normalizedHeaders = Symbol("normalizedHeaders");
4
6
  //# sourceMappingURL=interfaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;AAAA,2BAAyB"}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;AAAA,2BAAyB;AAuHZ,QAAA,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function mapIterator<T, U>(iterable: AsyncIterable<T>, cb: (payload: T) => U, end?: () => U, initial?: () => U): AsyncGenerator<U>;
2
+ //# sourceMappingURL=mapIterator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapIterator.d.ts","sourceRoot":"","sources":["../src/mapIterator.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC9B,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,EACrB,GAAG,CAAC,EAAE,MAAM,CAAC,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,GAChB,cAAc,CAAC,CAAC,CAAC,CA0DnB"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapIterator = void 0;
4
+ function mapIterator(iterable, cb, end, initial) {
5
+ const iterator = iterable[Symbol.asyncIterator]();
6
+ /**
7
+ * -1 - starting
8
+ * 0 - normal
9
+ * 1 - ending
10
+ * 2 - ended
11
+ */
12
+ let status = -1;
13
+ const mappedIterator = {
14
+ next() {
15
+ if (status === -1) {
16
+ status = 0;
17
+ if (typeof initial === "function") {
18
+ return Promise.resolve({ value: initial(), done: false });
19
+ }
20
+ }
21
+ if (status === 1) {
22
+ status = 2;
23
+ }
24
+ // NO 'else' here!
25
+ if (status === 2) {
26
+ return Promise.resolve({ value: undefined, done: true });
27
+ }
28
+ const next = iterator.next();
29
+ return next.then((v) => {
30
+ if (v.done) {
31
+ if (v.value !== undefined) {
32
+ throw new Error("Invalid assumption; tell Benjie he did bad.");
33
+ }
34
+ if (end) {
35
+ status = 1;
36
+ return { value: end(), done: false };
37
+ }
38
+ else {
39
+ status = 2;
40
+ return { value: undefined, done: true };
41
+ }
42
+ }
43
+ else {
44
+ return { value: cb(v.value), done: false };
45
+ }
46
+ });
47
+ },
48
+ return(value) {
49
+ status = 2;
50
+ iterator.return?.(value);
51
+ return Promise.resolve({ value: undefined, done: true });
52
+ },
53
+ throw(error) {
54
+ status = 2;
55
+ iterator.throw?.(error);
56
+ return Promise.reject(error);
57
+ },
58
+ [Symbol.asyncIterator]() {
59
+ return this;
60
+ },
61
+ };
62
+ return mappedIterator;
63
+ }
64
+ exports.mapIterator = mapIterator;
65
+ //# sourceMappingURL=mapIterator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapIterator.js","sourceRoot":"","sources":["../src/mapIterator.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CACzB,QAA0B,EAC1B,EAAqB,EACrB,GAAa,EACb,OAAiB;IAEjB,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;IAClD;;;;;OAKG;IACH,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC;IAChB,MAAM,cAAc,GAAsB;QACxC,IAAI;YACF,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE;gBACjB,MAAM,GAAG,CAAC,CAAC;gBACX,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;oBACjC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC3D;aACF;YACD,IAAI,MAAM,KAAK,CAAC,EAAE;gBAChB,MAA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AC,CAAC;QAC/B,CAAC;QACD,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;IAEF,OAAO,cAAc,CAAC;AACxB,CAAC;AA/DD,kCA+DC"}
@@ -1,4 +1,4 @@
1
- import type { ServerParams } from "../interfaces.js";
2
- import type { HandlerResult } from "./interfaces.js";
3
- export declare function makeGraphiQLHandler(_params: ServerParams): () => Promise<HandlerResult>;
1
+ import type { HandlerResult, NormalizedRequestDigest } from "../interfaces.js";
2
+ import type { OptionsFromConfig } from "../options.js";
3
+ export declare function makeGraphiQLHandler(_resolvedPreset: GraphileConfig.ResolvedPreset, dynamicOptions: OptionsFromConfig): (request: NormalizedRequestDigest) => Promise<HandlerResult>;
4
4
  //# sourceMappingURL=graphiql.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"graphiql.d.ts","sourceRoot":"","sources":["../../src/middleware/graphiql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMrD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,YAAY,SACtC,QAAQ,aAAa,CAAC,CAWxC"}
1
+ {"version":3,"file":"graphiql.d.ts","sourceRoot":"","sources":["../../src/middleware/graphiql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAOvD,wBAAgB,mBAAmB,CACjC,eAAe,EAAE,cAAc,CAAC,cAAc,EAC9C,cAAc,EAAE,iBAAiB,aAEV,uBAAuB,KAAG,QAAQ,aAAa,CAAC,CAsBxE"}
@@ -4,16 +4,26 @@ exports.makeGraphiQLHandler = void 0;
4
4
  const ruruServer = import("ruru/server");
5
5
  let ruruHTML = undefined;
6
6
  // TODO: use a specific version of mermaid
7
- function makeGraphiQLHandler(_params) {
8
- return async () => {
7
+ function makeGraphiQLHandler(_resolvedPreset, dynamicOptions) {
8
+ return async (request) => {
9
9
  if (!ruruHTML) {
10
10
  ruruHTML = (await ruruServer).ruruHTML;
11
11
  }
12
- const config = {};
12
+ const config = {
13
+ endpoint: dynamicOptions.graphqlPath,
14
+ // TODO: websocket endpoint
15
+ debugTools: dynamicOptions.explain === true
16
+ ? ["explain", "plan"]
17
+ : dynamicOptions.explain === false
18
+ ? []
19
+ : dynamicOptions.explain,
20
+ };
13
21
  return {
14
22
  statusCode: 200,
23
+ request,
24
+ dynamicOptions,
15
25
  type: "html",
16
- payload: ruruHTML(config),
26
+ payload: Buffer.from(ruruHTML(config), "utf8"),
17
27
  };
18
28
  };
19
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"graphiql.js","sourceRoot":"","sources":["../../src/middleware/graphiql.ts"],"names":[],"mappings":";;;AAGA,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AACzC,IAAI,QAAQ,GAAuD,SAAS,CAAC;AAE7E,0CAA0C;AAC1C,SAAgB,mBAAmB,CAAC,OAAqB;IACvD,OAAO,KAAK,IAA4B,EAAE;QACxC,IAAI,CAAC,QAAQ,EAAE;YACb,QAAQ,GAAG,CAAC,MAAM,UAAU,CAAC,CAAC,QAAQ,CAAC;SACxC;QACD,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,OAAO;YACL,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC;SAC1B,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAZD,kDAYC"}
1
+ {"version":3,"file":"graphiql.js","sourceRoot":"","sources":["../../src/middleware/graphiql.ts"],"names":[],"mappings":";;;AAGA,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzC,IAAI,QAAQ,GAAiC,SAAS,CAAC;AAEvD,0CAA0C;AAC1C,SAAgB,mBAAmB,CACjC,eAA8C,EAC9C,cAAiC;IAEjC,OAAO,KAAK,EAAE,OAAgC,EAA0B,EAAE;QACxE,IAAI,CAAC,QAAQ,EAAE;YACb,QAAQ,GAAG,CAAC,MAAM,UAAU,CAAC,CAAC,QAAQ,CAAC;SACxC;QACD,MAAM,MAAM,GAAoC;YAC9C,QAAQ,EAAE,cAAc,CAAC,WAAW;YACpC,2BAA2B;YAC3B,UAAU,EACR,cAAc,CAAC,OAAO,KAAK,IAAI;gBAC7B,CAAC,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC;gBACrB,CAAC,CAAC,cAAc,CAAC,OAAO,KAAK,KAAK;oBAClC,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAE,cAAc,CAAC,OAAiB;SACxC,CAAC;QACF,OAAO;YACL,UAAU,EAAE,GAAG;YACf,OAAO;YACP,cAAc;YACd,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;SAC/C,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AA1BD,kDA0BC"}
@@ -1,4 +1,9 @@
1
- import type { ServerParams } from "../interfaces.js";
2
- import type { HandlerResult } from "./interfaces.js";
3
- export declare const makeGraphQLHandler: (params: ServerParams) => (resolvedPreset: GraphileConfig.ResolvedPreset, ctx: GraphileConfig.GraphQLRequestContext, body: unknown) => Promise<HandlerResult>;
1
+ import type { PromiseOrDirect } from "grafast";
2
+ import type { GraphQLSchema } from "graphql";
3
+ import type { HandlerResult, NormalizedRequestDigest } from "../interfaces.js";
4
+ import type { OptionsFromConfig } from "../options.js";
5
+ export declare const APPLICATION_JSON = "application/json;charset=utf-8";
6
+ export declare const APPLICATION_GRAPHQL_RESPONSE_JSON = "application/graphql-response+json;charset=utf-8";
7
+ export declare const TEXT_HTML = "text/html;charset=utf-8";
8
+ export declare const makeGraphQLHandler: (resolvedPreset: GraphileConfig.ResolvedPreset, dynamicOptions: OptionsFromConfig, schemaOrPromise: PromiseOrDirect<GraphQLSchema> | null) => (request: NormalizedRequestDigest, graphiqlHandler?: ((request: NormalizedRequestDigest) => Promise<HandlerResult | null>) | undefined) => Promise<HandlerResult | null>;
4
9
  //# sourceMappingURL=graphql.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/middleware/graphql.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAqErD,eAAO,MAAM,kBAAkB,WAAY,YAAY,sBAMnC,eAAe,cAAc,OACxC,eAAe,qBAAqB,QACnC,OAAO,KACZ,QAAQ,aAAa,CA4DzB,CAAC"}
1
+ {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/middleware/graphql.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAQ/C,OAAO,KAAK,EAA+B,aAAa,EAAE,MAAM,SAAS,CAAC;AAW1E,OAAO,KAAK,EAEV,aAAa,EAEb,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA0PvD,eAAO,MAAM,gBAAgB,mCAAmC,CAAC;AACjE,eAAO,MAAM,iCAAiC,oDACK,CAAC;AACpD,eAAO,MAAM,SAAS,4BAA4B,CAAC;AAiBnD,eAAO,MAAM,kBAAkB,mBACb,eAAe,cAAc,kBAC7B,iBAAiB,mBAChB,gBAAgB,aAAa,CAAC,GAAG,IAAI,eAmD3C,uBAAuB,+BAErB,uBAAuB,KAC7B,QAAQ,aAAa,GAAG,IAAI,CAAC,kBACjC,QAAQ,aAAa,GAAG,IAAI,CA+LhC,CAAC"}