graphql-jit 0.8.9 → 0.8.10

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/dist/ast.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import 'graphql';
2
- export { A as Arguments, F as FieldsAndNodes, t as JitFieldNode, O as ObjectPath, z as addPath, u as collectFields, v as collectSubfields, y as computeLocations, B as flattenPath, w as getArgumentDefs, H as joinSkipIncludePath, r as resolveFieldDef, D as serializeObjectPathForSkipInclude, x as valueFromAST } from './index-CeluTkd4.mjs';
2
+ export { A as Arguments, F as FieldsAndNodes, t as JitFieldNode, O as ObjectPath, z as addPath, u as collectFields, v as collectSubfields, y as computeLocations, B as flattenPath, w as getArgumentDefs, H as joinSkipIncludePath, r as resolveFieldDef, D as serializeObjectPathForSkipInclude, x as valueFromAST } from './index-DtKZ-jVv.mjs';
3
3
  import '@graphql-typed-document-node/core';
4
4
  import './types.mjs';
5
5
  import './error.mjs';
package/dist/ast.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import 'graphql';
2
- export { A as Arguments, F as FieldsAndNodes, t as JitFieldNode, O as ObjectPath, z as addPath, u as collectFields, v as collectSubfields, y as computeLocations, B as flattenPath, w as getArgumentDefs, H as joinSkipIncludePath, r as resolveFieldDef, D as serializeObjectPathForSkipInclude, x as valueFromAST } from './index-mKv2zpdA.js';
2
+ export { A as Arguments, F as FieldsAndNodes, t as JitFieldNode, O as ObjectPath, z as addPath, u as collectFields, v as collectSubfields, y as computeLocations, B as flattenPath, w as getArgumentDefs, H as joinSkipIncludePath, r as resolveFieldDef, D as serializeObjectPathForSkipInclude, x as valueFromAST } from './index-CZg-2UMZ.js';
3
3
  import '@graphql-typed-document-node/core';
4
4
  import './types.js';
5
5
  import './error.js';
package/dist/compat.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'graphql';
2
2
  import './types.mjs';
3
- export { E as ExecutionContext, c as coerceInputLiteral, f as formatError, b as getDefaultValue, a as getGraphQLErrorOptions, g as getOperationRootType, h as hasDefaultValue, r as resolveFieldDef } from './index-CeluTkd4.mjs';
3
+ export { E as ExecutionContext, c as coerceInputLiteral, f as formatError, b as getDefaultValue, a as getGraphQLErrorOptions, g as getOperationRootType, h as hasDefaultValue, r as resolveFieldDef } from './index-DtKZ-jVv.mjs';
4
4
  import '@graphql-typed-document-node/core';
5
5
  import './error.mjs';
6
6
  import './resolve-info.mjs';
package/dist/compat.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'graphql';
2
2
  import './types.js';
3
- export { E as ExecutionContext, c as coerceInputLiteral, f as formatError, b as getDefaultValue, a as getGraphQLErrorOptions, g as getOperationRootType, h as hasDefaultValue, r as resolveFieldDef } from './index-mKv2zpdA.js';
3
+ export { E as ExecutionContext, c as coerceInputLiteral, f as formatError, b as getDefaultValue, a as getGraphQLErrorOptions, g as getOperationRootType, h as hasDefaultValue, r as resolveFieldDef } from './index-CZg-2UMZ.js';
4
4
  import '@graphql-typed-document-node/core';
5
5
  import './error.js';
6
6
  import './resolve-info.js';
@@ -1,5 +1,5 @@
1
1
  import '@graphql-typed-document-node/core';
2
- export { C as CompilationContext, k as CompiledQuery, e as CompilerOptions, i as ExecutionContext, G as GLOBAL_VARIABLES_NAME, q as buildCompilationContext, l as compileQuery, n as createBoundQuery, s as isAsyncIterable, m as isCompiledQuery, o as isPromise, p as isPromiseInliner } from './index-CeluTkd4.mjs';
2
+ export { C as CompilationContext, k as CompiledQuery, e as CompilerOptions, i as ExecutionContext, G as GLOBAL_VARIABLES_NAME, q as buildCompilationContext, l as compileQuery, n as createBoundQuery, s as isAsyncIterable, m as isCompiledQuery, o as isPromise, p as isPromiseInliner } from './index-DtKZ-jVv.mjs';
3
3
  import 'graphql';
4
4
  import './error.mjs';
5
5
  import './resolve-info.mjs';
@@ -1,5 +1,5 @@
1
1
  import '@graphql-typed-document-node/core';
2
- export { C as CompilationContext, k as CompiledQuery, e as CompilerOptions, i as ExecutionContext, G as GLOBAL_VARIABLES_NAME, q as buildCompilationContext, l as compileQuery, n as createBoundQuery, s as isAsyncIterable, m as isCompiledQuery, o as isPromise, p as isPromiseInliner } from './index-mKv2zpdA.js';
2
+ export { C as CompilationContext, k as CompiledQuery, e as CompilerOptions, i as ExecutionContext, G as GLOBAL_VARIABLES_NAME, q as buildCompilationContext, l as compileQuery, n as createBoundQuery, s as isAsyncIterable, m as isCompiledQuery, o as isPromise, p as isPromiseInliner } from './index-CZg-2UMZ.js';
3
3
  import 'graphql';
4
4
  import './error.js';
5
5
  import './resolve-info.js';
package/dist/execution.js CHANGED
@@ -152,7 +152,14 @@ function isCompiledQuery(query) {
152
152
  return "query" in query && typeof query.query === "function";
153
153
  }
154
154
  function createBoundQuery(compilationContext, document, func, getVariableValues, operationName) {
155
- const { resolvers, typeResolvers, isTypeOfs, serializers, resolveInfos } = compilationContext;
155
+ const {
156
+ resolvers,
157
+ typeResolvers,
158
+ isTypeOfs,
159
+ serializers,
160
+ resolveInfos,
161
+ literals
162
+ } = compilationContext;
156
163
  const trimmer = (0, import_non_null.createNullTrimmer)(compilationContext);
157
164
  const fnName = operationName || "query";
158
165
  const ret = {
@@ -172,6 +179,7 @@ function createBoundQuery(compilationContext, document, func, getVariableValues,
172
179
  isTypeOfs,
173
180
  serializers,
174
181
  resolveInfos,
182
+ literals,
175
183
  trimmer,
176
184
  rt: import_runtime.jitRuntime,
177
185
  promiseCounter: 0,
@@ -807,27 +815,66 @@ function compileListType(context, parentType, type, fieldNodes, originalObjectPa
807
815
  return `(typeof ${name} === "string" || typeof ${name}[Symbol.iterator] !== "function") ? ${errorCase} :
808
816
  ${GLOBAL_SAFE_MAP_NAME}(${GLOBAL_EXECUTION_CONTEXT}, ${name}, ${safeMapHandler}, ${parentIndexes})`;
809
817
  }
810
- const MAGIC_MINUS_INFINITY = "__MAGIC_MINUS_INFINITY__71d4310a_d4a3_4a05_b1fe_e60779d24998";
811
- const MAGIC_PLUS_INFINITY = "__MAGIC_PLUS_INFINITY__bb201c39_3333_4695_b4ad_7f1722e7aa7a";
812
- const MAGIC_NAN = "__MAGIC_NAN__57f286b9_4c20_487f_b409_79804ddcb4f8";
813
- const MAGIC_DATE = "__MAGIC_DATE__33a9e76d_02e0_4128_8e92_3530ad3da74d";
814
- function specialValueReplacer(key, value) {
815
- if (Number.isNaN(value)) {
816
- return MAGIC_NAN;
818
+ function isUnserializable(value) {
819
+ switch (typeof value) {
820
+ case "bigint":
821
+ case "symbol":
822
+ case "function":
823
+ return true;
824
+ case "object": {
825
+ if (value === null) {
826
+ return false;
827
+ }
828
+ const proto = Object.getPrototypeOf(value);
829
+ if (Array.isArray(value)) {
830
+ return proto !== Array.prototype;
831
+ }
832
+ if (value instanceof Date) {
833
+ return proto !== Date.prototype;
834
+ }
835
+ return proto !== null && proto !== Object.prototype;
836
+ }
837
+ default:
838
+ return false;
817
839
  }
818
- if (value === Infinity) {
819
- return MAGIC_PLUS_INFINITY;
840
+ }
841
+ function objectStringify(val, hoist) {
842
+ if (isUnserializable(val)) {
843
+ return `${GLOBAL_EXECUTION_CONTEXT}.literals.${hoist(val)}`;
844
+ }
845
+ if (typeof val === "number") {
846
+ return Number.isFinite(val) ? JSON.stringify(val) : String(val);
820
847
  }
821
- if (value === -Infinity) {
822
- return MAGIC_MINUS_INFINITY;
848
+ if (val === void 0) {
849
+ return "undefined";
823
850
  }
824
- if (this[key] instanceof Date) {
825
- return MAGIC_DATE + this[key].getTime();
851
+ if (val === null || typeof val !== "object") {
852
+ return JSON.stringify(val);
826
853
  }
827
- return value;
828
- }
829
- function objectStringify(val) {
830
- return JSON.stringify(val, specialValueReplacer).replace(new RegExp(`"${MAGIC_NAN}"`, "g"), "NaN").replace(new RegExp(`"${MAGIC_PLUS_INFINITY}"`, "g"), "Infinity").replace(new RegExp(`"${MAGIC_MINUS_INFINITY}"`, "g"), "-Infinity").replace(new RegExp(`"${MAGIC_DATE}([^"]+)"`, "g"), "new Date($1)");
854
+ if (val instanceof Date) {
855
+ return `new Date(${val.getTime()})`;
856
+ }
857
+ if (Array.isArray(val)) {
858
+ const items = [];
859
+ for (let i = 0; i < val.length; ++i) {
860
+ items.push(i in val ? objectStringify(val[i], hoist) : "null");
861
+ }
862
+ return `[${items.join(",")}]`;
863
+ }
864
+ const props = [];
865
+ for (const key of Object.keys(val)) {
866
+ if (val[key] === void 0) {
867
+ continue;
868
+ }
869
+ const name = JSON.stringify(key);
870
+ props.push(
871
+ `${key === "__proto__" ? `[${name}]` : name}:${objectStringify(
872
+ val[key],
873
+ hoist
874
+ )}`
875
+ );
876
+ }
877
+ return `{${props.join(",")}}`;
831
878
  }
832
879
  function getExecutionInfo(context, parentType, fieldType, fieldName, fieldNodes, responsePath) {
833
880
  const resolveInfoName = createResolveInfoName(responsePath);
@@ -872,7 +919,11 @@ function objectPath(topLevel, path) {
872
919
  function compileArguments(context, args, topLevelArg, validArgs, returnType, path) {
873
920
  let body = `
874
921
  let ${validArgs} = true;
875
- const ${topLevelArg} = ${objectStringify(args.values)};
922
+ const ${topLevelArg} = ${objectStringify(args.values, (value) => {
923
+ const key = `literal${Object.keys(context.literals).length}`;
924
+ context.literals[key] = value;
925
+ return key;
926
+ })};
876
927
  `;
877
928
  const errorDestination = getErrorDestination(returnType);
878
929
  for (const variable of args.missing) {
@@ -1042,6 +1093,7 @@ function buildCompilationContext(schema, document, options, operationName) {
1042
1093
  typeResolvers: {},
1043
1094
  isTypeOfs: {},
1044
1095
  resolveInfos: {},
1096
+ literals: {},
1045
1097
  hoistedFunctions: [],
1046
1098
  hoistedFunctionNames: /* @__PURE__ */ new Map(),
1047
1099
  leafErrHandlerCache: /* @__PURE__ */ new Map(),
@@ -1177,7 +1229,14 @@ function compileSubscriptionOperation(context, type, fieldMap, queryFn) {
1177
1229
  };
1178
1230
  }
1179
1231
  function createBoundSubscribe(compilationContext, document, func, getVariableValues, operationName) {
1180
- const { resolvers, typeResolvers, isTypeOfs, serializers, resolveInfos } = compilationContext;
1232
+ const {
1233
+ resolvers,
1234
+ typeResolvers,
1235
+ isTypeOfs,
1236
+ serializers,
1237
+ resolveInfos,
1238
+ literals
1239
+ } = compilationContext;
1181
1240
  const trimmer = (0, import_non_null.createNullTrimmer)(compilationContext);
1182
1241
  const fnName = operationName || "subscribe";
1183
1242
  const ret = {
@@ -1197,6 +1256,7 @@ function createBoundSubscribe(compilationContext, document, func, getVariableVal
1197
1256
  isTypeOfs,
1198
1257
  serializers,
1199
1258
  resolveInfos,
1259
+ literals,
1200
1260
  trimmer,
1201
1261
  rt: import_runtime.jitRuntime,
1202
1262
  promiseCounter: 0,