houdini 0.19.4 → 1.0.0-next.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.
@@ -1,4 +1,5 @@
1
1
  import * as graphql from 'graphql';
2
+ import { Config } from '.';
2
3
  export declare function getRootType(type: graphql.GraphQLType): graphql.GraphQLType;
3
4
  export declare function hashDocument(document: string | graphql.DocumentNode): string;
4
5
  type GraphQLParentType = graphql.GraphQLObjectType | graphql.GraphQLInputObjectType | graphql.GraphQLInterfaceType;
@@ -6,4 +7,17 @@ export declare function parentTypeFromAncestors(schema: graphql.GraphQLSchema, f
6
7
  export declare function definitionFromAncestors(ancestors: readonly any[]): graphql.OperationDefinitionNode | graphql.FragmentDefinitionNode;
7
8
  export declare function formatErrors(e: unknown, afterError?: (e: Error) => void): void;
8
9
  export declare function operation_requires_variables(operation: graphql.OperationDefinitionNode): boolean;
10
+ export declare function unwrapType(config: Config, type: any, wrappers?: TypeWrapper[]): {
11
+ type: graphql.GraphQLNamedType;
12
+ wrappers: TypeWrapper[];
13
+ };
14
+ export declare function wrapType({ type, wrappers, }: {
15
+ type: graphql.GraphQLNamedType;
16
+ wrappers: TypeWrapper[];
17
+ }): graphql.TypeNode;
18
+ export declare enum TypeWrapper {
19
+ Nullable = "Nullable",
20
+ List = "List",
21
+ NonNull = "NonNull"
22
+ }
9
23
  export {};
@@ -532,7 +532,7 @@ var require_kinds = __commonJS({
532
532
  value: true
533
533
  });
534
534
  exports.Kind = void 0;
535
- var Kind18 = Object.freeze({
535
+ var Kind19 = Object.freeze({
536
536
  NAME: "Name",
537
537
  DOCUMENT: "Document",
538
538
  OPERATION_DEFINITION: "OperationDefinition",
@@ -577,7 +577,7 @@ var require_kinds = __commonJS({
577
577
  ENUM_TYPE_EXTENSION: "EnumTypeExtension",
578
578
  INPUT_OBJECT_TYPE_EXTENSION: "InputObjectTypeExtension"
579
579
  });
580
- exports.Kind = Kind18;
580
+ exports.Kind = Kind19;
581
581
  }
582
582
  });
583
583
 
@@ -3368,8 +3368,8 @@ var require_definition = __commonJS({
3368
3368
  exports.assertCompositeType = assertCompositeType;
3369
3369
  exports.isAbstractType = isAbstractType;
3370
3370
  exports.assertAbstractType = assertAbstractType;
3371
- exports.GraphQLList = GraphQLList5;
3372
- exports.GraphQLNonNull = GraphQLNonNull5;
3371
+ exports.GraphQLList = GraphQLList6;
3372
+ exports.GraphQLNonNull = GraphQLNonNull6;
3373
3373
  exports.isWrappingType = isWrappingType;
3374
3374
  exports.assertWrappingType = assertWrappingType;
3375
3375
  exports.isNullableType = isNullableType;
@@ -3484,7 +3484,7 @@ var require_definition = __commonJS({
3484
3484
  return type;
3485
3485
  }
3486
3486
  function isListType7(type) {
3487
- return (0, _instanceOf.default)(type, GraphQLList5);
3487
+ return (0, _instanceOf.default)(type, GraphQLList6);
3488
3488
  }
3489
3489
  function assertListType(type) {
3490
3490
  if (!isListType7(type)) {
@@ -3493,7 +3493,7 @@ var require_definition = __commonJS({
3493
3493
  return type;
3494
3494
  }
3495
3495
  function isNonNullType6(type) {
3496
- return (0, _instanceOf.default)(type, GraphQLNonNull5);
3496
+ return (0, _instanceOf.default)(type, GraphQLNonNull6);
3497
3497
  }
3498
3498
  function assertNonNullType(type) {
3499
3499
  if (!isNonNullType6(type)) {
@@ -3546,44 +3546,44 @@ var require_definition = __commonJS({
3546
3546
  }
3547
3547
  return type;
3548
3548
  }
3549
- function GraphQLList5(ofType) {
3550
- if (this instanceof GraphQLList5) {
3549
+ function GraphQLList6(ofType) {
3550
+ if (this instanceof GraphQLList6) {
3551
3551
  this.ofType = assertType(ofType);
3552
3552
  } else {
3553
- return new GraphQLList5(ofType);
3553
+ return new GraphQLList6(ofType);
3554
3554
  }
3555
3555
  }
3556
- GraphQLList5.prototype.toString = function toString() {
3556
+ GraphQLList6.prototype.toString = function toString() {
3557
3557
  return "[" + String(this.ofType) + "]";
3558
3558
  };
3559
- GraphQLList5.prototype.toJSON = function toJSON() {
3559
+ GraphQLList6.prototype.toJSON = function toJSON() {
3560
3560
  return this.toString();
3561
3561
  };
3562
- Object.defineProperty(GraphQLList5.prototype, _symbols.SYMBOL_TO_STRING_TAG, {
3562
+ Object.defineProperty(GraphQLList6.prototype, _symbols.SYMBOL_TO_STRING_TAG, {
3563
3563
  get: function get() {
3564
3564
  return "GraphQLList";
3565
3565
  }
3566
3566
  });
3567
- (0, _defineInspect.default)(GraphQLList5);
3568
- function GraphQLNonNull5(ofType) {
3569
- if (this instanceof GraphQLNonNull5) {
3567
+ (0, _defineInspect.default)(GraphQLList6);
3568
+ function GraphQLNonNull6(ofType) {
3569
+ if (this instanceof GraphQLNonNull6) {
3570
3570
  this.ofType = assertNullableType(ofType);
3571
3571
  } else {
3572
- return new GraphQLNonNull5(ofType);
3572
+ return new GraphQLNonNull6(ofType);
3573
3573
  }
3574
3574
  }
3575
- GraphQLNonNull5.prototype.toString = function toString() {
3575
+ GraphQLNonNull6.prototype.toString = function toString() {
3576
3576
  return String(this.ofType) + "!";
3577
3577
  };
3578
- GraphQLNonNull5.prototype.toJSON = function toJSON() {
3578
+ GraphQLNonNull6.prototype.toJSON = function toJSON() {
3579
3579
  return this.toString();
3580
3580
  };
3581
- Object.defineProperty(GraphQLNonNull5.prototype, _symbols.SYMBOL_TO_STRING_TAG, {
3581
+ Object.defineProperty(GraphQLNonNull6.prototype, _symbols.SYMBOL_TO_STRING_TAG, {
3582
3582
  get: function get() {
3583
3583
  return "GraphQLNonNull";
3584
3584
  }
3585
3585
  });
3586
- (0, _defineInspect.default)(GraphQLNonNull5);
3586
+ (0, _defineInspect.default)(GraphQLNonNull6);
3587
3587
  function isWrappingType(type) {
3588
3588
  return isListType7(type) || isNonNullType6(type);
3589
3589
  }
@@ -14712,9 +14712,9 @@ var require_graphql2 = __commonJS({
14712
14712
  }
14713
14713
  });
14714
14714
 
14715
- // ../../node_modules/.pnpm/minimatch@5.1.1/node_modules/minimatch/lib/path.js
14715
+ // ../../node_modules/.pnpm/minimatch@5.1.2/node_modules/minimatch/lib/path.js
14716
14716
  var require_path = __commonJS({
14717
- "../../node_modules/.pnpm/minimatch@5.1.1/node_modules/minimatch/lib/path.js"(exports, module2) {
14717
+ "../../node_modules/.pnpm/minimatch@5.1.2/node_modules/minimatch/lib/path.js"(exports, module2) {
14718
14718
  var isWindows = typeof process === "object" && process && process.platform === "win32";
14719
14719
  module2.exports = isWindows ? { sep: "\\" } : { sep: "/" };
14720
14720
  }
@@ -14931,9 +14931,9 @@ var require_brace_expansion = __commonJS({
14931
14931
  }
14932
14932
  });
14933
14933
 
14934
- // ../../node_modules/.pnpm/minimatch@5.1.1/node_modules/minimatch/minimatch.js
14934
+ // ../../node_modules/.pnpm/minimatch@5.1.2/node_modules/minimatch/minimatch.js
14935
14935
  var require_minimatch = __commonJS({
14936
- "../../node_modules/.pnpm/minimatch@5.1.1/node_modules/minimatch/minimatch.js"(exports, module2) {
14936
+ "../../node_modules/.pnpm/minimatch@5.1.2/node_modules/minimatch/minimatch.js"(exports, module2) {
14937
14937
  var minimatch2 = module2.exports = (p, pattern, options = {}) => {
14938
14938
  assertValidPattern(pattern);
14939
14939
  if (!options.nocomment && pattern.charAt(0) === "#") {
@@ -15019,7 +15019,9 @@ var require_minimatch = __commonJS({
15019
15019
  return list;
15020
15020
  };
15021
15021
  var globUnescape = (s2) => s2.replace(/\\(.)/g, "$1");
15022
+ var charUnescape = (s2) => s2.replace(/\\([^-\]])/g, "$1");
15022
15023
  var regExpEscape = (s2) => s2.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
15024
+ var braExpEscape = (s2) => s2.replace(/[[\]\\]/g, "\\$&");
15023
15025
  var Minimatch = class {
15024
15026
  constructor(pattern, options) {
15025
15027
  assertValidPattern(pattern);
@@ -15211,6 +15213,10 @@ var require_minimatch = __commonJS({
15211
15213
  return false;
15212
15214
  }
15213
15215
  case "\\":
15216
+ if (inClass && pattern.charAt(i2 + 1) === "-") {
15217
+ re += c;
15218
+ continue;
15219
+ }
15214
15220
  clearStateChar();
15215
15221
  escaping = true;
15216
15222
  continue;
@@ -15293,17 +15299,13 @@ var require_minimatch = __commonJS({
15293
15299
  }
15294
15300
  cs = pattern.substring(classStart + 1, i2);
15295
15301
  try {
15296
- RegExp("[" + cs + "]");
15302
+ RegExp("[" + braExpEscape(charUnescape(cs)) + "]");
15303
+ re += c;
15297
15304
  } catch (er) {
15298
- sp = this.parse(cs, SUBPARSE);
15299
- re = re.substring(0, reClassStart) + "\\[" + sp[0] + "\\]";
15300
- hasMagic = hasMagic || sp[1];
15301
- inClass = false;
15302
- continue;
15305
+ re = re.substring(0, reClassStart) + "(?:$.)";
15303
15306
  }
15304
15307
  hasMagic = true;
15305
15308
  inClass = false;
15306
- re += c;
15307
15309
  continue;
15308
15310
  default:
15309
15311
  clearStateChar();
@@ -27479,9 +27481,9 @@ var init_multipart_parser = __esm({
27479
27481
  }
27480
27482
  });
27481
27483
 
27482
- // ../../node_modules/.pnpm/@babel+parser@7.20.5/node_modules/@babel/parser/lib/index.js
27484
+ // ../../node_modules/.pnpm/@babel+parser@7.20.7/node_modules/@babel/parser/lib/index.js
27483
27485
  var require_lib3 = __commonJS({
27484
- "../../node_modules/.pnpm/@babel+parser@7.20.5/node_modules/@babel/parser/lib/index.js"(exports) {
27486
+ "../../node_modules/.pnpm/@babel+parser@7.20.7/node_modules/@babel/parser/lib/index.js"(exports) {
27485
27487
  "use strict";
27486
27488
  Object.defineProperty(exports, "__esModule", { value: true });
27487
27489
  function _objectWithoutPropertiesLoose(source, excluded) {
@@ -27597,9 +27599,9 @@ var require_lib3 = __commonJS({
27597
27599
  AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
27598
27600
  AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
27599
27601
  AwaitNotInAsyncFunction: "'await' is only allowed within async functions.",
27600
- BadGetterArity: "A 'get' accesor must not have any formal parameters.",
27601
- BadSetterArity: "A 'set' accesor must have exactly one formal parameter.",
27602
- BadSetterRestParameter: "A 'set' accesor function argument must not be a rest parameter.",
27602
+ BadGetterArity: "A 'get' accessor must not have any formal parameters.",
27603
+ BadSetterArity: "A 'set' accessor must have exactly one formal parameter.",
27604
+ BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.",
27603
27605
  ConstructorClassField: "Classes may not have a field named 'constructor'.",
27604
27606
  ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
27605
27607
  ConstructorIsAccessor: "Class constructor may not be an accessor.",
@@ -31033,7 +31035,7 @@ var require_lib3 = __commonJS({
31033
31035
  }
31034
31036
  this.parser.raise(toParseError, origin);
31035
31037
  }
31036
- recordArrowParemeterBindingError(error, {
31038
+ recordArrowParameterBindingError(error, {
31037
31039
  at: node
31038
31040
  }) {
31039
31041
  const {
@@ -34792,6 +34794,7 @@ var require_lib3 = __commonJS({
34792
34794
  }) => `Property '${propertyName}' cannot have an initializer because it is marked abstract.`,
34793
34795
  AccesorCannotDeclareThisParameter: "'get' and 'set' accessors cannot declare 'this' parameters.",
34794
34796
  AccesorCannotHaveTypeParameters: "An accessor cannot have type parameters.",
34797
+ AccessorCannotBeOptional: "An 'accessor' property cannot be declared optional.",
34795
34798
  ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier.",
34796
34799
  ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier.",
34797
34800
  ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference: "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",
@@ -36754,8 +36757,12 @@ var require_lib3 = __commonJS({
36754
36757
  node.typeParameters = typeParameters;
36755
36758
  }
36756
36759
  parseClassPropertyAnnotation(node) {
36757
- if (!node.optional && this.eat(35)) {
36758
- node.definite = true;
36760
+ if (!node.optional) {
36761
+ if (this.eat(35)) {
36762
+ node.definite = true;
36763
+ } else if (this.eat(17)) {
36764
+ node.optional = true;
36765
+ }
36759
36766
  }
36760
36767
  const type = this.tsTryParseTypeAnnotation();
36761
36768
  if (type)
@@ -36794,6 +36801,15 @@ var require_lib3 = __commonJS({
36794
36801
  this.parseClassPropertyAnnotation(node);
36795
36802
  return super.parseClassPrivateProperty(node);
36796
36803
  }
36804
+ parseClassAccessorProperty(node) {
36805
+ this.parseClassPropertyAnnotation(node);
36806
+ if (node.optional) {
36807
+ this.raise(TSErrors.AccessorCannotBeOptional, {
36808
+ at: node
36809
+ });
36810
+ }
36811
+ return super.parseClassAccessorProperty(node);
36812
+ }
36797
36813
  pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
36798
36814
  const typeParameters = this.tsTryParseTypeParameters();
36799
36815
  if (typeParameters && isConstructor) {
@@ -37004,7 +37020,7 @@ var require_lib3 = __commonJS({
37004
37020
  case "TSNonNullExpression":
37005
37021
  case "TSTypeAssertion":
37006
37022
  if (isLHS) {
37007
- this.expressionScope.recordArrowParemeterBindingError(TSErrors.UnexpectedTypeCastInParameter, {
37023
+ this.expressionScope.recordArrowParameterBindingError(TSErrors.UnexpectedTypeCastInParameter, {
37008
37024
  at: node
37009
37025
  });
37010
37026
  } else {
@@ -37711,7 +37727,7 @@ var require_lib3 = __commonJS({
37711
37727
  parenthesized = unwrapParenthesizedExpression(node);
37712
37728
  if (isLHS) {
37713
37729
  if (parenthesized.type === "Identifier") {
37714
- this.expressionScope.recordArrowParemeterBindingError(Errors.InvalidParenthesizedAssignment, {
37730
+ this.expressionScope.recordArrowParameterBindingError(Errors.InvalidParenthesizedAssignment, {
37715
37731
  at: node
37716
37732
  });
37717
37733
  } else if (parenthesized.type !== "MemberExpression") {
@@ -58282,6 +58298,7 @@ __export(lib_exports, {
58282
58298
  HoudiniError: () => HoudiniError,
58283
58299
  LogLevel: () => LogLevel,
58284
58300
  RefetchUpdateMode: () => RefetchUpdateMode,
58301
+ TypeWrapper: () => TypeWrapper,
58285
58302
  cleanupFiles: () => cleanupFiles,
58286
58303
  computeID: () => computeID,
58287
58304
  defaultConfigValues: () => defaultConfigValues,
@@ -58308,7 +58325,9 @@ __export(lib_exports, {
58308
58325
  readConfigFile: () => readConfigFile,
58309
58326
  runPipeline: () => runPipeline,
58310
58327
  setMockConfig: () => setMockConfig,
58311
- siteURL: () => siteURL
58328
+ siteURL: () => siteURL,
58329
+ unwrapType: () => unwrapType,
58330
+ wrapType: () => wrapType
58312
58331
  });
58313
58332
  module.exports = __toCommonJS(lib_exports);
58314
58333
 
@@ -65531,6 +65550,60 @@ function operation_requires_variables(operation) {
65531
65550
  )
65532
65551
  );
65533
65552
  }
65553
+ function unwrapType(config, type, wrappers = []) {
65554
+ if (type.kind === "NonNullType") {
65555
+ return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
65556
+ }
65557
+ if (type instanceof graphql3.GraphQLNonNull) {
65558
+ return unwrapType(config, type.ofType, [TypeWrapper.NonNull, ...wrappers]);
65559
+ }
65560
+ if (wrappers[0] !== TypeWrapper.NonNull) {
65561
+ wrappers.unshift(TypeWrapper.Nullable);
65562
+ }
65563
+ if (type.kind === "ListType") {
65564
+ return unwrapType(config, type.type, [TypeWrapper.List, ...wrappers]);
65565
+ }
65566
+ if (type instanceof graphql3.GraphQLList) {
65567
+ return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
65568
+ }
65569
+ const namedType = config.schema.getType(type.name.value || type.name);
65570
+ if (!namedType) {
65571
+ throw new Error("Could not unwrap type: " + JSON.stringify(type));
65572
+ }
65573
+ return { type: namedType, wrappers };
65574
+ }
65575
+ function wrapType({
65576
+ type,
65577
+ wrappers
65578
+ }) {
65579
+ const head = wrappers[0];
65580
+ const tail = wrappers.slice(1);
65581
+ let kind = graphql3.Kind.NAMED_TYPE;
65582
+ if (head === TypeWrapper.List) {
65583
+ kind = graphql3.Kind.LIST_TYPE;
65584
+ } else if (head === TypeWrapper.NonNull) {
65585
+ kind = graphql3.Kind.NON_NULL_TYPE;
65586
+ }
65587
+ if (kind === "NamedType") {
65588
+ return {
65589
+ kind,
65590
+ name: {
65591
+ kind: graphql3.Kind.NAME,
65592
+ value: type.name
65593
+ }
65594
+ };
65595
+ }
65596
+ return {
65597
+ kind,
65598
+ type: wrapType({ type, wrappers: tail })
65599
+ };
65600
+ }
65601
+ var TypeWrapper = /* @__PURE__ */ ((TypeWrapper2) => {
65602
+ TypeWrapper2["Nullable"] = "Nullable";
65603
+ TypeWrapper2["List"] = "List";
65604
+ TypeWrapper2["NonNull"] = "NonNull";
65605
+ return TypeWrapper2;
65606
+ })(TypeWrapper || {});
65534
65607
 
65535
65608
  // src/lib/parse.ts
65536
65609
  var import_parser = __toESM(require_lib3(), 1);
@@ -65804,6 +65877,7 @@ async function find_graphql(config, parsedScript, walker) {
65804
65877
  HoudiniError,
65805
65878
  LogLevel,
65806
65879
  RefetchUpdateMode,
65880
+ TypeWrapper,
65807
65881
  cleanupFiles,
65808
65882
  computeID,
65809
65883
  defaultConfigValues,
@@ -65830,7 +65904,9 @@ async function find_graphql(config, parsedScript, walker) {
65830
65904
  readConfigFile,
65831
65905
  runPipeline,
65832
65906
  setMockConfig,
65833
- siteURL
65907
+ siteURL,
65908
+ unwrapType,
65909
+ wrapType
65834
65910
  });
65835
65911
  /*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
65836
65912
  /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */