graphql-jit 0.8.9 → 0.9.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.
- package/README.md +25 -0
- package/dist/cjs/ast.d.ts +89 -0
- package/dist/cjs/ast.js +766 -0
- package/dist/cjs/ast.js.map +1 -0
- package/dist/cjs/compat.d.ts +70 -0
- package/dist/cjs/compat.js +144 -0
- package/dist/cjs/compat.js.map +1 -0
- package/dist/cjs/debug.d.ts +29 -0
- package/dist/cjs/debug.js +46 -0
- package/dist/cjs/debug.js.map +1 -0
- package/dist/cjs/error.d.ts +7 -0
- package/dist/cjs/error.js +58 -0
- package/dist/cjs/error.js.map +1 -0
- package/dist/cjs/execution.d.ts +154 -0
- package/dist/cjs/execution.js +1240 -0
- package/dist/cjs/execution.js.map +1 -0
- package/dist/cjs/generate.d.ts +4 -0
- package/dist/cjs/generate.js +13 -0
- package/dist/cjs/generate.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +10 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/inspect.d.ts +5 -0
- package/dist/cjs/inspect.js +110 -0
- package/dist/cjs/inspect.js.map +1 -0
- package/dist/cjs/json.d.ts +9 -0
- package/dist/cjs/json.js +144 -0
- package/dist/cjs/json.js.map +1 -0
- package/dist/cjs/memoize.d.ts +5 -0
- package/dist/cjs/memoize.js +28 -0
- package/dist/cjs/memoize.js.map +1 -0
- package/dist/cjs/non-null.d.ts +9 -0
- package/dist/cjs/non-null.js +205 -0
- package/dist/cjs/non-null.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/{resolve-info.d.ts → cjs/resolve-info.d.ts} +10 -12
- package/dist/cjs/resolve-info.js +232 -0
- package/dist/cjs/resolve-info.js.map +1 -0
- package/dist/cjs/runtime.d.ts +14 -0
- package/dist/cjs/runtime.js +92 -0
- package/dist/cjs/runtime.js.map +1 -0
- package/dist/cjs/types.d.ts +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/variables.d.ts +20 -0
- package/dist/cjs/variables.js +357 -0
- package/dist/cjs/variables.js.map +1 -0
- package/dist/esm/ast.d.ts +89 -0
- package/dist/esm/ast.js +751 -0
- package/dist/esm/ast.js.map +1 -0
- package/dist/esm/compat.d.ts +70 -0
- package/dist/esm/compat.js +102 -0
- package/dist/esm/compat.js.map +1 -0
- package/dist/esm/debug.d.ts +29 -0
- package/dist/esm/debug.js +40 -0
- package/dist/esm/debug.js.map +1 -0
- package/dist/esm/error.d.ts +7 -0
- package/dist/esm/error.js +55 -0
- package/dist/esm/error.js.map +1 -0
- package/dist/esm/execution.d.ts +154 -0
- package/dist/esm/execution.js +1227 -0
- package/dist/esm/execution.js.map +1 -0
- package/dist/esm/generate.d.ts +4 -0
- package/dist/esm/generate.js +10 -0
- package/dist/esm/generate.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/inspect.d.ts +5 -0
- package/dist/esm/inspect.js +106 -0
- package/dist/esm/inspect.js.map +1 -0
- package/dist/esm/json.d.ts +9 -0
- package/dist/esm/json.js +141 -0
- package/dist/esm/json.js.map +1 -0
- package/dist/esm/memoize.d.ts +5 -0
- package/dist/esm/memoize.js +20 -0
- package/dist/esm/memoize.js.map +1 -0
- package/dist/esm/non-null.d.ts +9 -0
- package/dist/esm/non-null.js +199 -0
- package/dist/esm/non-null.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/{resolve-info.d.mts → esm/resolve-info.d.ts} +10 -12
- package/dist/esm/resolve-info.js +224 -0
- package/dist/esm/resolve-info.js.map +1 -0
- package/dist/esm/runtime.d.ts +14 -0
- package/dist/esm/runtime.js +89 -0
- package/dist/esm/runtime.js.map +1 -0
- package/dist/esm/types.d.ts +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/variables.d.ts +20 -0
- package/dist/esm/variables.js +350 -0
- package/dist/esm/variables.js.map +1 -0
- package/package.json +39 -35
- package/dist/ast.d.mts +0 -7
- package/dist/ast.d.ts +0 -7
- package/dist/ast.js +0 -635
- package/dist/ast.js.map +0 -1
- package/dist/ast.mjs +0 -612
- package/dist/ast.mjs.map +0 -1
- package/dist/compat.d.mts +0 -7
- package/dist/compat.d.ts +0 -7
- package/dist/compat.js +0 -113
- package/dist/compat.js.map +0 -1
- package/dist/compat.mjs +0 -75
- package/dist/compat.mjs.map +0 -1
- package/dist/error.d.mts +0 -11
- package/dist/error.d.ts +0 -11
- package/dist/error.js +0 -79
- package/dist/error.js.map +0 -1
- package/dist/error.mjs +0 -57
- package/dist/error.mjs.map +0 -1
- package/dist/execution.d.mts +0 -7
- package/dist/execution.d.ts +0 -7
- package/dist/execution.js +0 -1262
- package/dist/execution.js.map +0 -1
- package/dist/execution.mjs +0 -1248
- package/dist/execution.mjs.map +0 -1
- package/dist/generate.d.mts +0 -6
- package/dist/generate.d.ts +0 -6
- package/dist/generate.js +0 -37
- package/dist/generate.js.map +0 -1
- package/dist/generate.mjs +0 -13
- package/dist/generate.mjs.map +0 -1
- package/dist/index-CeluTkd4.d.mts +0 -329
- package/dist/index-mKv2zpdA.d.ts +0 -329
- package/dist/index.d.mts +0 -7
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -36
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -15
- package/dist/index.mjs.map +0 -1
- package/dist/inspect.d.mts +0 -7
- package/dist/inspect.d.ts +0 -7
- package/dist/inspect.js +0 -121
- package/dist/inspect.js.map +0 -1
- package/dist/inspect.mjs +0 -97
- package/dist/inspect.mjs.map +0 -1
- package/dist/json.d.mts +0 -18
- package/dist/json.d.ts +0 -18
- package/dist/json.js +0 -181
- package/dist/json.js.map +0 -1
- package/dist/json.mjs +0 -164
- package/dist/json.mjs.map +0 -1
- package/dist/memoize.d.mts +0 -6
- package/dist/memoize.d.ts +0 -6
- package/dist/memoize.js +0 -67
- package/dist/memoize.js.map +0 -1
- package/dist/memoize.mjs +0 -31
- package/dist/memoize.mjs.map +0 -1
- package/dist/non-null.d.mts +0 -7
- package/dist/non-null.d.ts +0 -7
- package/dist/non-null.js +0 -196
- package/dist/non-null.js.map +0 -1
- package/dist/non-null.mjs +0 -167
- package/dist/non-null.mjs.map +0 -1
- package/dist/resolve-info.js +0 -245
- package/dist/resolve-info.js.map +0 -1
- package/dist/resolve-info.mjs +0 -219
- package/dist/resolve-info.mjs.map +0 -1
- package/dist/runtime.d.mts +0 -7
- package/dist/runtime.d.ts +0 -7
- package/dist/runtime.js +0 -115
- package/dist/runtime.js.map +0 -1
- package/dist/runtime.mjs +0 -91
- package/dist/runtime.mjs.map +0 -1
- package/dist/types.d.mts +0 -3
- package/dist/types.d.ts +0 -3
- package/dist/types.js +0 -17
- package/dist/types.js.map +0 -1
- package/dist/types.mjs +0 -1
- package/dist/types.mjs.map +0 -1
- package/dist/variables.d.mts +0 -17
- package/dist/variables.d.ts +0 -17
- package/dist/variables.js +0 -412
- package/dist/variables.js.map +0 -1
- package/dist/variables.mjs +0 -391
- package/dist/variables.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -123,6 +123,31 @@ Compiles the `document` AST, using an optional operationName and compiler option
|
|
|
123
123
|
- `customSerializers` {Object as Map, default: {}} - Replace serializer functions for specific types. Can be used as a safer alternative
|
|
124
124
|
for overly expensive serializers
|
|
125
125
|
- `customJSONSerializer` {boolean, default: false} - Whether to produce also a JSON serializer function using `fast-json-stringify`. The default stringifier function is `JSON.stringify`
|
|
126
|
+
- `debug` {object, optional} - Publishes formatted generated executors as virtual JavaScript sources. This is intended for local development.
|
|
127
|
+
- `enabled` {boolean, required} - Enables all debug-only work. Set this to `false` to skip formatting and generated-source changes.
|
|
128
|
+
- `querySourceName` {string, optional} - A stable name for the generated query source, such as `graphql-jit://graphql-jit/my-service/GetProduct.query.js`.
|
|
129
|
+
- `variablesSourceName` {string, optional} - A stable name for the generated variable-coercion source, such as `graphql-jit://graphql-jit/my-service/GetProduct.variables.js`.
|
|
130
|
+
- `formatSourceCode` {(source: string) => string, optional} - A synchronous formatter that runs before compilation. e.g. `@prettier/sync`.
|
|
131
|
+
|
|
132
|
+
### Debugging generated executors
|
|
133
|
+
|
|
134
|
+
Start Node with `--inspect` and enable `debug` for the operation being investigated:
|
|
135
|
+
|
|
136
|
+
```js
|
|
137
|
+
const { format } = require("@prettier/sync");
|
|
138
|
+
|
|
139
|
+
const compiledQuery = compileQuery(schema, document, "GetProduct", {
|
|
140
|
+
debug: {
|
|
141
|
+
enabled: true,
|
|
142
|
+
querySourceName: "graphql-jit://graphql-jit/shop/GetProduct.query.js",
|
|
143
|
+
variablesSourceName:
|
|
144
|
+
"graphql-jit://graphql-jit/shop/GetProduct.variables.js",
|
|
145
|
+
formatSourceCode: (source) => format(source, { parser: "babel" })
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The debugger exposes separate query and variable-coercion scripts. Set breakpoints directly in those generated JavaScript sources.
|
|
126
151
|
|
|
127
152
|
#### compiledQuery.query(root: any, context: any, variables: Maybe<{ [key: string]: any }>)
|
|
128
153
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type ArgumentNode, type ASTNode, type DirectiveNode, type FieldNode, type GraphQLArgument, GraphQLDirective, type GraphQLField, type GraphQLInputType, GraphQLObjectType, type SelectionSetNode, type SourceLocation, type ValueNode, type VariableNode } from "graphql";
|
|
2
|
+
import { type CompilationContext } from "./execution.js";
|
|
3
|
+
import { resolveFieldDef } from "./compat.js";
|
|
4
|
+
export interface JitFieldNode extends FieldNode {
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use __internalShouldIncludePath instead
|
|
7
|
+
* @see __internalShouldIncludePath
|
|
8
|
+
*/
|
|
9
|
+
__internalShouldInclude?: string[];
|
|
10
|
+
__internalShouldIncludePath?: {
|
|
11
|
+
[path: string]: string[];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface FieldsAndNodes {
|
|
15
|
+
[key: string]: JitFieldNode[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Given a selectionSet, adds all of the fields in that selection to
|
|
19
|
+
* the passed in map of fields, and returns it at the end.
|
|
20
|
+
*
|
|
21
|
+
* CollectFields requires the "runtime type" of an object. For a field which
|
|
22
|
+
* returns an Interface or Union type, the "runtime type" will be the actual
|
|
23
|
+
* Object type returned by that field.
|
|
24
|
+
*/
|
|
25
|
+
export declare function collectFields(compilationContext: CompilationContext, runtimeType: GraphQLObjectType, selectionSet: SelectionSetNode, fields: FieldsAndNodes, visitedFragmentNames: {
|
|
26
|
+
[key: string]: boolean;
|
|
27
|
+
}, parentResponsePath?: ObjectPath): FieldsAndNodes;
|
|
28
|
+
export { resolveFieldDef };
|
|
29
|
+
export declare function collectSubfields(compilationContext: CompilationContext, returnType: GraphQLObjectType, fieldNodes: FieldNode[], parentResponsePath?: ObjectPath): {
|
|
30
|
+
[key: string]: FieldNode[];
|
|
31
|
+
};
|
|
32
|
+
type ResponsePathType = "variable" | "literal" | "meta";
|
|
33
|
+
export interface ObjectPath {
|
|
34
|
+
prev: ObjectPath | undefined;
|
|
35
|
+
key: string;
|
|
36
|
+
type: ResponsePathType;
|
|
37
|
+
}
|
|
38
|
+
interface MissingVariablePath {
|
|
39
|
+
valueNode: VariableNode;
|
|
40
|
+
path?: ObjectPath;
|
|
41
|
+
argument?: {
|
|
42
|
+
definition: GraphQLArgument;
|
|
43
|
+
node: ArgumentNode;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface Arguments {
|
|
47
|
+
values: {
|
|
48
|
+
[argument: string]: any;
|
|
49
|
+
};
|
|
50
|
+
missing: MissingVariablePath[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Prepares an object map of argument values given a list of argument
|
|
54
|
+
* definitions and list of argument AST nodes.
|
|
55
|
+
*
|
|
56
|
+
* Note: The returned value is a plain Object with a prototype, since it is
|
|
57
|
+
* exposed to user code. Care should be taken to not pull values from the
|
|
58
|
+
* Object prototype.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getArgumentDefs(def: GraphQLField<any, any> | GraphQLDirective, node: FieldNode | DirectiveNode): Arguments;
|
|
61
|
+
interface ASTValueWithVariables {
|
|
62
|
+
value: object | string | boolean | symbol | number | null | any[];
|
|
63
|
+
variables: MissingVariablePath[];
|
|
64
|
+
}
|
|
65
|
+
interface ASTValue {
|
|
66
|
+
value: object | string | boolean | symbol | number | null | any[];
|
|
67
|
+
}
|
|
68
|
+
export declare function valueFromAST(valueNode: ValueNode, type: GraphQLInputType): undefined | ASTValue | ASTValueWithVariables;
|
|
69
|
+
export declare function computeLocations(nodes: ASTNode[]): SourceLocation[];
|
|
70
|
+
export declare function addPath(responsePath: ObjectPath | undefined, key: string, type?: ResponsePathType): ObjectPath;
|
|
71
|
+
export declare function flattenPath(path: ObjectPath): Array<{
|
|
72
|
+
key: string;
|
|
73
|
+
type: ResponsePathType;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Serialize a path for use in the skip/include directives.
|
|
77
|
+
*
|
|
78
|
+
* @param path The path to serialize
|
|
79
|
+
* @returns The path serialized as a string, with the root path first.
|
|
80
|
+
*/
|
|
81
|
+
export declare function serializeObjectPathForSkipInclude(path: ObjectPath | undefined): string;
|
|
82
|
+
/**
|
|
83
|
+
* join two path segments to a dot notation, handling empty strings
|
|
84
|
+
*
|
|
85
|
+
* @param a path segment
|
|
86
|
+
* @param b path segment
|
|
87
|
+
* @returns combined path in dot notation
|
|
88
|
+
*/
|
|
89
|
+
export declare function joinSkipIncludePath(a: string, b: string): string;
|