@znight/graphql 0.0.0 → 0.2.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 (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1063 -0
  3. package/dist/compiler.d.mts +93 -0
  4. package/dist/compiler.mjs +2832 -0
  5. package/dist/compiler.mjs.map +1 -0
  6. package/dist/index.d.mts +542 -0
  7. package/dist/index.mjs +128 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/dist/names-BlzDM5cF.mjs +111 -0
  10. package/dist/names-BlzDM5cF.mjs.map +1 -0
  11. package/dist/plugin-BdBxr5NQ.mjs +3222 -0
  12. package/dist/plugin-BdBxr5NQ.mjs.map +1 -0
  13. package/dist/testing.d.mts +101 -0
  14. package/dist/testing.mjs +306 -0
  15. package/dist/testing.mjs.map +1 -0
  16. package/dist/types-CgbV9LjD.d.mts +234 -0
  17. package/package.json +97 -1
  18. package/src/compiler/analyze.ts +608 -0
  19. package/src/compiler/builder.ts +1640 -0
  20. package/src/compiler/constants.ts +74 -0
  21. package/src/compiler/data.ts +73 -0
  22. package/src/compiler/defaults.ts +92 -0
  23. package/src/compiler/discriminators.ts +53 -0
  24. package/src/compiler/docs.ts +55 -0
  25. package/src/compiler/generate.ts +405 -0
  26. package/src/compiler/ids.ts +128 -0
  27. package/src/compiler/index.ts +93 -0
  28. package/src/compiler/locate.ts +44 -0
  29. package/src/compiler/model.ts +122 -0
  30. package/src/compiler/options.ts +54 -0
  31. package/src/compiler/scalars.ts +138 -0
  32. package/src/compiler/sdl-view.ts +59 -0
  33. package/src/context.ts +181 -0
  34. package/src/decisions.ts +169 -0
  35. package/src/decorators.ts +196 -0
  36. package/src/errors.ts +89 -0
  37. package/src/execution.ts +1064 -0
  38. package/src/format.ts +285 -0
  39. package/src/index.ts +84 -0
  40. package/src/limits.ts +177 -0
  41. package/src/loaders.ts +149 -0
  42. package/src/memory-pubsub.ts +133 -0
  43. package/src/metadata.ts +195 -0
  44. package/src/names.ts +47 -0
  45. package/src/options.ts +309 -0
  46. package/src/pipeline.ts +277 -0
  47. package/src/plugin.ts +557 -0
  48. package/src/pubsub.ts +36 -0
  49. package/src/scalars.ts +131 -0
  50. package/src/schema-hash.ts +18 -0
  51. package/src/schema.ts +557 -0
  52. package/src/sdl.ts +515 -0
  53. package/src/testing.ts +454 -0
  54. package/src/tokens.ts +22 -0
  55. package/src/transport/abort.ts +80 -0
  56. package/src/transport/accept.ts +155 -0
  57. package/src/transport/graphiql.ts +106 -0
  58. package/src/transport/http.ts +373 -0
  59. package/src/transport/sse.ts +45 -0
  60. package/src/type-ref.ts +89 -0
  61. package/src/types.ts +190 -0
  62. package/src/validate-args.ts +48 -0
@@ -0,0 +1,93 @@
1
+ import { Scope } from "@znight/core";
2
+ import { MetaEntry } from "@znight/http/compiler";
3
+ import { BindingHandle, ClassInfo, ClassRef, CompilerExtension, Location, ValueRef } from "@znight/compiler";
4
+ /** Kind of field a resolver method provides. */
5
+ type FieldOperation = "query" | "mutation" | "subscription" | "field";
6
+ /** A `@Resolver` class. */
7
+ interface ResolverData {
8
+ readonly kind: "resolver";
9
+ /** The resolver class; its identity is the provider token. */
10
+ readonly host: ClassInfo;
11
+ readonly scope: Scope;
12
+ /** Location of `@Resolver`. */
13
+ readonly location: Location;
14
+ /** Class `@UseGuard` guards. */
15
+ readonly guards: readonly ClassRef[];
16
+ /** One entry per field decorator of the class's methods, in source order. */
17
+ readonly fields: readonly FieldData[];
18
+ }
19
+ /** One `@Query`, `@Mutation`, `@Subscription` or `@ResolveField` decorator. */
20
+ interface FieldData {
21
+ /** Method name. */
22
+ readonly method: string;
23
+ readonly operation: FieldOperation;
24
+ /** GraphQL field name (decorator argument, or the method name). */
25
+ readonly name: string;
26
+ /** Location of the field decorator. */
27
+ readonly location: Location;
28
+ /** Location of the method name. */
29
+ readonly methodLocation: Location;
30
+ /** Method `@UseGuard` guards (class guards are on {@link ResolverData.guards}). */
31
+ readonly guards: readonly ClassRef[];
32
+ /** Effective route metadata: the class entries a method decision does not replace, then the method's. */
33
+ readonly meta: readonly MetaEntry[];
34
+ /** One entry per method parameter, by index (`undefined`: the parameter could not be analysed). */
35
+ readonly params: readonly (ParamData | undefined)[];
36
+ /** `false` when a parameter or the method could not be analysed (an error was reported). */
37
+ readonly complete: boolean;
38
+ }
39
+ /** What a method parameter receives (§7.3). */
40
+ type ParamData = {
41
+ readonly kind: "args";
42
+ /** `@Args('name')`: one argument; `undefined`: the properties of the type are the arguments. */
43
+ readonly name: string | undefined;
44
+ /** `@Args(..., Schema)`: the Standard Schema validating the value. */
45
+ readonly schema: ValueRef | undefined;
46
+ readonly location: Location;
47
+ } | {
48
+ readonly kind: "parent";
49
+ readonly location: Location;
50
+ } | {
51
+ readonly kind: "ctx";
52
+ } | {
53
+ readonly kind: "info";
54
+ } | {
55
+ readonly kind: "loader";
56
+ /** Binding of the loader provider (lazy edge from the resolver). */
57
+ readonly binding: BindingHandle;
58
+ /** Identity of `L` in `Loader<L>`. */
59
+ readonly identity: string;
60
+ readonly location: Location;
61
+ };
62
+ /** Everything the extension stores. */
63
+ type GraphQLData = ResolverData;
64
+ /**
65
+ * Options of the compiler extension (RFC 0005 §6.7), given with `graphql.configure({ ... })` in
66
+ * `znight.config.ts`. Import-free.
67
+ */
68
+ /** Options of `graphql.configure()`. */
69
+ interface GraphQLCompilerOptions {
70
+ /**
71
+ * Path of the SDL artifact, relative to the project root (`'schema.graphql'`), written next to the
72
+ * generated module and checked by `znight generate --check`. Default `false`: no file.
73
+ */
74
+ readonly sdl?: string | false;
75
+ /** GraphQL type of `number`. Default `'Float'`; `'Int'` suits counts and identifiers. */
76
+ readonly number?: "Float" | "Int";
77
+ }
78
+ /** {@link GraphQLCompilerOptions} with their defaults. */
79
+ interface ResolvedGraphQLCompilerOptions {
80
+ readonly sdl: string | false;
81
+ readonly number: "Float" | "Int";
82
+ }
83
+ /** The `@znight/graphql` compiler extension, with its options and `configure()`. */
84
+ export interface GraphQLCompilerExtension extends CompilerExtension<GraphQLData> {
85
+ /** The options of this copy (defaults filled in). */
86
+ readonly options: ResolvedGraphQLCompilerOptions;
87
+ /** A copy of the extension with `options` merged onto the options of this one. */
88
+ configure(options: GraphQLCompilerOptions): GraphQLCompilerExtension;
89
+ }
90
+ /** The `@znight/graphql` compiler extension with its default options. */
91
+ export declare const graphqlCompilerExtension: GraphQLCompilerExtension;
92
+ export { type FieldData, type FieldOperation, type GraphQLCompilerOptions, type GraphQLData, type ParamData, type ResolvedGraphQLCompilerOptions, type ResolverData, graphqlCompilerExtension as default };
93
+ //# sourceMappingURL=compiler.d.mts.map