@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,21 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/runtime/index.ts", "../src/runtime/mock-operation.ts", "../src/runtime/coercion/index.ts", "../src/runtime/coercion/document.ts", "../src/runtime/coercion/issues.ts", "../src/runtime/coercion/cross-inspect.ts", "../src/runtime/coercion/inspect.ts", "../src/runtime/coercion/suggestions.ts", "../src/runtime/coercion/messages.ts", "../src/runtime/coercion/validate.ts", "../src/runtime/response.ts", "../src/runtime/refusals.ts"],
4
+ "sourcesContent": [
5
+ "// What an `invalidInput` of your own builds its answer with, from\n// `@nxgt/graphql-validation`, so an application needs no direct import of it.\nexport {\n\ttype FieldError,\n\ttype FieldIssue,\n\tfieldIssueOf,\n\tfieldsError,\n\tinputPath,\n\tinvalidInputError,\n\ttype Translate,\n} from '@nxgt/graphql-validation';\nexport type { InputType, InputTypes } from './coercion';\nexport {\n\ttype GraphQLMockInfo,\n\ttype GraphQLMockResolver,\n\ttype MockedOperation,\n\ttype MockOptions,\n\tmockOperation,\n} from './mock-operation';\nexport {\n\tbadUserInputRefusal,\n\ttype InvalidInput,\n\ttype InvalidInputAnswer,\n\tinvalidInputRefusal,\n\ttype RefusedOperation,\n} from './refusals';\nexport {\n\ttype AnyGraphQLError,\n\terrorResponse,\n\tisGraphQLError,\n} from './response';\n",
6
+ "import type {\n\tPath,\n\tRequestHandlerOptions,\n\tResponseResolverInfo,\n\tResponseResolverReturnType,\n} from 'msw';\nimport {\n\ttype GraphQLHandler,\n\ttype GraphQLQuery,\n\ttype GraphQLResponseBody,\n\ttype GraphQLVariables,\n\tgraphql,\n} from 'msw/graphql';\nimport type { z } from 'zod';\nimport { COERCION_STATUS, coercionErrors, type InputTypes } from './coercion';\nimport type { InvalidInput } from './refusals';\nimport { errorResponse, isGraphQLError } from './response';\n\n/**\n * What a resolver receives: msw's own resolver info for a GraphQL\n * operation (`variables`, `query`, `operationName`, `request`, `cookies`,\n * `requestId`, `finalize`), `variables` typed with the operation's\n * variables type. They are the variables as sent: checked, not parsed.\n */\nexport type GraphQLMockInfo<Variables extends GraphQLVariables> =\n\tResponseResolverInfo<{\n\t\tquery: string;\n\t\toperationName: string;\n\t\tvariables: Variables;\n\t\tcookies: Record<string, string>;\n\t}>;\n\n/**\n * A handler's resolver, as msw's `graphql.link(...).query(name, resolver)`\n * takes one, without its generator form: return\n * `HttpResponse.json({ data })`, an `errorResponse(...)`, or nothing to\n * let the next handler answer; throw a `GraphQLError` to answer with it.\n */\nexport type GraphQLMockResolver<\n\tResult extends GraphQLQuery,\n\tVariables extends GraphQLVariables,\n> = (\n\tinfo: GraphQLMockInfo<Variables>,\n) =>\n\t| ResponseResolverReturnType<GraphQLResponseBody<Result>>\n\t| Promise<ResponseResolverReturnType<GraphQLResponseBody<Result>>>;\n\n/** A handler's options: msw's (`once`), and an endpoint for this handler only. */\nexport interface MockOptions extends RequestHandlerOptions {\n\t/** Overrides the generated `endpoint` for this handler: a URL or a path msw matches. */\n\treadonly endpoint?: Path;\n}\n\n/** One operation, as the generated file describes it. */\nexport interface MockedOperation {\n\treadonly type: 'query' | 'mutation';\n\t/** The operation's name in the document: `SignUp`. */\n\treadonly name: string;\n\t/** The variables' schema, from `@nxgt/graphql-codegen-zod`: `zSignUpMutationVariables`. */\n\treadonly variables: z.ZodType;\n\t/**\n\t * Each variable's GraphQL type, with its default: `{ first: \"Int = 10\" }`.\n\t * Internal: written by the plugin for the coercion answer, its form may\n\t * change in any version together with the generated file. Defaults to\n\t * `{}`: no variable is walked, and every refusal goes to `invalidInput`.\n\t */\n\treadonly variableTypes?: Readonly<Record<string, string>> | undefined;\n\t/**\n\t * The input types the variables reach, from the schema. Internal, as\n\t * `variableTypes`; defaults to `{}`.\n\t */\n\treadonly inputTypes?: InputTypes | undefined;\n\treadonly endpoint: Path;\n\treadonly invalidInput: InvalidInput;\n}\n\n/**\n * An msw handler for one operation: `graphql.link(endpoint)`'s `query` or\n * `mutation` by the operation's name. Its variables are checked with the\n * operation's schema first, without calling `resolver` when they fail: a\n * value graphql refuses while coercing the variables (missing, null, of\n * the wrong type, an unknown enum value or field, an Int beyond 32 bits, a\n * value a custom scalar refuses) is answered as graphql-yoga answers it\n * (`coercionErrors`, status 400), whatever `invalidInput` is; any other\n * invalid input with `invalidInput`'s error and status. A `GraphQLError`\n * the resolver throws is answered as `errorResponse` answers it; anything\n * else it throws is msw's to answer (a 500).\n */\nexport function mockOperation<\n\tResult extends GraphQLQuery,\n\tVariables extends GraphQLVariables,\n>(\n\toperation: MockedOperation,\n\tresolver: GraphQLMockResolver<Result, Variables>,\n\toptions: MockOptions = {},\n): GraphQLHandler {\n\tconst { endpoint = operation.endpoint, ...handlerOptions } = options;\n\tconst link = graphql.link(endpoint);\n\tconst where = { type: operation.type, name: operation.name };\n\treturn link[operation.type](\n\t\toperation.name,\n\t\tasync (info) => {\n\t\t\tconst checked = await operation.variables.safeParseAsync(info.variables);\n\t\t\tif (!checked.success) {\n\t\t\t\tconst { issues } = checked.error;\n\t\t\t\t// The API refuses these while coercing the variables, before\n\t\t\t\t// its own validation: whatever invalidInput says.\n\t\t\t\tconst refused = coercionErrors(issues, info, operation);\n\t\t\t\tif (refused.length > 0)\n\t\t\t\t\treturn errorResponse(refused, { status: COERCION_STATUS });\n\t\t\t\t// A status no response can carry is ignored, as errorResponse\n\t\t\t\t// ignores it: the error's own, else 200.\n\t\t\t\tconst { error, status } = await operation.invalidInput(issues, where);\n\t\t\t\treturn errorResponse(error, { status });\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst answer = await resolver(info as GraphQLMockInfo<Variables>);\n\t\t\t\tassertNotIterator(answer, operation.name);\n\t\t\t\treturn answer;\n\t\t\t} catch (error) {\n\t\t\t\tif (isGraphQLError(error)) return errorResponse(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\thandlerOptions,\n\t);\n}\n\n/**\n * msw would keep a generator's iterator and answer the next requests from\n * it without calling this handler's resolver again, so their variables would\n * go unchecked: refused instead.\n */\nfunction assertNotIterator(answer: unknown, name: string): void {\n\tif (\n\t\ttypeof answer === 'object' &&\n\t\tanswer !== null &&\n\t\t!(answer instanceof Response) &&\n\t\ttypeof (answer as { next?: unknown }).next === 'function'\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`@nxgt/graphql-codegen-msw: the resolver of ${name} returned an iterator (a generator function?). Each request's variables are checked before the resolver runs, which msw cannot do once it keeps an iterator: answer each request from a plain function, or register one handler per answer with { once: true }.`,\n\t\t);\n\t}\n}\n",
7
+ "// What graphql-yoga refuses while it coerces the variables, before any\n// resolver runs: a missing or null value for a non-null type, a value of the\n// wrong type, an unknown enum value, an unknown input field, an Int beyond\n// 32 bits, a value a custom scalar refuses. Measured on graphql-yoga 5.24\n// (@graphql-tools/executor 2, graphql 17): one error per problem,\n// `{ message, locations }` and no extensions, status 400 whatever the\n// Accept header.\n//\n// How coercion is decided: the variables are walked as graphql walks them\n// (`validate.ts`), over the input types the generated file describes from\n// the schema. A built-in scalar, an enum, an input object and the non-null\n// and list wrappers are judged as graphql judges them, from the declared\n// type and the value sent, never from a Zod issue; a custom scalar refuses\n// exactly where the operation's Zod schema has an issue at its position.\n// So the answer is graphql-yoga's whenever graphql would refuse, and empty\n// otherwise, when the issues are the API's own validation.\nimport type { GraphQLFormattedError, VariableDefinitionNode } from 'graphql';\nimport { GraphQLError } from 'graphql';\nimport type { z } from 'zod';\nimport {\n\tdeclared,\n\tdefinitionsOf,\n\ttype InputTypes,\n\tprintType,\n} from './document';\nimport { placed } from './issues';\nimport { variableRefusal } from './messages';\nimport { type Problem, validateValue, type Walk } from './validate';\n\nexport type { InputType, InputTypes } from './document';\nexport { STALE_FILE } from './validate';\n\n/** The status graphql-yoga answers a variable coercion error with. */\nexport const COERCION_STATUS = 400;\n\n/**\n * What the generated file says of an operation's variables. Without them\n * (a hand-written handler), no variable is walked.\n */\nexport interface DeclaredVariables {\n\t/** Each variable's type, with its default: `{ first: \"Int = 10\" }`. */\n\treadonly variableTypes?: Readonly<Record<string, string>> | undefined;\n\treadonly inputTypes?: InputTypes | undefined;\n}\n\n/** The request whose variables the operation's schema refused. */\nexport interface CoercedRequest {\n\treadonly query: string;\n\treadonly operationName: string;\n\treadonly variables: unknown;\n}\n\n/**\n * The errors graphql-yoga answers the request's variables with, in its\n * order (variables in declaration order, an object's fields in the\n * schema's, unknown fields last), each located at the variable's\n * definition in the query sent; empty when graphql takes every variable.\n */\nexport function coercionErrors(\n\tissues: readonly z.core.$ZodIssue[],\n\trequest: CoercedRequest,\n\toperation: DeclaredVariables,\n): GraphQLFormattedError[] {\n\tconst definitions = definitionsOf(request.query, request.operationName);\n\tconst sent =\n\t\ttypeof request.variables === 'object' && request.variables !== null\n\t\t\t? (request.variables as Record<string, unknown>)\n\t\t\t: {};\n\tconst walked = placed(issues);\n\tconst { variableTypes = {}, inputTypes = {} } = operation;\n\treturn Object.entries(variableTypes).flatMap(([name, source]) =>\n\t\tvariableMessages(name, source, sent, {\n\t\t\ttypes: inputTypes,\n\t\t\tissues: walked,\n\t\t\tproblems: [],\n\t\t}).map((message) => located(message, definitions.get(name))),\n\t);\n}\n\n/** One variable's messages, as @graphql-tools/executor's `getVariableValues` words them. */\nfunction variableMessages(\n\tname: string,\n\tsource: string,\n\tsent: Record<string, unknown>,\n\twalk: Walk,\n): string[] {\n\tconst { type, hasDefault } = declared(source);\n\tif (!Object.hasOwn(sent, name))\n\t\treturn type.kind === 'non-null' && !hasDefault\n\t\t\t? [variableRefusal.notProvided(name, printType(type))]\n\t\t\t: [];\n\tconst value = sent[name];\n\tif (value === null && type.kind === 'non-null')\n\t\treturn [variableRefusal.isNull(name, printType(type))];\n\tvalidateValue(walk, value, type, { path: [], zodPath: [name] });\n\treturn walk.problems.map(({ path, value: found, reason }: Problem) =>\n\t\tvariableRefusal.invalidValue(name, found, path, reason),\n\t);\n}\n\nfunction located(\n\tmessage: string,\n\tdefinition: VariableDefinitionNode | undefined,\n): GraphQLFormattedError {\n\treturn new GraphQLError(\n\t\tmessage,\n\t\tdefinition ? { nodes: definition } : {},\n\t).toJSON();\n}\n",
8
+ "import {\n\tKind,\n\ttype OperationDefinitionNode,\n\tparse,\n\ttype VariableDefinitionNode,\n} from 'graphql';\n\n/**\n * One GraphQL type the variables reach, as the generated file describes it\n * from the schema: a built-in scalar (`String`, `Int`, `Float`, `Boolean`,\n * `ID`), a custom scalar, an enum and its values, or an input object and\n * the type of each field (`\"[String!]\"`, `\"Int! = 1\"` with a default).\n *\n * Internal: written by the plugin and read by the coercion answer only. Its\n * form may change in any version, together with the generated file.\n */\nexport type InputType =\n\t| { readonly kind: 'builtin' }\n\t| { readonly kind: 'scalar' }\n\t| { readonly kind: 'enum'; readonly values: readonly string[] }\n\t| {\n\t\t\treadonly kind: 'input';\n\t\t\treadonly fields: Readonly<Record<string, string>>;\n\t\t\treadonly oneOf?: true;\n\t };\n\n/** The input types of one generated file, by name. Internal, as `InputType`. */\nexport type InputTypes = Readonly<Record<string, InputType>>;\n\n/** A type as graphql-js walks it: non-null and list wrappers around a name. */\nexport type TypeRef =\n\t| { readonly kind: 'non-null'; readonly of: TypeRef }\n\t| { readonly kind: 'list'; readonly of: TypeRef }\n\t| { readonly kind: 'named'; readonly name: string };\n\n/** A variable's or an input field's declaration: its type, and whether it has a default. */\nexport interface Declared {\n\treadonly type: TypeRef;\n\treadonly hasDefault: boolean;\n}\n\n/** `\"[Int!]! = [1]\"` read: the type before ` = `, a default after it. */\nexport function declared(source: string): Declared {\n\tconst at = source.indexOf(' = ');\n\tconst printed = at === -1 ? source : source.slice(0, at);\n\treturn { type: typeRef(printed.trim()), hasDefault: at !== -1 };\n}\n\nfunction typeRef(printed: string): TypeRef {\n\tif (printed.endsWith('!'))\n\t\treturn { kind: 'non-null', of: typeRef(printed.slice(0, -1)) };\n\tif (printed.startsWith('[') && printed.endsWith(']'))\n\t\treturn { kind: 'list', of: typeRef(printed.slice(1, -1)) };\n\treturn { kind: 'named', name: printed };\n}\n\n/** A type as graphql-js prints it in a message: `[Int!]!`. */\nexport function printType(type: TypeRef): string {\n\tswitch (type.kind) {\n\t\tcase 'non-null':\n\t\t\treturn `${printType(type.of)}!`;\n\t\tcase 'list':\n\t\t\treturn `[${printType(type.of)}]`;\n\t\tdefault:\n\t\t\treturn type.name;\n\t}\n}\n\n/**\n * The variables' definitions of the operation named `name` in the query the\n * client sent, by variable: where each error is located. Empty when the\n * query does not parse.\n */\nexport function definitionsOf(\n\tquery: string,\n\tname: string,\n): ReadonlyMap<string, VariableDefinitionNode> {\n\tlet operations: OperationDefinitionNode[];\n\ttry {\n\t\toperations = parse(query).definitions.filter(\n\t\t\t(node): node is OperationDefinitionNode =>\n\t\t\t\tnode.kind === Kind.OPERATION_DEFINITION,\n\t\t);\n\t} catch {\n\t\treturn new Map();\n\t}\n\tconst operation =\n\t\toperations.find((node) => node.name?.value === name) ?? operations[0];\n\treturn new Map(\n\t\t(operation?.variableDefinitions ?? []).map((node) => [\n\t\t\tnode.variable.name.value,\n\t\t\tnode,\n\t\t]),\n\t);\n}\n",
9
+ "import type { z } from 'zod';\n\n/** A Zod issue and its whole path inside the variables. */\nexport interface PlacedIssue {\n\treadonly path: readonly (string | number)[];\n\treadonly issue: z.core.$ZodIssue;\n}\n\n/**\n * Every issue with its whole path, a union's own issue followed by each of\n * its branches' (a list that also takes a single value is a union): a\n * custom scalar's refusal may sit in either branch.\n */\nexport function placed(\n\tissues: readonly z.core.$ZodIssue[],\n\tprefix: readonly (string | number)[] = [],\n): PlacedIssue[] {\n\treturn issues.flatMap((issue) => {\n\t\tconst path = [...prefix, ...issue.path.map(segment)];\n\t\tconst own = { path, issue };\n\t\tif (issue.code !== 'invalid_union') return [own];\n\t\treturn [own, ...issue.errors.flatMap((branch) => placed(branch, path))];\n\t});\n}\n\nfunction segment(key: PropertyKey): string | number {\n\treturn typeof key === 'number' ? key : String(key);\n}\n\n/**\n * The first issue at `path` or below it: what a custom scalar's schema\n * refused there. A scalar built with `zodScalar` refuses with its schema's\n * first issue, which the client's schema, the same one, reports first too.\n */\nexport function issueAt(\n\tissues: readonly PlacedIssue[],\n\tpath: readonly (string | number)[],\n): z.core.$ZodIssue | undefined {\n\treturn issues.find(\n\t\t(placedIssue) =>\n\t\t\tplacedIssue.path.length >= path.length &&\n\t\t\tpath.every((key, index) => placedIssue.path[index] === key),\n\t)?.issue;\n}\n",
10
+ "/*!\n * Ported from cross-inspect 1.0.1 (packages/inspect),\n * https://github.com/ardatan/graphql-tools\n * Copyright (c) 2020 The Guild, Inc.\n * itself taken from graphql-js, https://github.com/graphql/graphql-js\n * Copyright (c) GraphQL Contributors\n * @license MIT\n */\n\n/**\n * A value as @graphql-tools/executor prints it in the messages it words\n * itself (the input objects' and the variable's prefix), through\n * `cross-inspect`: a string quoted, `{ a: 1, b: \"x\" }`, `[1, 2]`, `{}` and\n * `[]`, `[Object]` or `[Array]` beyond three levels, and every item of a\n * list. The variables come from JSON, so no function, error or cycle\n * reaches it: those branches of cross-inspect are left out. graphql's own\n * messages print with graphql's `inspect` (`inspect.ts`).\n */\nexport function crossInspect(value: unknown): string {\n\treturn formatValue(value, 0);\n}\n\nconst MAX_DEPTH = 3;\n\nfunction formatValue(value: unknown, depth: number): string {\n\tif (typeof value === 'string') return JSON.stringify(value);\n\tif (typeof value !== 'object' || value === null) return String(value);\n\tif (Array.isArray(value)) {\n\t\tif (value.length === 0) return '[]';\n\t\tif (depth >= MAX_DEPTH) return '[Array]';\n\t\treturn `[${value.map((item) => formatValue(item, depth + 1)).join(', ')}]`;\n\t}\n\tconst entries = Object.entries(value);\n\tif (entries.length === 0) return '{}';\n\tif (depth >= MAX_DEPTH) return '[Object]';\n\treturn `{ ${entries\n\t\t.map(([key, item]) => `${key}: ${formatValue(item, depth + 1)}`)\n\t\t.join(', ')} }`;\n}\n",
11
+ "/*!\n * Ported from graphql-js 17.0.2 (src/jsutils/inspect.ts),\n * https://github.com/graphql/graphql-js\n * Copyright (c) GraphQL Contributors\n * @license MIT\n */\n\n// graphql-js's own `inspect`, ported line for line: what graphql prints in\n// the messages it words itself (the built-in scalars', an enum's, and the\n// value an enum suggestion is read from). Two levels deep, then `[Object]`\n// or `[Array]`; ten items of a list, then `... N more items`. The executor's\n// messages print with `cross-inspect` instead (`cross-inspect.ts`).\n\nconst MAX_ARRAY_LENGTH = 10;\nconst MAX_RECURSIVE_DEPTH = 2;\n\n/** A value as graphql-js prints it in an error message. */\nexport function inspect(value: unknown): string {\n\treturn formatValue(value, []);\n}\n\nfunction formatValue(value: unknown, seenValues: readonly unknown[]): string {\n\tswitch (typeof value) {\n\t\tcase 'string':\n\t\t\treturn JSON.stringify(value);\n\t\tcase 'function':\n\t\t\treturn value.name ? `[function ${value.name}]` : '[function]';\n\t\tcase 'object':\n\t\t\treturn formatObjectValue(value, seenValues);\n\t\tdefault:\n\t\t\treturn String(value);\n\t}\n}\n\nfunction formatObjectValue(\n\tvalue: object | null,\n\tpreviouslySeenValues: readonly unknown[],\n): string {\n\tif (value === null) {\n\t\treturn 'null';\n\t}\n\tif (previouslySeenValues.includes(value)) {\n\t\treturn '[Circular]';\n\t}\n\tconst seenValues = [...previouslySeenValues, value];\n\tif (isJSONable(value)) {\n\t\tconst jsonValue = value.toJSON();\n\t\t// check for infinite recursion\n\t\tif (jsonValue !== value) {\n\t\t\treturn typeof jsonValue === 'string'\n\t\t\t\t? jsonValue\n\t\t\t\t: formatValue(jsonValue, seenValues);\n\t\t}\n\t} else if (Array.isArray(value)) {\n\t\treturn formatArray(value, seenValues);\n\t}\n\treturn formatObject(value, seenValues);\n}\n\nfunction isJSONable(value: object): value is { toJSON: () => unknown } {\n\treturn typeof (value as { toJSON?: unknown }).toJSON === 'function';\n}\n\nfunction formatObject(object: object, seenValues: readonly unknown[]): string {\n\tconst entries = Object.entries(object);\n\tif (entries.length === 0) {\n\t\treturn '{}';\n\t}\n\tif (seenValues.length > MAX_RECURSIVE_DEPTH) {\n\t\treturn `[${getObjectTag(object)}]`;\n\t}\n\tconst properties = entries.map(\n\t\t([key, value]) => `${key}: ${formatValue(value, seenValues)}`,\n\t);\n\treturn `{ ${properties.join(', ')} }`;\n}\n\nfunction formatArray(\n\tarray: readonly unknown[],\n\tseenValues: readonly unknown[],\n): string {\n\tif (array.length === 0) {\n\t\treturn '[]';\n\t}\n\tif (seenValues.length > MAX_RECURSIVE_DEPTH) {\n\t\treturn '[Array]';\n\t}\n\tconst len = Math.min(MAX_ARRAY_LENGTH, array.length);\n\tconst remaining = array.length - len;\n\tconst items: string[] = [];\n\tfor (let i = 0; i < len; ++i) {\n\t\titems.push(formatValue(array[i], seenValues));\n\t}\n\tif (remaining === 1) {\n\t\titems.push('... 1 more item');\n\t} else if (remaining > 1) {\n\t\titems.push(`... ${remaining} more items`);\n\t}\n\treturn `[${items.join(', ')}]`;\n}\n\nfunction getObjectTag(object: object): string {\n\tconst tag = Object.prototype.toString\n\t\t.call(object)\n\t\t.replace(/^\\[object /, '')\n\t\t.replace(/]$/, '');\n\tif (tag === 'Object' && typeof object.constructor === 'function') {\n\t\tconst name = object.constructor.name;\n\t\tif (typeof name === 'string' && name !== '') {\n\t\t\treturn name;\n\t\t}\n\t}\n\treturn tag;\n}\n",
12
+ "/*!\n * Ported from graphql-js 17.0.2 (src/jsutils/suggestionList.ts,\n * didYouMean.ts, formatList.ts, naturalCompare.ts),\n * https://github.com/graphql/graphql-js\n * Copyright (c) GraphQL Contributors\n * @license MIT\n */\n\n// graphql-js's \"Did you mean …?\" (graphql 17's `suggestionList`,\n// `didYouMean`, `orList` and `naturalCompare`, which\n// @graphql-tools/executor copies), ported line for line so the mock\n// suggests what the API suggests, in the same order. graphql 16 words a\n// few messages differently; graphql-yoga 5 on graphql 17 is the reference.\n\nconst MAX_SUGGESTIONS = 5;\n\n/**\n * ` Did you mean \"a\" or \"b\"?`, after `subject` when given (`the enum\n * value`), or `''` without a suggestion.\n */\nexport function didYouMean(\n\tsuggestions: readonly string[],\n\tsubject?: string,\n): string {\n\tif (suggestions.length === 0) return '';\n\tconst listed = orList(\n\t\tsuggestions.slice(0, MAX_SUGGESTIONS).map((item) => `\"${item}\"`),\n\t);\n\treturn ` Did you mean ${subject ? `${subject} ` : ''}${listed}?`;\n}\n\nfunction orList(items: readonly string[]): string {\n\tif (items.length === 1) return items[0] ?? '';\n\tif (items.length === 2) return `${items[0]} or ${items[1]}`;\n\treturn `${items.slice(0, -1).join(', ')}, or ${items.at(-1)}`;\n}\n\n/** The options close enough to `input`, the closest first. */\nexport function suggestionList(\n\tinput: string,\n\toptions: readonly string[],\n): string[] {\n\tconst distances = new Map<string, number>();\n\tconst threshold = Math.floor(input.length * 0.4) + 1;\n\tfor (const option of options) {\n\t\tconst distance = lexicalDistance(input, option, threshold);\n\t\tif (distance !== undefined) distances.set(option, distance);\n\t}\n\treturn [...distances.keys()].sort(\n\t\t(a, b) =>\n\t\t\t(distances.get(a) ?? 0) - (distances.get(b) ?? 0) || naturalCompare(a, b),\n\t);\n}\n\n/**\n * Damerau-Levenshtein on the lower-cased strings, a change of case alone\n * counting as one edit; undefined beyond `threshold`.\n */\nfunction lexicalDistance(\n\tinput: string,\n\toption: string,\n\tthreshold: number,\n): number | undefined {\n\tif (input === option) return 0;\n\tconst lowerInput = input.toLowerCase();\n\tconst lowerOption = option.toLowerCase();\n\tif (lowerInput === lowerOption) return 1;\n\tlet a = codes(lowerOption);\n\tlet b = codes(lowerInput);\n\tif (a.length < b.length) [a, b] = [b, a];\n\tif (a.length - b.length > threshold) return undefined;\n\tconst rows = [0, 1, 2].map(() => new Array<number>(b.length + 1).fill(0));\n\tconst row = (i: number): number[] => rows[i % 3] as number[];\n\tfor (let j = 0; j <= b.length; j++) row(0)[j] = j;\n\tfor (let i = 1; i <= a.length; i++) {\n\t\tconst up = row(i - 1);\n\t\tconst current = row(i);\n\t\tcurrent[0] = i;\n\t\tlet smallest = i;\n\t\tfor (let j = 1; j <= b.length; j++) {\n\t\t\tconst cost = a[i - 1] === b[j - 1] ? 0 : 1;\n\t\t\tlet cell = Math.min(\n\t\t\t\t(up[j] ?? 0) + 1,\n\t\t\t\t(current[j - 1] ?? 0) + 1,\n\t\t\t\t(up[j - 1] ?? 0) + cost,\n\t\t\t);\n\t\t\tif (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1])\n\t\t\t\tcell = Math.min(cell, (row(i - 2)[j - 2] ?? 0) + 1);\n\t\t\tif (cell < smallest) smallest = cell;\n\t\t\tcurrent[j] = cell;\n\t\t}\n\t\tif (smallest > threshold) return undefined;\n\t}\n\tconst distance = row(a.length)[b.length] ?? 0;\n\treturn distance <= threshold ? distance : undefined;\n}\n\nfunction codes(text: string): number[] {\n\treturn Array.from({ length: text.length }, (_, i) => text.charCodeAt(i));\n}\n\nconst DIGIT_0 = 48;\nconst DIGIT_9 = 57;\n\nconst isDigit = (code: number): boolean =>\n\t!Number.isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9;\n\n/** graphql-js's order for two suggestions equally close: numbers by value. */\nfunction naturalCompare(aText: string, bText: string): number {\n\tlet a = 0;\n\tlet b = 0;\n\twhile (a < aText.length && b < bText.length) {\n\t\tlet aChar = aText.charCodeAt(a);\n\t\tlet bChar = bText.charCodeAt(b);\n\t\tif (isDigit(aChar) && isDigit(bChar)) {\n\t\t\tlet aNumber = 0;\n\t\t\tdo {\n\t\t\t\t++a;\n\t\t\t\taNumber = aNumber * 10 + aChar - DIGIT_0;\n\t\t\t\taChar = aText.charCodeAt(a);\n\t\t\t} while (isDigit(aChar) && aNumber > 0);\n\t\t\tlet bNumber = 0;\n\t\t\tdo {\n\t\t\t\t++b;\n\t\t\t\tbNumber = bNumber * 10 + bChar - DIGIT_0;\n\t\t\t\tbChar = bText.charCodeAt(b);\n\t\t\t} while (isDigit(bChar) && bNumber > 0);\n\t\t\tif (aNumber !== bNumber) return aNumber < bNumber ? -1 : 1;\n\t\t} else {\n\t\t\tif (aChar !== bChar) return aChar < bChar ? -1 : 1;\n\t\t\t++a;\n\t\t\t++b;\n\t\t}\n\t}\n\treturn aText.length - bText.length;\n}\n",
13
+ "/*!\n * Messages ported from graphql-js 17.0.2 (src/type/scalars.ts,\n * src/type/definition.ts), https://github.com/graphql/graphql-js\n * Copyright (c) GraphQL Contributors\n * and from @graphql-tools/executor 2.0.3 (execution/validateInputValue,\n * execution/values), https://github.com/ardatan/graphql-tools\n * Copyright (c) 2020 The Guild, Inc.\n * @license MIT\n */\n\n// How graphql 17 words a value it refuses, as graphql-yoga 5 with\n// @graphql-tools/executor 2 answers it: the leaf scalars' and enums' own\n// messages, printed with graphql's `inspect`, and the input object's and\n// the variable's prefix, which the executor words and prints with\n// `cross-inspect`.\nimport type { z } from 'zod';\nimport { crossInspect } from './cross-inspect';\nimport { inspect } from './inspect';\nimport { didYouMean, suggestionList } from './suggestions';\n\nconst INT_MAX = 2_147_483_647;\nconst INT_MIN = -2_147_483_648;\n\n/** Why a built-in scalar refuses `value`, or undefined when it takes it. */\nexport function builtinRefusal(\n\tname: string,\n\tvalue: unknown,\n): string | undefined {\n\tconst found = inspect(value);\n\tswitch (name) {\n\t\tcase 'String':\n\t\t\treturn typeof value === 'string'\n\t\t\t\t? undefined\n\t\t\t\t: `String cannot represent a non string value: ${found}`;\n\t\tcase 'Boolean':\n\t\t\treturn typeof value === 'boolean'\n\t\t\t\t? undefined\n\t\t\t\t: `Boolean cannot represent a non boolean value: ${found}`;\n\t\tcase 'Float':\n\t\t\treturn typeof value === 'number' && Number.isFinite(value)\n\t\t\t\t? undefined\n\t\t\t\t: `Float cannot represent non numeric value: ${found}`;\n\t\tcase 'ID':\n\t\t\treturn typeof value === 'string' || Number.isInteger(value)\n\t\t\t\t? undefined\n\t\t\t\t: `ID cannot represent value: ${found}`;\n\t\tcase 'Int':\n\t\t\treturn intRefusal(value);\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\n/** Int's bound is decided from the declared type, never from a Zod issue. */\nfunction intRefusal(value: unknown): string | undefined {\n\tif (typeof value !== 'number' || !Number.isInteger(value))\n\t\treturn `Int cannot represent non-integer value: ${inspect(value)}`;\n\tif (value > INT_MAX || value < INT_MIN)\n\t\treturn `Int cannot represent non 32-bit signed integer value: ${inspect(value)}`;\n\treturn undefined;\n}\n\n/** Why the enum `name` refuses `value`, with graphql's suggestions. */\nexport function enumRefusal(\n\tname: string,\n\tvalues: readonly string[],\n\tvalue: unknown,\n): string | undefined {\n\tif (typeof value !== 'string') {\n\t\tconst found = inspect(value);\n\t\treturn `Enum \"${name}\" cannot represent non-string value: ${found}.${suggest(found, values)}`;\n\t}\n\tif (values.includes(value)) return undefined;\n\treturn `Value \"${value}\" does not exist in \"${name}\" enum.${suggest(value, values)}`;\n}\n\nfunction suggest(value: string, values: readonly string[]): string {\n\treturn didYouMean(suggestionList(value, values), 'the enum value');\n}\n\n/**\n * Why a custom scalar refuses the value, as a scalar built with\n * `zodScalar` (`@nxgt/graphql-scalars`) words it: its schema's first issue,\n * which the client's schema, the same one, reports too.\n */\nexport function scalarRefusal(\n\tname: string,\n\tissue: z.core.$ZodIssue | undefined,\n): string | undefined {\n\treturn issue && `${name} cannot represent this input: ${issue.message}`;\n}\n\n/** The input object messages, by what is wrong with the object. */\nexport const objectRefusal = {\n\tnotAnObject: (type: string, value: unknown) =>\n\t\t`Expected value of type \"${type}\" to be an object, found: ${crossInspect(value)}.`,\n\tmissingField: (type: string, field: string, object: unknown) =>\n\t\t`Expected value of type \"${type}\" to include required field \"${field}\", found: ${crossInspect(object)}.`,\n\tunknownField: (\n\t\ttype: string,\n\t\tfield: string,\n\t\tknown: readonly string[],\n\t\tobject: unknown,\n\t) => {\n\t\tconst suggestion = didYouMean(suggestionList(field, known));\n\t\treturn `Expected value of type \"${type}\" not to include unknown field \"${field}\"${suggestion ? `.${suggestion} Found` : ', found'}: ${crossInspect(object)}.`;\n\t},\n\toneOf: (type: string) =>\n\t\t`Within OneOf Input Object type \"${type}\", exactly one field must be specified, and the value for that field must be non-null.`,\n\tnotProvided: (type: string) =>\n\t\t`Expected a value of non-null type \"${type}\" to be provided.`,\n\tisNull: (type: string) =>\n\t\t`Expected value of non-null type \"${type}\" not to be null.`,\n};\n\n/** The messages about a variable itself, before its value is walked. */\nexport const variableRefusal = {\n\tnotProvided: (name: string, type: string) =>\n\t\t`Variable \"$${name}\" of required type \"${type}\" was not provided.`,\n\tisNull: (name: string, type: string) =>\n\t\t`Variable \"$${name}\" of non-null type \"${type}\" must not be null.`,\n\t/** `Variable \"$input\" got invalid value 1 at \"input.tags[0]\"; <reason>` */\n\tinvalidValue: (\n\t\tname: string,\n\t\tvalue: unknown,\n\t\tpath: readonly (string | number)[],\n\t\treason: string,\n\t) => {\n\t\tconst at =\n\t\t\tpath.length > 0\n\t\t\t\t? ` at \"${name}${path.map((key) => (typeof key === 'number' ? `[${key}]` : `.${key}`)).join('')}\"`\n\t\t\t\t: '';\n\t\treturn `Variable \"$${name}\" got invalid value ${crossInspect(value)}${at}; ${reason}`;\n\t},\n};\n",
14
+ "/*!\n * Ported from @graphql-tools/executor 2.0.3 (execution/validateInputValue),\n * https://github.com/ardatan/graphql-tools\n * Copyright (c) 2020 The Guild, Inc.\n * itself a copy of graphql-js 17's validateInputValue,\n * https://github.com/graphql/graphql-js\n * Copyright (c) GraphQL Contributors\n * @license MIT\n */\n\n// @graphql-tools/executor 2.0.3's copy of graphql 17's `validateInputValue`,\n// the one it runs on each variable, walked over the generated input types:\n// the same problems, at the same paths, in the same order.\nimport {\n\tdeclared,\n\ttype InputType,\n\ttype InputTypes,\n\tprintType,\n\ttype TypeRef,\n} from './document';\nimport { issueAt, type PlacedIssue } from './issues';\nimport {\n\tbuiltinRefusal,\n\tenumRefusal,\n\tobjectRefusal,\n\tscalarRefusal,\n} from './messages';\n\ntype Path = readonly (string | number)[];\ntype InputObject = Extract<InputType, { kind: 'input' }>;\n\n/** One value graphql refuses: where, the value there, and why. */\nexport interface Problem {\n\treadonly path: Path;\n\treadonly value: unknown;\n\treadonly reason: string;\n}\n\n/** What a walk reads, and the problems it found so far. */\nexport interface Walk {\n\treadonly types: InputTypes;\n\treadonly issues: readonly PlacedIssue[];\n\treadonly problems: Problem[];\n}\n\n/** Where a walk stands: graphql's path below the variable, and the Zod schema's. */\ninterface At {\n\treadonly path: Path;\n\t/**\n\t * From the variable's name. It differs from graphql's where a single\n\t * value stands for a list: the schema wraps it (`[0]`), graphql does not.\n\t */\n\treadonly zodPath: Path;\n}\n\n/** Walks `value` at `type`, recording each problem in `walk.problems`. */\nexport function validateValue(\n\twalk: Walk,\n\tvalue: unknown,\n\ttype: TypeRef,\n\tat: At,\n): void {\n\tif (type.kind === 'non-null') {\n\t\tif (value === undefined)\n\t\t\treport(walk, at, value, objectRefusal.notProvided(printType(type)));\n\t\telse if (value === null)\n\t\t\treport(walk, at, value, objectRefusal.isNull(printType(type)));\n\t\telse validateValue(walk, value, type.of, at);\n\t} else if (value === null || value === undefined) {\n\t\t// A nullable type takes null, and an absent field is the object's.\n\t} else if (type.kind === 'list') {\n\t\tvalidateList(walk, value, type.of, at);\n\t} else {\n\t\tvalidateNamed(walk, value, type.name, at);\n\t}\n}\n\nfunction validateList(walk: Walk, value: unknown, item: TypeRef, at: At): void {\n\tif (!Array.isArray(value)) {\n\t\tvalidateValue(walk, value, item, { ...at, zodPath: [...at.zodPath, 0] });\n\t\treturn;\n\t}\n\tvalue.forEach((element, index) => {\n\t\tvalidateValue(walk, element, item, {\n\t\t\tpath: [...at.path, index],\n\t\t\tzodPath: [...at.zodPath, index],\n\t\t});\n\t});\n}\n\n/** The spec scalars, judged as built-ins even when the file omits them. */\nconst BUILT_INS: ReadonlySet<string> = new Set([\n\t'String',\n\t'Int',\n\t'Float',\n\t'Boolean',\n\t'ID',\n]);\n\nfunction validateNamed(walk: Walk, value: unknown, name: string, at: At): void {\n\t// A name the generated file does not describe is judged as a custom\n\t// scalar is: refused only where the Zod schema refused it.\n\tconst named: InputType =\n\t\twalk.types[name] ??\n\t\t(BUILT_INS.has(name) ? { kind: 'builtin' } : { kind: 'scalar' });\n\tif (named.kind === 'input') {\n\t\tvalidateObject(walk, value, name, named, at);\n\t\treturn;\n\t}\n\tconst reason = leafRefusal(walk, value, name, named, at);\n\tif (reason !== undefined) report(walk, at, value, reason);\n}\n\nfunction leafRefusal(\n\twalk: Walk,\n\tvalue: unknown,\n\tname: string,\n\tnamed: Exclude<InputType, InputObject>,\n\tat: At,\n): string | undefined {\n\tswitch (named.kind) {\n\t\tcase 'builtin':\n\t\t\treturn builtinRefusal(name, value);\n\t\tcase 'enum':\n\t\t\treturn enumRefusal(name, named.values, value);\n\t\tcase 'scalar':\n\t\t\treturn scalarRefusal(name, issueAt(walk.issues, at.zodPath));\n\t\tdefault:\n\t\t\t// A kind this runtime does not know: the file was written by\n\t\t\t// another version of the plugin.\n\t\t\tthrow new Error(STALE_FILE);\n\t}\n}\n\n/** Thrown on an input type whose `kind` this runtime does not know. */\nexport const STALE_FILE =\n\t'@nxgt/graphql-codegen-msw: the generated file was written by another version than the runtime; regenerate it';\n\nfunction validateObject(\n\twalk: Walk,\n\tvalue: unknown,\n\tname: string,\n\ttype: InputObject,\n\tat: At,\n): void {\n\tif (typeof value !== 'object' || value === null || Array.isArray(value)) {\n\t\treport(walk, at, value, objectRefusal.notAnObject(name, value));\n\t\treturn;\n\t}\n\tconst object = value as Record<string, unknown>;\n\tfor (const [field, source] of Object.entries(type.fields)) {\n\t\tconst { type: fieldType, hasDefault } = declared(source);\n\t\tconst fieldValue = Object.hasOwn(object, field) ? object[field] : undefined;\n\t\tif (fieldValue !== undefined)\n\t\t\tvalidateValue(walk, fieldValue, fieldType, {\n\t\t\t\tpath: [...at.path, field],\n\t\t\t\tzodPath: [...at.zodPath, field],\n\t\t\t});\n\t\telse if (fieldType.kind === 'non-null' && !hasDefault)\n\t\t\treport(walk, at, object, objectRefusal.missingField(name, field, object));\n\t}\n\tconst names = Object.keys(type.fields);\n\tconst known: string[] = [];\n\tfor (const key of Object.keys(object)) {\n\t\tif (object[key] === undefined) continue;\n\t\tif (Object.hasOwn(type.fields, key)) known.push(key);\n\t\telse\n\t\t\treport(\n\t\t\t\twalk,\n\t\t\t\tat,\n\t\t\t\tobject,\n\t\t\t\tobjectRefusal.unknownField(name, key, names, object),\n\t\t\t);\n\t}\n\tif (type.oneOf) validateOneOf(walk, object, name, known, at);\n}\n\n/** A `@oneOf` input object: exactly one field, and not null. */\nfunction validateOneOf(\n\twalk: Walk,\n\tobject: Record<string, unknown>,\n\tname: string,\n\tknown: readonly string[],\n\tat: At,\n): void {\n\tconst [only] = known;\n\tif (known.length !== 1 || only === undefined)\n\t\treport(walk, at, object, objectRefusal.oneOf(name));\n\telse if (object[only] === null)\n\t\treport(\n\t\t\twalk,\n\t\t\t{ ...at, path: [...at.path, only] },\n\t\t\tobject,\n\t\t\tobjectRefusal.oneOf(name),\n\t\t);\n}\n\nfunction report(walk: Walk, at: At, value: unknown, reason: string): void {\n\twalk.problems.push({ path: at.path, value, reason });\n}\n",
15
+ "import type { GraphQLError, GraphQLFormattedError } from 'graphql';\nimport { HttpResponse } from 'msw';\n\n/** An error as a resolver throws it, or as it goes on the wire. */\nexport type AnyGraphQLError = GraphQLError | GraphQLFormattedError;\n\n/**\n * Whether `value` is a `GraphQLError`, from any copy of `graphql`: by its\n * name (or its `[object GraphQLError]` tag, which a subclass with its own\n * `name` keeps) and its `toJSON`, never `instanceof`, so an error your\n * application built with its own `graphql` is one too.\n */\nexport function isGraphQLError(value: unknown): value is GraphQLError {\n\treturn (\n\t\tvalue instanceof Error &&\n\t\t(value.name === 'GraphQLError' ||\n\t\t\tObject.prototype.toString.call(value) === '[object GraphQLError]') &&\n\t\ttypeof (value as { toJSON?: unknown }).toJSON === 'function'\n\t);\n}\n\n/**\n * `error` as the response carries it: a `GraphQLError`'s `toJSON()`, or\n * itself, without `extensions.http` and `extensions.unexpected`, which\n * graphql-yoga keeps for itself and never sends (an `extensions` left empty\n * goes too).\n */\nexport function formatted(error: AnyGraphQLError): GraphQLFormattedError {\n\tconst json = isGraphQLError(error) ? error.toJSON() : error;\n\tconst { extensions, ...rest } = json;\n\tif (extensions === undefined) return json;\n\tconst { http: _http, unexpected: _unexpected, ...kept } = extensions;\n\treturn Object.keys(kept).length > 0 ? { ...rest, extensions: kept } : rest;\n}\n\n/**\n * `status` when a response can carry it: an integer from 200 to 599 other\n * than 204, 205 and 304, which have no body.\n */\nfunction validStatus(status: unknown): number | undefined {\n\treturn typeof status === 'number' &&\n\t\tNumber.isInteger(status) &&\n\t\tstatus >= 200 &&\n\t\tstatus <= 599 &&\n\t\tstatus !== 204 &&\n\t\tstatus !== 205 &&\n\t\tstatus !== 304\n\t\t? status\n\t\t: undefined;\n}\n\n/** `extensions.http.status`, when it is a status a response can carry. */\nexport function statusOf(error: AnyGraphQLError): number | undefined {\n\tconst http = (error.extensions as { http?: { status?: unknown } } | undefined)\n\t\t?.http;\n\treturn validStatus(http?.status);\n}\n\n/**\n * A GraphQL response holding `errors` only, as graphql-yoga answers one:\n * `{ errors }`, each error without its `extensions.http` (see `formatted`),\n * at `status` when a response can carry it, else the highest\n * `extensions.http.status` among the errors, else 200. What a resolver\n * returns to refuse, as your server would:\n * `return errorResponse(fieldsError('conflict', fields, { status: 409 }))`.\n */\nexport function errorResponse(\n\terror: AnyGraphQLError | readonly AnyGraphQLError[],\n\tinit: { readonly status?: number } = {},\n): HttpResponse<{ errors: GraphQLFormattedError[] }> {\n\tconst errors = (Array.isArray(error) ? error : [error]) as AnyGraphQLError[];\n\tconst statuses = errors\n\t\t.map(statusOf)\n\t\t.filter((status) => status !== undefined);\n\tconst status =\n\t\tvalidStatus(init.status) ??\n\t\t(statuses.length > 0 ? Math.max(...statuses) : 200);\n\treturn HttpResponse.json({ errors: errors.map(formatted) }, { status });\n}\n",
16
+ "import {\n\tbadUserInput,\n\tfieldIssueOf,\n\tinvalidInputError,\n\ttype Translate,\n} from '@nxgt/graphql-validation';\nimport { z } from 'zod';\nimport type { AnyGraphQLError } from './response';\n\n/** The operation whose variables were refused. */\nexport interface RefusedOperation {\n\treadonly type: 'query' | 'mutation';\n\t/** The operation's name in the document: `SignUp`. */\n\treadonly name: string;\n}\n\n/** What an invalid input is answered with: the one error, and the HTTP status. */\nexport interface InvalidInputAnswer {\n\treadonly error: AnyGraphQLError;\n\treadonly status: number;\n}\n\n/**\n * Answers an invalid input: the issues of the variables' Zod schema (each\n * `path` starting with the variable's name) and the operation, to the error\n * and status the handler responds with. The resolver is not called.\n */\nexport type InvalidInput = (\n\tissues: readonly z.core.$ZodIssue[],\n\toperation: RefusedOperation,\n) => InvalidInputAnswer | Promise<InvalidInputAnswer>;\n\n/**\n * The default answer: `invalidInputError`'s one 400 error, its `fields` the\n * issues in order through `fieldIssueOf` (`@nxgt/graphql-validation`'s),\n * each message `translate(code)`, or the code without a translator.\n */\nexport function invalidInputRefusal(\n\toptions: { readonly translate?: Translate } = {},\n): InvalidInput {\n\tconst { translate } = options;\n\treturn (issues) => ({\n\t\terror: invalidInputError(\n\t\t\tissues.map(fieldIssueOf),\n\t\t\ttranslate ? { translate } : {},\n\t\t),\n\t\tstatus: 400,\n\t});\n}\n\n/**\n * The answer `withValidation` gives: one `BAD_USER_INPUT` error,\n * `Invalid arguments for <operation>. <path>: <first message>`, its\n * `extensions.issues` each with its path inside the variables; status 200,\n * as a GraphQL server answers a resolver's error.\n */\nexport const badUserInputRefusal: InvalidInput = (issues, operation) => ({\n\terror: badUserInput(operation.name, new z.ZodError([...issues])),\n\tstatus: 200,\n});\n"
17
+ ],
18
+ "m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1,65 @@
1
+ import type { Path, RequestHandlerOptions, ResponseResolverInfo, ResponseResolverReturnType } from 'msw';
2
+ import { type GraphQLHandler, type GraphQLQuery, type GraphQLResponseBody, type GraphQLVariables } from 'msw/graphql';
3
+ import type { z } from 'zod';
4
+ import { type InputTypes } from './coercion/index.js';
5
+ import type { InvalidInput } from './refusals.js';
6
+ /**
7
+ * What a resolver receives: msw's own resolver info for a GraphQL
8
+ * operation (`variables`, `query`, `operationName`, `request`, `cookies`,
9
+ * `requestId`, `finalize`), `variables` typed with the operation's
10
+ * variables type. They are the variables as sent: checked, not parsed.
11
+ */
12
+ export type GraphQLMockInfo<Variables extends GraphQLVariables> = ResponseResolverInfo<{
13
+ query: string;
14
+ operationName: string;
15
+ variables: Variables;
16
+ cookies: Record<string, string>;
17
+ }>;
18
+ /**
19
+ * A handler's resolver, as msw's `graphql.link(...).query(name, resolver)`
20
+ * takes one, without its generator form: return
21
+ * `HttpResponse.json({ data })`, an `errorResponse(...)`, or nothing to
22
+ * let the next handler answer; throw a `GraphQLError` to answer with it.
23
+ */
24
+ export type GraphQLMockResolver<Result extends GraphQLQuery, Variables extends GraphQLVariables> = (info: GraphQLMockInfo<Variables>) => ResponseResolverReturnType<GraphQLResponseBody<Result>> | Promise<ResponseResolverReturnType<GraphQLResponseBody<Result>>>;
25
+ /** A handler's options: msw's (`once`), and an endpoint for this handler only. */
26
+ export interface MockOptions extends RequestHandlerOptions {
27
+ /** Overrides the generated `endpoint` for this handler: a URL or a path msw matches. */
28
+ readonly endpoint?: Path;
29
+ }
30
+ /** One operation, as the generated file describes it. */
31
+ export interface MockedOperation {
32
+ readonly type: 'query' | 'mutation';
33
+ /** The operation's name in the document: `SignUp`. */
34
+ readonly name: string;
35
+ /** The variables' schema, from `@nxgt/graphql-codegen-zod`: `zSignUpMutationVariables`. */
36
+ readonly variables: z.ZodType;
37
+ /**
38
+ * Each variable's GraphQL type, with its default: `{ first: "Int = 10" }`.
39
+ * Internal: written by the plugin for the coercion answer, its form may
40
+ * change in any version together with the generated file. Defaults to
41
+ * `{}`: no variable is walked, and every refusal goes to `invalidInput`.
42
+ */
43
+ readonly variableTypes?: Readonly<Record<string, string>> | undefined;
44
+ /**
45
+ * The input types the variables reach, from the schema. Internal, as
46
+ * `variableTypes`; defaults to `{}`.
47
+ */
48
+ readonly inputTypes?: InputTypes | undefined;
49
+ readonly endpoint: Path;
50
+ readonly invalidInput: InvalidInput;
51
+ }
52
+ /**
53
+ * An msw handler for one operation: `graphql.link(endpoint)`'s `query` or
54
+ * `mutation` by the operation's name. Its variables are checked with the
55
+ * operation's schema first, without calling `resolver` when they fail: a
56
+ * value graphql refuses while coercing the variables (missing, null, of
57
+ * the wrong type, an unknown enum value or field, an Int beyond 32 bits, a
58
+ * value a custom scalar refuses) is answered as graphql-yoga answers it
59
+ * (`coercionErrors`, status 400), whatever `invalidInput` is; any other
60
+ * invalid input with `invalidInput`'s error and status. A `GraphQLError`
61
+ * the resolver throws is answered as `errorResponse` answers it; anything
62
+ * else it throws is msw's to answer (a 500).
63
+ */
64
+ export declare function mockOperation<Result extends GraphQLQuery, Variables extends GraphQLVariables>(operation: MockedOperation, resolver: GraphQLMockResolver<Result, Variables>, options?: MockOptions): GraphQLHandler;
65
+ //# sourceMappingURL=mock-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-operation.d.ts","sourceRoot":"","sources":["../../src/runtime/mock-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,IAAI,EACJ,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,MAAM,KAAK,CAAC;AACb,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAErB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAmC,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,KAAK,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AWG;AACH,wBAAgB,aAAa,CAC5B,MAAM,SAAS,YAAY,EAC3B,SAAS,SAAS,gBAAgB,EAElC,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,mBAAmB,CAAC,MAAM,EAAE,SAAS,CAAC,EAChD,OAAO,GAAE,WAAgB,GACvB,cAAc,CA+BhB"}
@@ -0,0 +1,36 @@
1
+ import { type Translate } from '@nxgt/graphql-validation';
2
+ import { z } from 'zod';
3
+ import type { AnyGraphQLError } from './response.js';
4
+ /** The operation whose variables were refused. */
5
+ export interface RefusedOperation {
6
+ readonly type: 'query' | 'mutation';
7
+ /** The operation's name in the document: `SignUp`. */
8
+ readonly name: string;
9
+ }
10
+ /** What an invalid input is answered with: the one error, and the HTTP status. */
11
+ export interface InvalidInputAnswer {
12
+ readonly error: AnyGraphQLError;
13
+ readonly status: number;
14
+ }
15
+ /**
16
+ * Answers an invalid input: the issues of the variables' Zod schema (each
17
+ * `path` starting with the variable's name) and the operation, to the error
18
+ * and status the handler responds with. The resolver is not called.
19
+ */
20
+ export type InvalidInput = (issues: readonly z.core.$ZodIssue[], operation: RefusedOperation) => InvalidInputAnswer | Promise<InvalidInputAnswer>;
21
+ /**
22
+ * The default answer: `invalidInputError`'s one 400 error, its `fields` the
23
+ * issues in order through `fieldIssueOf` (`@nxgt/graphql-validation`'s),
24
+ * each message `translate(code)`, or the code without a translator.
25
+ */
26
+ export declare function invalidInputRefusal(options?: {
27
+ readonly translate?: Translate;
28
+ }): InvalidInput;
29
+ /**
30
+ * The answer `withValidation` gives: one `BAD_USER_INPUT` error,
31
+ * `Invalid arguments for <operation>. <path>: <first message>`, its
32
+ * `extensions.issues` each with its path inside the variables; status 200,
33
+ * as a GraphQL server answers a resolver's error.
34
+ */
35
+ export declare const badUserInputRefusal: InvalidInput;
36
+ //# sourceMappingURL=refusals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusals.d.ts","sourceRoot":"","sources":["../../src/runtime/refusals.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IACpC,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,kFAAkF;AAClF,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAC1B,MAAM,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,EACnC,SAAS,EAAE,gBAAgB,KACvB,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,GAAE;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAO,GAC9C,YAAY,CASd;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAGhC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { GraphQLError, GraphQLFormattedError } from 'graphql';
2
+ import { HttpResponse } from 'msw';
3
+ /** An error as a resolver throws it, or as it goes on the wire. */
4
+ export type AnyGraphQLError = GraphQLError | GraphQLFormattedError;
5
+ /**
6
+ * Whether `value` is a `GraphQLError`, from any copy of `graphql`: by its
7
+ * name (or its `[object GraphQLError]` tag, which a subclass with its own
8
+ * `name` keeps) and its `toJSON`, never `instanceof`, so an error your
9
+ * application built with its own `graphql` is one too.
10
+ */
11
+ export declare function isGraphQLError(value: unknown): value is GraphQLError;
12
+ /**
13
+ * `error` as the response carries it: a `GraphQLError`'s `toJSON()`, or
14
+ * itself, without `extensions.http` and `extensions.unexpected`, which
15
+ * graphql-yoga keeps for itself and never sends (an `extensions` left empty
16
+ * goes too).
17
+ */
18
+ export declare function formatted(error: AnyGraphQLError): GraphQLFormattedError;
19
+ /** `extensions.http.status`, when it is a status a response can carry. */
20
+ export declare function statusOf(error: AnyGraphQLError): number | undefined;
21
+ /**
22
+ * A GraphQL response holding `errors` only, as graphql-yoga answers one:
23
+ * `{ errors }`, each error without its `extensions.http` (see `formatted`),
24
+ * at `status` when a response can carry it, else the highest
25
+ * `extensions.http.status` among the errors, else 200. What a resolver
26
+ * returns to refuse, as your server would:
27
+ * `return errorResponse(fieldsError('conflict', fields, { status: 409 }))`.
28
+ */
29
+ export declare function errorResponse(error: AnyGraphQLError | readonly AnyGraphQLError[], init?: {
30
+ readonly status?: number;
31
+ }): HttpResponse<{
32
+ errors: GraphQLFormattedError[];
33
+ }>;
34
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/runtime/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAEnC,mEAAmE;AACnE,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,qBAAqB,CAAC;AAEnE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAOpE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,eAAe,GAAG,qBAAqB,CAMvE;AAkBD,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAInE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC5B,KAAK,EAAE,eAAe,GAAG,SAAS,eAAe,EAAE,EACnD,IAAI,GAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GACrC,YAAY,CAAC;IAAE,MAAM,EAAE,qBAAqB,EAAE,CAAA;CAAE,CAAC,CASnD"}
package/docs/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # @nxgt/graphql-codegen-msw documentation
2
+
3
+ ## Guides
4
+
5
+ | Page | Read it when |
6
+ | --- | --- |
7
+ | [Handlers](guide/handlers.md) | you want to know what the plugin writes: the handlers, where their types and schemas come from, naming, the endpoint, the resolver, how an invalid input is answered (`invalid-input`, `bad-user-input`, your own), tests under Node and Bun, and the runtime |
8
+
9
+ ## Reference
10
+
11
+ | Page | Read it when |
12
+ | --- | --- |
13
+ | [Troubleshooting](troubleshooting.md) | you have an error message and want its cause |
14
+ | [Roadmap](roadmap.md) | you want to know what is coming, and what is not |