@nxgt/graphql-codegen-msw 0.0.0-stage → 0.1.0

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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +293 -2
  3. package/THIRD-PARTY-NOTICES.md +71 -0
  4. package/dist/config.d.ts +66 -0
  5. package/dist/config.d.ts.map +1 -0
  6. package/dist/imports.d.ts +17 -0
  7. package/dist/imports.d.ts.map +1 -0
  8. package/dist/index.d.ts +13 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +365 -0
  11. package/dist/index.js.map +15 -0
  12. package/dist/input-types.d.ts +11 -0
  13. package/dist/input-types.d.ts.map +1 -0
  14. package/dist/naming.d.ts +23 -0
  15. package/dist/naming.d.ts.map +1 -0
  16. package/dist/operations.d.ts +17 -0
  17. package/dist/operations.d.ts.map +1 -0
  18. package/dist/options.d.ts +31 -0
  19. package/dist/options.d.ts.map +1 -0
  20. package/dist/runtime/coercion/cross-inspect.d.ts +19 -0
  21. package/dist/runtime/coercion/cross-inspect.d.ts.map +1 -0
  22. package/dist/runtime/coercion/document.d.ts +51 -0
  23. package/dist/runtime/coercion/document.d.ts.map +1 -0
  24. package/dist/runtime/coercion/index.d.ts +30 -0
  25. package/dist/runtime/coercion/index.d.ts.map +1 -0
  26. package/dist/runtime/coercion/inspect.d.ts +9 -0
  27. package/dist/runtime/coercion/inspect.d.ts.map +1 -0
  28. package/dist/runtime/coercion/issues.d.ts +19 -0
  29. package/dist/runtime/coercion/issues.d.ts.map +1 -0
  30. package/dist/runtime/coercion/messages.d.ts +37 -0
  31. package/dist/runtime/coercion/messages.d.ts.map +1 -0
  32. package/dist/runtime/coercion/suggestions.d.ts +15 -0
  33. package/dist/runtime/coercion/suggestions.d.ts.map +1 -0
  34. package/dist/runtime/coercion/validate.d.ts +39 -0
  35. package/dist/runtime/coercion/validate.d.ts.map +1 -0
  36. package/dist/runtime/index.d.ts +6 -0
  37. package/dist/runtime/index.d.ts.map +1 -0
  38. package/dist/runtime/index.js +595 -0
  39. package/dist/runtime/index.js.map +21 -0
  40. package/dist/runtime/mock-operation.d.ts +65 -0
  41. package/dist/runtime/mock-operation.d.ts.map +1 -0
  42. package/dist/runtime/refusals.d.ts +36 -0
  43. package/dist/runtime/refusals.d.ts.map +1 -0
  44. package/dist/runtime/response.d.ts +34 -0
  45. package/dist/runtime/response.d.ts.map +1 -0
  46. package/docs/README.md +14 -0
  47. package/docs/guide/handlers.md +654 -0
  48. package/docs/roadmap.md +40 -0
  49. package/docs/troubleshooting.md +304 -0
  50. package/package.json +80 -5
@@ -0,0 +1,30 @@
1
+ import type { GraphQLFormattedError } from 'graphql';
2
+ import type { z } from 'zod';
3
+ import { type InputTypes } from './document.js';
4
+ export type { InputType, InputTypes } from './document.js';
5
+ export { STALE_FILE } from './validate.js';
6
+ /** The status graphql-yoga answers a variable coercion error with. */
7
+ export declare const COERCION_STATUS = 400;
8
+ /**
9
+ * What the generated file says of an operation's variables. Without them
10
+ * (a hand-written handler), no variable is walked.
11
+ */
12
+ export interface DeclaredVariables {
13
+ /** Each variable's type, with its default: `{ first: "Int = 10" }`. */
14
+ readonly variableTypes?: Readonly<Record<string, string>> | undefined;
15
+ readonly inputTypes?: InputTypes | undefined;
16
+ }
17
+ /** The request whose variables the operation's schema refused. */
18
+ export interface CoercedRequest {
19
+ readonly query: string;
20
+ readonly operationName: string;
21
+ readonly variables: unknown;
22
+ }
23
+ /**
24
+ * The errors graphql-yoga answers the request's variables with, in its
25
+ * order (variables in declaration order, an object's fields in the
26
+ * schema's, unknown fields last), each located at the variable's
27
+ * definition in the query sent; empty when graphql takes every variable.
28
+ */
29
+ export declare function coercionErrors(issues: readonly z.core.$ZodIssue[], request: CoercedRequest, operation: DeclaredVariables): GraphQLFormattedError[];
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/coercion/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,qBAAqB,EAA0B,MAAM,SAAS,CAAC;AAE7E,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAGN,KAAK,UAAU,EAEf,MAAM,YAAY,CAAC;AAKpB,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,sEAAsE;AACtE,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IACjC,uEAAuE;IACvE,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CAC7C;AAED,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,EACnC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,iBAAiB,GAC1B,qBAAqB,EAAE,CAezB"}
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * Ported from graphql-js 17.0.2 (src/jsutils/inspect.ts),
3
+ * https://github.com/graphql/graphql-js
4
+ * Copyright (c) GraphQL Contributors
5
+ * @license MIT
6
+ */
7
+ /** A value as graphql-js prints it in an error message. */
8
+ export declare function inspect(value: unknown): string;
9
+ //# sourceMappingURL=inspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../../src/runtime/coercion/inspect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,2DAA2D;AAC3D,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE9C"}
@@ -0,0 +1,19 @@
1
+ import type { z } from 'zod';
2
+ /** A Zod issue and its whole path inside the variables. */
3
+ export interface PlacedIssue {
4
+ readonly path: readonly (string | number)[];
5
+ readonly issue: z.core.$ZodIssue;
6
+ }
7
+ /**
8
+ * Every issue with its whole path, a union's own issue followed by each of
9
+ * its branches' (a list that also takes a single value is a union): a
10
+ * custom scalar's refusal may sit in either branch.
11
+ */
12
+ export declare function placed(issues: readonly z.core.$ZodIssue[], prefix?: readonly (string | number)[]): PlacedIssue[];
13
+ /**
14
+ * The first issue at `path` or below it: what a custom scalar's schema
15
+ * refused there. A scalar built with `zodScalar` refuses with its schema's
16
+ * first issue, which the client's schema, the same one, reports first too.
17
+ */
18
+ export declare function issueAt(issues: readonly PlacedIssue[], path: readonly (string | number)[]): z.core.$ZodIssue | undefined;
19
+ //# sourceMappingURL=issues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issues.d.ts","sourceRoot":"","sources":["../../../src/runtime/coercion/issues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,2DAA2D;AAC3D,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;CACjC;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CACrB,MAAM,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,EACnC,MAAM,GAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAO,GACvC,WAAW,EAAE,CAOf;AAMD;;;;GAIG;AACH,wBAAgB,OAAO,CACtB,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,IAAI,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAChC,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,SAAS,CAM9B"}
@@ -0,0 +1,37 @@
1
+ /*!
2
+ * Messages ported from graphql-js 17.0.2 (src/type/scalars.ts,
3
+ * src/type/definition.ts), https://github.com/graphql/graphql-js
4
+ * Copyright (c) GraphQL Contributors
5
+ * and from @graphql-tools/executor 2.0.3 (execution/validateInputValue,
6
+ * execution/values), https://github.com/ardatan/graphql-tools
7
+ * Copyright (c) 2020 The Guild, Inc.
8
+ * @license MIT
9
+ */
10
+ import type { z } from 'zod';
11
+ /** Why a built-in scalar refuses `value`, or undefined when it takes it. */
12
+ export declare function builtinRefusal(name: string, value: unknown): string | undefined;
13
+ /** Why the enum `name` refuses `value`, with graphql's suggestions. */
14
+ export declare function enumRefusal(name: string, values: readonly string[], value: unknown): string | undefined;
15
+ /**
16
+ * Why a custom scalar refuses the value, as a scalar built with
17
+ * `zodScalar` (`@nxgt/graphql-scalars`) words it: its schema's first issue,
18
+ * which the client's schema, the same one, reports too.
19
+ */
20
+ export declare function scalarRefusal(name: string, issue: z.core.$ZodIssue | undefined): string | undefined;
21
+ /** The input object messages, by what is wrong with the object. */
22
+ export declare const objectRefusal: {
23
+ notAnObject: (type: string, value: unknown) => string;
24
+ missingField: (type: string, field: string, object: unknown) => string;
25
+ unknownField: (type: string, field: string, known: readonly string[], object: unknown) => string;
26
+ oneOf: (type: string) => string;
27
+ notProvided: (type: string) => string;
28
+ isNull: (type: string) => string;
29
+ };
30
+ /** The messages about a variable itself, before its value is walked. */
31
+ export declare const variableRefusal: {
32
+ notProvided: (name: string, type: string) => string;
33
+ isNull: (name: string, type: string) => string;
34
+ /** `Variable "$input" got invalid value 1 at "input.tags[0]"; <reason>` */
35
+ invalidValue: (name: string, value: unknown, path: readonly (string | number)[], reason: string) => string;
36
+ };
37
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/runtime/coercion/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQ7B,4EAA4E;AAC5E,wBAAgB,cAAc,CAC7B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GACZ,MAAM,GAAG,SAAS,CAwBpB;AAWD,uEAAuE;AACvE,wBAAgB,WAAW,CAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,KAAK,EAAE,OAAO,GACZ,MAAM,GAAG,SAAS,CAOpB;AAMD;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,SAAS,GACjC,MAAM,GAAG,SAAS,CAEpB;AAED,mEAAmE;AACnE,eAAO,MAAM,aAAa;wBACL,MAAM,SAAS,OAAO;yBAErB,MAAM,SAAS,MAAM,UAAU,OAAO;yBAGpD,MAAM,SACL,MAAM,SACN,SAAS,MAAM,EAAE,UAChB,OAAO;kBAKF,MAAM;wBAEA,MAAM;mBAEX,MAAM;CAErB,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,eAAe;wBACP,MAAM,QAAQ,MAAM;mBAEzB,MAAM,QAAQ,MAAM;IAEnC,2EAA2E;yBAEpE,MAAM,SACL,OAAO,QACR,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,UAC1B,MAAM;CAQf,CAAC"}
@@ -0,0 +1,15 @@
1
+ /*!
2
+ * Ported from graphql-js 17.0.2 (src/jsutils/suggestionList.ts,
3
+ * didYouMean.ts, formatList.ts, naturalCompare.ts),
4
+ * https://github.com/graphql/graphql-js
5
+ * Copyright (c) GraphQL Contributors
6
+ * @license MIT
7
+ */
8
+ /**
9
+ * ` Did you mean "a" or "b"?`, after `subject` when given (`the enum
10
+ * value`), or `''` without a suggestion.
11
+ */
12
+ export declare function didYouMean(suggestions: readonly string[], subject?: string): string;
13
+ /** The options close enough to `input`, the closest first. */
14
+ export declare function suggestionList(input: string, options: readonly string[]): string[];
15
+ //# sourceMappingURL=suggestions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suggestions.d.ts","sourceRoot":"","sources":["../../../src/runtime/coercion/suggestions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH;;;GAGG;AACH,wBAAgB,UAAU,CACzB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,OAAO,CAAC,EAAE,MAAM,GACd,MAAM,CAMR;AAQD,8DAA8D;AAC9D,wBAAgB,cAAc,CAC7B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,MAAM,EAAE,GACxB,MAAM,EAAE,CAWV"}
@@ -0,0 +1,39 @@
1
+ /*!
2
+ * Ported from @graphql-tools/executor 2.0.3 (execution/validateInputValue),
3
+ * https://github.com/ardatan/graphql-tools
4
+ * Copyright (c) 2020 The Guild, Inc.
5
+ * itself a copy of graphql-js 17's validateInputValue,
6
+ * https://github.com/graphql/graphql-js
7
+ * Copyright (c) GraphQL Contributors
8
+ * @license MIT
9
+ */
10
+ import { type InputTypes, type TypeRef } from './document.js';
11
+ import { type PlacedIssue } from './issues.js';
12
+ type Path = readonly (string | number)[];
13
+ /** One value graphql refuses: where, the value there, and why. */
14
+ export interface Problem {
15
+ readonly path: Path;
16
+ readonly value: unknown;
17
+ readonly reason: string;
18
+ }
19
+ /** What a walk reads, and the problems it found so far. */
20
+ export interface Walk {
21
+ readonly types: InputTypes;
22
+ readonly issues: readonly PlacedIssue[];
23
+ readonly problems: Problem[];
24
+ }
25
+ /** Where a walk stands: graphql's path below the variable, and the Zod schema's. */
26
+ interface At {
27
+ readonly path: Path;
28
+ /**
29
+ * From the variable's name. It differs from graphql's where a single
30
+ * value stands for a list: the schema wraps it (`[0]`), graphql does not.
31
+ */
32
+ readonly zodPath: Path;
33
+ }
34
+ /** Walks `value` at `type`, recording each problem in `walk.problems`. */
35
+ export declare function validateValue(walk: Walk, value: unknown, type: TypeRef, at: At): void;
36
+ /** Thrown on an input type whose `kind` this runtime does not know. */
37
+ export declare const STALE_FILE = "@nxgt/graphql-codegen-msw: the generated file was written by another version than the runtime; regenerate it";
38
+ export {};
39
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/runtime/coercion/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EAGN,KAAK,UAAU,EAEf,KAAK,OAAO,EACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAQrD,KAAK,IAAI,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;AAGzC,kEAAkE;AAClE,MAAM,WAAW,OAAO;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,2DAA2D;AAC3D,MAAM,WAAW,IAAI;IACpB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;CAC7B;AAED,oFAAoF;AACpF,UAAU,EAAE;IACX,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;CACvB;AAED,0EAA0E;AAC1E,wBAAgB,aAAa,CAC5B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,OAAO,EACb,EAAE,EAAE,EAAE,GACJ,IAAI,CAcN;AA2DD,uEAAuE;AACvE,eAAO,MAAM,UAAU,iHACwF,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { type FieldError, type FieldIssue, fieldIssueOf, fieldsError, inputPath, invalidInputError, type Translate, } from '@nxgt/graphql-validation';
2
+ export type { InputType, InputTypes } from './coercion/index.js';
3
+ export { type GraphQLMockInfo, type GraphQLMockResolver, type MockedOperation, type MockOptions, mockOperation, } from './mock-operation.js';
4
+ export { badUserInputRefusal, type InvalidInput, type InvalidInputAnswer, invalidInputRefusal, type RefusedOperation, } from './refusals.js';
5
+ export { type AnyGraphQLError, errorResponse, isGraphQLError, } from './response.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,UAAU,EACf,KAAK,UAAU,EACf,YAAY,EACZ,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,KAAK,SAAS,GACd,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,aAAa,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,mBAAmB,EACnB,KAAK,gBAAgB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,KAAK,eAAe,EACpB,aAAa,EACb,cAAc,GACd,MAAM,YAAY,CAAC"}