@hygraph/cli 0.0.7 → 0.0.9
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 +4 -5
- package/dist/cli.js +3394 -250
- package/dist/define.d.ts +712 -155
- package/dist/define2.js +4461 -48
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/define2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as __exportAll } from "./rolldown-runtime.js";
|
|
1
|
+
import { n as __exportAll, t as __commonJSMin } from "./rolldown-runtime.js";
|
|
2
2
|
//#region src/utils/is-empty.ts
|
|
3
3
|
/**
|
|
4
4
|
* A nullable string that was omitted, `null` or written as `""` canonicalises
|
|
@@ -12,9 +12,10 @@ function isEmpty(value) {
|
|
|
12
12
|
//#region src/define/fields/asset.ts
|
|
13
13
|
/**
|
|
14
14
|
* One asset, or a list of them, that editors connect to the entry. Hygraph
|
|
15
|
-
* adds a field back on the Asset model
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* adds a field back on the Asset model: on a model, the
|
|
16
|
+
* `assetReverseField` on `system.asset` that `reverse` names; on a
|
|
17
|
+
* component, a hidden one the CLI names after the field and the
|
|
18
|
+
* component, `iconCard` for `icon` on `Card`.
|
|
18
19
|
*
|
|
19
20
|
* Nothing here is validated: the checks run at plan time with the model's
|
|
20
21
|
* or component's own.
|
|
@@ -29,10 +30,11 @@ function asset$1(input) {
|
|
|
29
30
|
required: input.required ?? FIELD_DEFAULTS.required,
|
|
30
31
|
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
31
32
|
visibilityCondition: input.visibilityCondition ?? null,
|
|
33
|
+
reverse: isEmpty(input.reverse) ? null : input.reverse,
|
|
32
34
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
|
-
/** `renamedFrom` stays out of the IR. */
|
|
37
|
+
/** `renamedFrom` stays out of the IR, and `reverse` when unset. */
|
|
36
38
|
function convertAssetFieldToIR(field, position) {
|
|
37
39
|
return {
|
|
38
40
|
kind: "asset",
|
|
@@ -43,17 +45,64 @@ function convertAssetFieldToIR(field, position) {
|
|
|
43
45
|
list: field.list,
|
|
44
46
|
required: field.required,
|
|
45
47
|
visibility: field.visibility,
|
|
46
|
-
visibilityCondition: field.visibilityCondition
|
|
48
|
+
visibilityCondition: field.visibilityCondition,
|
|
49
|
+
...field.reverse !== null && { reverse: field.reverse }
|
|
47
50
|
};
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
50
|
-
* The apiId
|
|
51
|
-
*
|
|
53
|
+
* The apiId Studio gives an asset field's other side on Asset: `imagePost`
|
|
54
|
+
* for a field `image` on `Post`. The CLI gives it to a component's.
|
|
52
55
|
*/
|
|
53
56
|
function assetReverseApiId(apiId, parentApiId) {
|
|
54
57
|
return `${apiId}${parentApiId.charAt(0).toUpperCase()}${parentApiId.slice(1)}`;
|
|
55
58
|
}
|
|
56
59
|
//#endregion
|
|
60
|
+
//#region src/define/fields/assetReverseField.ts
|
|
61
|
+
/**
|
|
62
|
+
* The field back on Asset of an asset field on a model: the entries that
|
|
63
|
+
* use the asset there. Goes in `system.asset`'s fields, and the asset
|
|
64
|
+
* field names it in `reverse`. It has its own name, description and
|
|
65
|
+
* visibility, and renames on its own. Asset only.
|
|
66
|
+
*
|
|
67
|
+
* Nothing here is validated, and the model is not looked at until the
|
|
68
|
+
* plan: the checks run at plan time with the model's own.
|
|
69
|
+
*/
|
|
70
|
+
function assetReverseField(input) {
|
|
71
|
+
return {
|
|
72
|
+
__typename: "AssetReverseField",
|
|
73
|
+
apiId: input.apiId,
|
|
74
|
+
displayName: input.displayName,
|
|
75
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
76
|
+
to: input.to,
|
|
77
|
+
reverse: input.reverse,
|
|
78
|
+
list: true,
|
|
79
|
+
required: false,
|
|
80
|
+
visibility: input.visibility ?? "API_ONLY",
|
|
81
|
+
visibilityCondition: null,
|
|
82
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Hygraph keeps a field back as the two-way side of its asset field, so
|
|
87
|
+
* the IR has it as one, with no rules. `renamedFrom` stays out.
|
|
88
|
+
*/
|
|
89
|
+
function convertAssetReverseFieldToIR(field, position) {
|
|
90
|
+
return {
|
|
91
|
+
kind: "referenceTwoWay",
|
|
92
|
+
apiId: field.apiId,
|
|
93
|
+
displayName: field.displayName,
|
|
94
|
+
description: field.description,
|
|
95
|
+
to: field.to().apiId,
|
|
96
|
+
reverse: field.reverse,
|
|
97
|
+
rules: null,
|
|
98
|
+
position,
|
|
99
|
+
list: true,
|
|
100
|
+
required: false,
|
|
101
|
+
visibility: field.visibility,
|
|
102
|
+
visibilityCondition: null
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
57
106
|
//#region src/define/fields/boolean.ts
|
|
58
107
|
/**
|
|
59
108
|
* True or false.
|
|
@@ -603,6 +652,4323 @@ function convertReferenceTwoWayFieldToIR(field, position) {
|
|
|
603
652
|
};
|
|
604
653
|
}
|
|
605
654
|
//#endregion
|
|
655
|
+
//#region src/define/fields/referenceUnion.ts
|
|
656
|
+
/**
|
|
657
|
+
* Entries of several models, which editors choose from, such as a video or an
|
|
658
|
+
* image. On a model, each of those models shows the connection back in a field
|
|
659
|
+
* of its own: declare it there with `define.field.referenceUnionMember`, and
|
|
660
|
+
* name it here in `reverse`. On a component, leave `reverse` out.
|
|
661
|
+
*
|
|
662
|
+
* Nothing here is validated, and the models are not looked at until the
|
|
663
|
+
* plan: the checks run at plan time with the model's own.
|
|
664
|
+
*/
|
|
665
|
+
function referenceUnion(input) {
|
|
666
|
+
return {
|
|
667
|
+
__typename: "ReferenceUnionField",
|
|
668
|
+
apiId: input.apiId,
|
|
669
|
+
displayName: input.displayName,
|
|
670
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
671
|
+
to: [...input.to],
|
|
672
|
+
reverse: isEmpty(input.reverse) ? null : input.reverse,
|
|
673
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
674
|
+
required: false,
|
|
675
|
+
rules: input.rules === void 0 ? null : referenceRules(input.rules),
|
|
676
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
677
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
678
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* The IR names the models by their apiIds, sorted: Hygraph keeps no order
|
|
683
|
+
* for them. `renamedFrom` stays out.
|
|
684
|
+
*/
|
|
685
|
+
function convertReferenceUnionFieldToIR(field, position) {
|
|
686
|
+
return {
|
|
687
|
+
kind: "referenceUnion",
|
|
688
|
+
apiId: field.apiId,
|
|
689
|
+
displayName: field.displayName,
|
|
690
|
+
description: field.description,
|
|
691
|
+
to: field.to.map((model) => model().apiId).toSorted(),
|
|
692
|
+
reverse: field.reverse,
|
|
693
|
+
rules: field.rules,
|
|
694
|
+
position,
|
|
695
|
+
list: field.list,
|
|
696
|
+
required: false,
|
|
697
|
+
visibility: field.visibility,
|
|
698
|
+
visibilityCondition: field.visibilityCondition
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region src/define/fields/referenceUnionMember.ts
|
|
703
|
+
/**
|
|
704
|
+
* The entries whose union reference connects to this one: the field back
|
|
705
|
+
* of a `define.field.referenceUnion`, on each model it lists. Every one
|
|
706
|
+
* has the same apiId, the union's `reverse`; each has its own name,
|
|
707
|
+
* visibility and condition. To rename them, set `renamedFrom` on one that
|
|
708
|
+
* already exists: the others follow. Models only: a component cannot have
|
|
709
|
+
* one.
|
|
710
|
+
*
|
|
711
|
+
* Nothing here is validated, and the model is not looked at until the
|
|
712
|
+
* plan: the checks run at plan time with the model's own.
|
|
713
|
+
*/
|
|
714
|
+
function referenceUnionMember(input) {
|
|
715
|
+
return {
|
|
716
|
+
__typename: "ReferenceUnionMemberField",
|
|
717
|
+
apiId: input.apiId,
|
|
718
|
+
displayName: input.displayName,
|
|
719
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
720
|
+
to: input.to,
|
|
721
|
+
reverse: input.reverse,
|
|
722
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
723
|
+
required: false,
|
|
724
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
725
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
726
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
/** The IR names the model by its apiId. `renamedFrom` stays out. */
|
|
730
|
+
function convertReferenceUnionMemberFieldToIR(field, position) {
|
|
731
|
+
return {
|
|
732
|
+
kind: "referenceUnionMember",
|
|
733
|
+
apiId: field.apiId,
|
|
734
|
+
displayName: field.displayName,
|
|
735
|
+
description: field.description,
|
|
736
|
+
to: field.to().apiId,
|
|
737
|
+
reverse: field.reverse,
|
|
738
|
+
position,
|
|
739
|
+
list: field.list,
|
|
740
|
+
required: false,
|
|
741
|
+
visibility: field.visibility,
|
|
742
|
+
visibilityCondition: field.visibilityCondition
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
//#endregion
|
|
746
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/kinds.js
|
|
747
|
+
var require_kinds = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
748
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
749
|
+
exports.Kind = void 0;
|
|
750
|
+
/** @category Kinds */
|
|
751
|
+
/** The set of allowed kind values for AST nodes. */
|
|
752
|
+
var Kind;
|
|
753
|
+
exports.Kind = Kind;
|
|
754
|
+
(function(Kind) {
|
|
755
|
+
Kind["NAME"] = "Name";
|
|
756
|
+
Kind["DOCUMENT"] = "Document";
|
|
757
|
+
Kind["OPERATION_DEFINITION"] = "OperationDefinition";
|
|
758
|
+
Kind["VARIABLE_DEFINITION"] = "VariableDefinition";
|
|
759
|
+
Kind["SELECTION_SET"] = "SelectionSet";
|
|
760
|
+
Kind["FIELD"] = "Field";
|
|
761
|
+
Kind["ARGUMENT"] = "Argument";
|
|
762
|
+
Kind["FRAGMENT_SPREAD"] = "FragmentSpread";
|
|
763
|
+
Kind["INLINE_FRAGMENT"] = "InlineFragment";
|
|
764
|
+
Kind["FRAGMENT_DEFINITION"] = "FragmentDefinition";
|
|
765
|
+
Kind["VARIABLE"] = "Variable";
|
|
766
|
+
Kind["INT"] = "IntValue";
|
|
767
|
+
Kind["FLOAT"] = "FloatValue";
|
|
768
|
+
Kind["STRING"] = "StringValue";
|
|
769
|
+
Kind["BOOLEAN"] = "BooleanValue";
|
|
770
|
+
Kind["NULL"] = "NullValue";
|
|
771
|
+
Kind["ENUM"] = "EnumValue";
|
|
772
|
+
Kind["LIST"] = "ListValue";
|
|
773
|
+
Kind["OBJECT"] = "ObjectValue";
|
|
774
|
+
Kind["OBJECT_FIELD"] = "ObjectField";
|
|
775
|
+
Kind["DIRECTIVE"] = "Directive";
|
|
776
|
+
Kind["NAMED_TYPE"] = "NamedType";
|
|
777
|
+
Kind["LIST_TYPE"] = "ListType";
|
|
778
|
+
Kind["NON_NULL_TYPE"] = "NonNullType";
|
|
779
|
+
Kind["SCHEMA_DEFINITION"] = "SchemaDefinition";
|
|
780
|
+
Kind["OPERATION_TYPE_DEFINITION"] = "OperationTypeDefinition";
|
|
781
|
+
Kind["SCALAR_TYPE_DEFINITION"] = "ScalarTypeDefinition";
|
|
782
|
+
Kind["OBJECT_TYPE_DEFINITION"] = "ObjectTypeDefinition";
|
|
783
|
+
Kind["FIELD_DEFINITION"] = "FieldDefinition";
|
|
784
|
+
Kind["INPUT_VALUE_DEFINITION"] = "InputValueDefinition";
|
|
785
|
+
Kind["INTERFACE_TYPE_DEFINITION"] = "InterfaceTypeDefinition";
|
|
786
|
+
Kind["UNION_TYPE_DEFINITION"] = "UnionTypeDefinition";
|
|
787
|
+
Kind["ENUM_TYPE_DEFINITION"] = "EnumTypeDefinition";
|
|
788
|
+
Kind["ENUM_VALUE_DEFINITION"] = "EnumValueDefinition";
|
|
789
|
+
Kind["INPUT_OBJECT_TYPE_DEFINITION"] = "InputObjectTypeDefinition";
|
|
790
|
+
Kind["DIRECTIVE_DEFINITION"] = "DirectiveDefinition";
|
|
791
|
+
Kind["SCHEMA_EXTENSION"] = "SchemaExtension";
|
|
792
|
+
Kind["DIRECTIVE_EXTENSION"] = "DirectiveExtension";
|
|
793
|
+
Kind["SCALAR_TYPE_EXTENSION"] = "ScalarTypeExtension";
|
|
794
|
+
Kind["OBJECT_TYPE_EXTENSION"] = "ObjectTypeExtension";
|
|
795
|
+
Kind["INTERFACE_TYPE_EXTENSION"] = "InterfaceTypeExtension";
|
|
796
|
+
Kind["UNION_TYPE_EXTENSION"] = "UnionTypeExtension";
|
|
797
|
+
Kind["ENUM_TYPE_EXTENSION"] = "EnumTypeExtension";
|
|
798
|
+
Kind["INPUT_OBJECT_TYPE_EXTENSION"] = "InputObjectTypeExtension";
|
|
799
|
+
Kind["TYPE_COORDINATE"] = "TypeCoordinate";
|
|
800
|
+
Kind["MEMBER_COORDINATE"] = "MemberCoordinate";
|
|
801
|
+
Kind["ARGUMENT_COORDINATE"] = "ArgumentCoordinate";
|
|
802
|
+
Kind["DIRECTIVE_COORDINATE"] = "DirectiveCoordinate";
|
|
803
|
+
Kind["DIRECTIVE_ARGUMENT_COORDINATE"] = "DirectiveArgumentCoordinate";
|
|
804
|
+
})(Kind || (exports.Kind = Kind = {}));
|
|
805
|
+
}));
|
|
806
|
+
/**
|
|
807
|
+
* Deprecated legacy alias for the enum type representing the possible kind
|
|
808
|
+
* values of AST nodes. This alias will be removed in v17. In v17, `Kind` is
|
|
809
|
+
* exported as the single public symbol for both the runtime object and the
|
|
810
|
+
* corresponding TypeScript type.
|
|
811
|
+
* @deprecated Will be removed in v17. In v17, use `Kind` as both the runtime
|
|
812
|
+
* value and the type.
|
|
813
|
+
*/
|
|
814
|
+
//#endregion
|
|
815
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/jsutils/isObjectLike.js
|
|
816
|
+
var require_isObjectLike = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
817
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
818
|
+
exports.isObjectLike = isObjectLike;
|
|
819
|
+
/**
|
|
820
|
+
* Return true if `value` is object-like. A value is object-like if it's not
|
|
821
|
+
* `null` and has a `typeof` result of "object".
|
|
822
|
+
*
|
|
823
|
+
* @internal
|
|
824
|
+
*/
|
|
825
|
+
function isObjectLike(value) {
|
|
826
|
+
return typeof value == "object" && value !== null;
|
|
827
|
+
}
|
|
828
|
+
}));
|
|
829
|
+
//#endregion
|
|
830
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/jsutils/invariant.js
|
|
831
|
+
var require_invariant = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
832
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
833
|
+
exports.invariant = invariant;
|
|
834
|
+
/** @internal */
|
|
835
|
+
function invariant(condition, message) {
|
|
836
|
+
if (!Boolean(condition)) throw new Error(message != null ? message : "Unexpected invariant triggered.");
|
|
837
|
+
}
|
|
838
|
+
}));
|
|
839
|
+
//#endregion
|
|
840
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/location.js
|
|
841
|
+
var require_location = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
842
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
843
|
+
exports.getLocation = getLocation;
|
|
844
|
+
var _invariant = require_invariant();
|
|
845
|
+
/** @category Source */
|
|
846
|
+
const LineRegExp = /\r\n|[\n\r]/g;
|
|
847
|
+
/** Represents a location in a Source. */
|
|
848
|
+
/**
|
|
849
|
+
* Takes a Source and a UTF-8 character offset, and returns the corresponding
|
|
850
|
+
* line and column as a SourceLocation.
|
|
851
|
+
* @param source - The source document that contains the position.
|
|
852
|
+
* @param position - The UTF-8 character offset in the source body.
|
|
853
|
+
* @returns The 1-indexed line and column for the given source position.
|
|
854
|
+
* @example
|
|
855
|
+
* ```ts
|
|
856
|
+
* import { Source, getLocation } from 'graphql/language';
|
|
857
|
+
*
|
|
858
|
+
* const source = new Source('type Query { hello: String }');
|
|
859
|
+
* const location = getLocation(source, 13);
|
|
860
|
+
*
|
|
861
|
+
* location; // => { line: 1, column: 14 }
|
|
862
|
+
* ```
|
|
863
|
+
*/
|
|
864
|
+
function getLocation(source, position) {
|
|
865
|
+
let lastLineStart = 0;
|
|
866
|
+
let line = 1;
|
|
867
|
+
for (const match of source.body.matchAll(LineRegExp)) {
|
|
868
|
+
typeof match.index === "number" || (0, _invariant.invariant)(false);
|
|
869
|
+
if (match.index >= position) break;
|
|
870
|
+
lastLineStart = match.index + match[0].length;
|
|
871
|
+
line += 1;
|
|
872
|
+
}
|
|
873
|
+
return {
|
|
874
|
+
line,
|
|
875
|
+
column: position + 1 - lastLineStart
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
}));
|
|
879
|
+
//#endregion
|
|
880
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/printLocation.js
|
|
881
|
+
var require_printLocation = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
882
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
883
|
+
exports.printLocation = printLocation;
|
|
884
|
+
exports.printSourceLocation = printSourceLocation;
|
|
885
|
+
var _location = require_location();
|
|
886
|
+
/** @category Source */
|
|
887
|
+
/**
|
|
888
|
+
* Render a helpful description of the location in the GraphQL Source document.
|
|
889
|
+
* @param location - The AST location to print.
|
|
890
|
+
* @returns A formatted source excerpt with line and column information.
|
|
891
|
+
* @example
|
|
892
|
+
* ```ts
|
|
893
|
+
* import { parse, printLocation } from 'graphql/language';
|
|
894
|
+
*
|
|
895
|
+
* const document = parse('type Query { hello: String }');
|
|
896
|
+
* const location = document.definitions[0].loc;
|
|
897
|
+
*
|
|
898
|
+
* if (location) {
|
|
899
|
+
* const printed = printLocation(location);
|
|
900
|
+
*
|
|
901
|
+
* printed; // => 'GraphQL request:1:1\n1 | type Query { hello: String }\n | ^'
|
|
902
|
+
* }
|
|
903
|
+
* ```
|
|
904
|
+
*/
|
|
905
|
+
function printLocation(location) {
|
|
906
|
+
return printSourceLocation(location.source, (0, _location.getLocation)(location.source, location.start));
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Render a helpful description of the location in the GraphQL Source document.
|
|
910
|
+
* @param source - The source document that contains the location.
|
|
911
|
+
* @param sourceLocation - The 1-indexed line and column to print.
|
|
912
|
+
* @returns A formatted source excerpt with line and column information.
|
|
913
|
+
* @example
|
|
914
|
+
* ```ts
|
|
915
|
+
* import { Source, printSourceLocation } from 'graphql/language';
|
|
916
|
+
*
|
|
917
|
+
* const source = new Source('type Query { hello: String }');
|
|
918
|
+
* const printed = printSourceLocation(source, { line: 1, column: 14 });
|
|
919
|
+
*
|
|
920
|
+
* printed; // => 'GraphQL request:1:14\n1 | type Query { hello: String }\n | ^'
|
|
921
|
+
* ```
|
|
922
|
+
*/
|
|
923
|
+
function printSourceLocation(source, sourceLocation) {
|
|
924
|
+
const firstLineColumnOffset = source.locationOffset.column - 1;
|
|
925
|
+
const body = "".padStart(firstLineColumnOffset) + source.body;
|
|
926
|
+
const lineIndex = sourceLocation.line - 1;
|
|
927
|
+
const lineOffset = source.locationOffset.line - 1;
|
|
928
|
+
const lineNum = sourceLocation.line + lineOffset;
|
|
929
|
+
const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;
|
|
930
|
+
const columnNum = sourceLocation.column + columnOffset;
|
|
931
|
+
const locationStr = `${source.name}:${lineNum}:${columnNum}\n`;
|
|
932
|
+
const lines = body.split(/\r\n|[\n\r]/g);
|
|
933
|
+
const locationLine = lines[lineIndex];
|
|
934
|
+
if (locationLine.length > 120) {
|
|
935
|
+
const subLineIndex = Math.floor(columnNum / 80);
|
|
936
|
+
const subLineColumnNum = columnNum % 80;
|
|
937
|
+
const subLines = [];
|
|
938
|
+
for (let i = 0; i < locationLine.length; i += 80) subLines.push(locationLine.slice(i, i + 80));
|
|
939
|
+
return locationStr + printPrefixedLines([
|
|
940
|
+
[`${lineNum} |`, subLines[0]],
|
|
941
|
+
...subLines.slice(1, subLineIndex + 1).map((subLine) => ["|", subLine]),
|
|
942
|
+
["|", "^".padStart(subLineColumnNum)],
|
|
943
|
+
["|", subLines[subLineIndex + 1]]
|
|
944
|
+
]);
|
|
945
|
+
}
|
|
946
|
+
return locationStr + printPrefixedLines([
|
|
947
|
+
[`${lineNum - 1} |`, lines[lineIndex - 1]],
|
|
948
|
+
[`${lineNum} |`, locationLine],
|
|
949
|
+
["|", "^".padStart(columnNum)],
|
|
950
|
+
[`${lineNum + 1} |`, lines[lineIndex + 1]]
|
|
951
|
+
]);
|
|
952
|
+
}
|
|
953
|
+
function printPrefixedLines(lines) {
|
|
954
|
+
const existingLines = lines.filter(([_, line]) => line !== void 0);
|
|
955
|
+
const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
|
|
956
|
+
return existingLines.map(([prefix, line]) => prefix.padStart(padLen) + (line ? " " + line : "")).join("\n");
|
|
957
|
+
}
|
|
958
|
+
}));
|
|
959
|
+
//#endregion
|
|
960
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/error/GraphQLError.js
|
|
961
|
+
var require_GraphQLError = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
962
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
963
|
+
exports.GraphQLError = void 0;
|
|
964
|
+
exports.formatError = formatError;
|
|
965
|
+
exports.printError = printError;
|
|
966
|
+
var _isObjectLike = require_isObjectLike();
|
|
967
|
+
var _location = require_location();
|
|
968
|
+
var _printLocation = require_printLocation();
|
|
969
|
+
/** @category Errors */
|
|
970
|
+
function toNormalizedOptions(args) {
|
|
971
|
+
const firstArg = args[0];
|
|
972
|
+
if (firstArg == null || "kind" in firstArg || "length" in firstArg) return {
|
|
973
|
+
nodes: firstArg,
|
|
974
|
+
source: args[1],
|
|
975
|
+
positions: args[2],
|
|
976
|
+
path: args[3],
|
|
977
|
+
originalError: args[4],
|
|
978
|
+
extensions: args[5]
|
|
979
|
+
};
|
|
980
|
+
return firstArg;
|
|
981
|
+
}
|
|
982
|
+
exports.GraphQLError = class GraphQLError extends Error {
|
|
983
|
+
/**
|
|
984
|
+
* An array of `{ line, column }` locations within the source GraphQL document
|
|
985
|
+
* which correspond to this error.
|
|
986
|
+
*
|
|
987
|
+
* Errors during validation often contain multiple locations, for example to
|
|
988
|
+
* point out two things with the same name. Errors during execution include a
|
|
989
|
+
* single location, the field which produced the error.
|
|
990
|
+
*
|
|
991
|
+
* Enumerable, and appears in the result of JSON.stringify().
|
|
992
|
+
*/
|
|
993
|
+
/**
|
|
994
|
+
* An array describing the JSON-path into the execution response which
|
|
995
|
+
* corresponds to this error. Only included for errors during execution.
|
|
996
|
+
*
|
|
997
|
+
* Enumerable, and appears in the result of JSON.stringify().
|
|
998
|
+
*/
|
|
999
|
+
/** An array of GraphQL AST Nodes corresponding to this error. */
|
|
1000
|
+
/**
|
|
1001
|
+
* The source GraphQL document for the first location of this error.
|
|
1002
|
+
*
|
|
1003
|
+
* Note that if this Error represents more than one node, the source may not
|
|
1004
|
+
* represent nodes after the first node.
|
|
1005
|
+
*/
|
|
1006
|
+
/**
|
|
1007
|
+
* An array of character offsets within the source GraphQL document
|
|
1008
|
+
* which correspond to this error.
|
|
1009
|
+
*/
|
|
1010
|
+
/** Original error that caused this GraphQLError, if one exists. */
|
|
1011
|
+
/** Extension fields to add to the formatted error. */
|
|
1012
|
+
/**
|
|
1013
|
+
* Creates a GraphQLError instance.
|
|
1014
|
+
* @param message - Human-readable error message.
|
|
1015
|
+
* @param options - Error metadata such as source locations, response path, original error, and extensions.
|
|
1016
|
+
* This positional-arguments constructor overload is deprecated. Use the
|
|
1017
|
+
* `GraphQLError(message, options)` overload instead.
|
|
1018
|
+
* @example
|
|
1019
|
+
* ```ts
|
|
1020
|
+
* // Create an error from AST nodes and response metadata.
|
|
1021
|
+
* import { parse } from 'graphql/language';
|
|
1022
|
+
* import { GraphQLError } from 'graphql/error';
|
|
1023
|
+
*
|
|
1024
|
+
* const document = parse('{ greeting }');
|
|
1025
|
+
* const fieldNode = document.definitions[0].selectionSet.selections[0];
|
|
1026
|
+
* const error = new GraphQLError('Cannot query this field.', {
|
|
1027
|
+
* nodes: fieldNode,
|
|
1028
|
+
* path: ['greeting'],
|
|
1029
|
+
* extensions: { code: 'FORBIDDEN' },
|
|
1030
|
+
* });
|
|
1031
|
+
*
|
|
1032
|
+
* error.message; // => 'Cannot query this field.'
|
|
1033
|
+
* error.locations; // => [{ line: 1, column: 3 }]
|
|
1034
|
+
* error.path; // => ['greeting']
|
|
1035
|
+
* error.extensions; // => { code: 'FORBIDDEN' }
|
|
1036
|
+
* ```
|
|
1037
|
+
* @example
|
|
1038
|
+
* ```ts
|
|
1039
|
+
* // This variant derives locations from source positions and preserves the original error.
|
|
1040
|
+
* import { Source } from 'graphql/language';
|
|
1041
|
+
* import { GraphQLError } from 'graphql/error';
|
|
1042
|
+
*
|
|
1043
|
+
* const source = new Source('{ greeting }');
|
|
1044
|
+
* const originalError = new Error('Database unavailable.');
|
|
1045
|
+
* const error = new GraphQLError('Resolver failed.', {
|
|
1046
|
+
* source,
|
|
1047
|
+
* positions: [2],
|
|
1048
|
+
* path: ['greeting'],
|
|
1049
|
+
* originalError,
|
|
1050
|
+
* });
|
|
1051
|
+
*
|
|
1052
|
+
* error.locations; // => [{ line: 1, column: 3 }]
|
|
1053
|
+
* error.path; // => ['greeting']
|
|
1054
|
+
* error.originalError; // => originalError
|
|
1055
|
+
* ```
|
|
1056
|
+
*/
|
|
1057
|
+
/**
|
|
1058
|
+
* Creates a GraphQLError instance using the legacy positional constructor.
|
|
1059
|
+
* This deprecated overload will be removed in v17. Prefer the
|
|
1060
|
+
* `GraphQLErrorOptions` object overload, which keeps optional error metadata
|
|
1061
|
+
* in a single options bag.
|
|
1062
|
+
* @param message - Human-readable error message.
|
|
1063
|
+
* @param nodes - AST node or nodes associated with this error.
|
|
1064
|
+
* @param source - Source document used to derive error locations.
|
|
1065
|
+
* @param positions - Character offsets in the source document associated with
|
|
1066
|
+
* this error.
|
|
1067
|
+
* @param path - Response path where this error occurred during execution.
|
|
1068
|
+
* @param originalError - Original error that caused this GraphQLError, if one
|
|
1069
|
+
* exists.
|
|
1070
|
+
* @param extensions - Extension fields to include in the formatted error.
|
|
1071
|
+
* @example
|
|
1072
|
+
* ```ts
|
|
1073
|
+
* import { Source } from 'graphql/language';
|
|
1074
|
+
* import { GraphQLError } from 'graphql/error';
|
|
1075
|
+
*
|
|
1076
|
+
* const source = new Source('{ greeting }');
|
|
1077
|
+
* const originalError = new Error('Database unavailable.');
|
|
1078
|
+
* const error = new GraphQLError(
|
|
1079
|
+
* 'Resolver failed.',
|
|
1080
|
+
* undefined,
|
|
1081
|
+
* source,
|
|
1082
|
+
* [2],
|
|
1083
|
+
* ['greeting'],
|
|
1084
|
+
* originalError,
|
|
1085
|
+
* { code: 'INTERNAL' },
|
|
1086
|
+
* );
|
|
1087
|
+
*
|
|
1088
|
+
* error.locations; // => [{ line: 1, column: 3 }]
|
|
1089
|
+
* error.path; // => ['greeting']
|
|
1090
|
+
* error.originalError; // => originalError
|
|
1091
|
+
* error.extensions; // => { code: 'INTERNAL' }
|
|
1092
|
+
* ```
|
|
1093
|
+
* @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
|
|
1094
|
+
*/
|
|
1095
|
+
constructor(message, ...rawArgs) {
|
|
1096
|
+
var _this$nodes, _nodeLocations$, _ref;
|
|
1097
|
+
const { nodes, source, positions, path, originalError, extensions } = toNormalizedOptions(rawArgs);
|
|
1098
|
+
super(message);
|
|
1099
|
+
this.name = "GraphQLError";
|
|
1100
|
+
this.path = path !== null && path !== void 0 ? path : void 0;
|
|
1101
|
+
this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
|
|
1102
|
+
this.nodes = undefinedIfEmpty(Array.isArray(nodes) ? nodes : nodes ? [nodes] : void 0);
|
|
1103
|
+
const nodeLocations = undefinedIfEmpty((_this$nodes = this.nodes) === null || _this$nodes === void 0 ? void 0 : _this$nodes.map((node) => node.loc).filter((loc) => loc != null));
|
|
1104
|
+
this.source = source !== null && source !== void 0 ? source : nodeLocations === null || nodeLocations === void 0 ? void 0 : (_nodeLocations$ = nodeLocations[0]) === null || _nodeLocations$ === void 0 ? void 0 : _nodeLocations$.source;
|
|
1105
|
+
this.positions = positions !== null && positions !== void 0 ? positions : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => loc.start);
|
|
1106
|
+
this.locations = positions && source ? positions.map((pos) => (0, _location.getLocation)(source, pos)) : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => (0, _location.getLocation)(loc.source, loc.start));
|
|
1107
|
+
const originalExtensions = (0, _isObjectLike.isObjectLike)(originalError === null || originalError === void 0 ? void 0 : originalError.extensions) ? originalError === null || originalError === void 0 ? void 0 : originalError.extensions : void 0;
|
|
1108
|
+
this.extensions = (_ref = extensions !== null && extensions !== void 0 ? extensions : originalExtensions) !== null && _ref !== void 0 ? _ref : Object.create(null);
|
|
1109
|
+
Object.defineProperties(this, {
|
|
1110
|
+
message: {
|
|
1111
|
+
writable: true,
|
|
1112
|
+
enumerable: true
|
|
1113
|
+
},
|
|
1114
|
+
name: { enumerable: false },
|
|
1115
|
+
nodes: { enumerable: false },
|
|
1116
|
+
source: { enumerable: false },
|
|
1117
|
+
positions: { enumerable: false },
|
|
1118
|
+
originalError: { enumerable: false }
|
|
1119
|
+
});
|
|
1120
|
+
/* c8 ignore start */
|
|
1121
|
+
if (originalError !== null && originalError !== void 0 && originalError.stack) Object.defineProperty(this, "stack", {
|
|
1122
|
+
value: originalError.stack,
|
|
1123
|
+
writable: true,
|
|
1124
|
+
configurable: true
|
|
1125
|
+
});
|
|
1126
|
+
else if (Error.captureStackTrace) Error.captureStackTrace(this, GraphQLError);
|
|
1127
|
+
else Object.defineProperty(this, "stack", {
|
|
1128
|
+
value: Error().stack,
|
|
1129
|
+
writable: true,
|
|
1130
|
+
configurable: true
|
|
1131
|
+
});
|
|
1132
|
+
/* c8 ignore stop */
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
1136
|
+
* @returns The built-in string tag for this object.
|
|
1137
|
+
*/
|
|
1138
|
+
get [Symbol.toStringTag]() {
|
|
1139
|
+
return "GraphQLError";
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Returns this error as a human-readable message with source locations.
|
|
1143
|
+
* @returns The formatted error string.
|
|
1144
|
+
* @example
|
|
1145
|
+
* ```ts
|
|
1146
|
+
* import { Source } from 'graphql/language';
|
|
1147
|
+
* import { GraphQLError } from 'graphql/error';
|
|
1148
|
+
*
|
|
1149
|
+
* const error = new GraphQLError('Cannot query field "name".', {
|
|
1150
|
+
* source: new Source('{ name }'),
|
|
1151
|
+
* positions: [2],
|
|
1152
|
+
* });
|
|
1153
|
+
*
|
|
1154
|
+
* error.toString(); // => 'Cannot query field "name".\n\nGraphQL request:1:3\n1 | { name }\n | ^'
|
|
1155
|
+
* ```
|
|
1156
|
+
*/
|
|
1157
|
+
toString() {
|
|
1158
|
+
let output = this.message;
|
|
1159
|
+
if (this.nodes) {
|
|
1160
|
+
for (const node of this.nodes) if (node.loc) output += "\n\n" + (0, _printLocation.printLocation)(node.loc);
|
|
1161
|
+
} else if (this.source && this.locations) for (const location of this.locations) output += "\n\n" + (0, _printLocation.printSourceLocation)(this.source, location);
|
|
1162
|
+
return output;
|
|
1163
|
+
}
|
|
1164
|
+
/**
|
|
1165
|
+
* Returns the JSON representation used when this object is serialized.
|
|
1166
|
+
* @returns The JSON-serializable representation.
|
|
1167
|
+
* @example
|
|
1168
|
+
* ```ts
|
|
1169
|
+
* import { GraphQLError } from 'graphql/error';
|
|
1170
|
+
*
|
|
1171
|
+
* const error = new GraphQLError('Resolver failed.', {
|
|
1172
|
+
* path: ['viewer', 'name'],
|
|
1173
|
+
* extensions: { code: 'INTERNAL' },
|
|
1174
|
+
* });
|
|
1175
|
+
*
|
|
1176
|
+
* error.toJSON(); // => { message: 'Resolver failed.', path: ['viewer', 'name'], extensions: { code: 'INTERNAL' } }
|
|
1177
|
+
* ```
|
|
1178
|
+
*/
|
|
1179
|
+
toJSON() {
|
|
1180
|
+
const formattedError = { message: this.message };
|
|
1181
|
+
if (this.locations != null) formattedError.locations = this.locations;
|
|
1182
|
+
if (this.path != null) formattedError.path = this.path;
|
|
1183
|
+
if (this.extensions != null && Object.keys(this.extensions).length > 0) formattedError.extensions = this.extensions;
|
|
1184
|
+
return formattedError;
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
function undefinedIfEmpty(array) {
|
|
1188
|
+
return array === void 0 || array.length === 0 ? void 0 : array;
|
|
1189
|
+
}
|
|
1190
|
+
/** See: https://spec.graphql.org/draft/#sec-Errors */
|
|
1191
|
+
/**
|
|
1192
|
+
* Prints a GraphQLError to a string, representing useful location information
|
|
1193
|
+
* about the error's position in the source. This deprecated helper is retained
|
|
1194
|
+
* for backwards compatibility; call `error.toString()` instead because
|
|
1195
|
+
* printError will be removed in v17.
|
|
1196
|
+
* @param error - The error to format.
|
|
1197
|
+
* @returns The printed string representation.
|
|
1198
|
+
* @example
|
|
1199
|
+
* ```ts
|
|
1200
|
+
* import { GraphQLError, printError } from 'graphql/error';
|
|
1201
|
+
*
|
|
1202
|
+
* const message = printError(new GraphQLError('Example error'));
|
|
1203
|
+
*
|
|
1204
|
+
* message; // => 'Example error'
|
|
1205
|
+
* ```
|
|
1206
|
+
* @deprecated Please use `error.toString` instead. Will be removed in v17
|
|
1207
|
+
*/
|
|
1208
|
+
function printError(error) {
|
|
1209
|
+
return error.toString();
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Given a GraphQLError, format it according to the rules described by the
|
|
1213
|
+
* Response Format, Errors section of the GraphQL Specification. This deprecated
|
|
1214
|
+
* helper is retained for backwards compatibility; call `error.toJSON()`
|
|
1215
|
+
* instead because formatError will be removed in v17.
|
|
1216
|
+
* @param error - The error to format.
|
|
1217
|
+
* @returns The JSON-serializable formatted error.
|
|
1218
|
+
* @example
|
|
1219
|
+
* ```ts
|
|
1220
|
+
* import { GraphQLError, formatError } from 'graphql/error';
|
|
1221
|
+
*
|
|
1222
|
+
* const formatted = formatError(new GraphQLError('Example error'));
|
|
1223
|
+
*
|
|
1224
|
+
* formatted; // => { message: 'Example error' }
|
|
1225
|
+
* ```
|
|
1226
|
+
* @deprecated Please use `error.toJSON` instead. Will be removed in v17
|
|
1227
|
+
*/
|
|
1228
|
+
function formatError(error) {
|
|
1229
|
+
return error.toJSON();
|
|
1230
|
+
}
|
|
1231
|
+
}));
|
|
1232
|
+
//#endregion
|
|
1233
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/error/syntaxError.js
|
|
1234
|
+
var require_syntaxError = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1235
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1236
|
+
exports.syntaxError = syntaxError;
|
|
1237
|
+
var _GraphQLError = require_GraphQLError();
|
|
1238
|
+
/** @category Errors */
|
|
1239
|
+
/**
|
|
1240
|
+
* Produces a GraphQLError representing a syntax error, containing useful
|
|
1241
|
+
* descriptive information about the syntax error's position in the source.
|
|
1242
|
+
* @param source - The GraphQL source containing the syntax error.
|
|
1243
|
+
* @param position - Character offset where the syntax error was encountered.
|
|
1244
|
+
* @param description - Human-readable description of the syntax error.
|
|
1245
|
+
* @returns A GraphQLError located at the syntax error position.
|
|
1246
|
+
* @example
|
|
1247
|
+
* ```ts
|
|
1248
|
+
* import { Source } from 'graphql/language';
|
|
1249
|
+
* import { syntaxError } from 'graphql/error';
|
|
1250
|
+
*
|
|
1251
|
+
* const error = syntaxError(new Source('query {'), 7, 'Expected Name');
|
|
1252
|
+
*
|
|
1253
|
+
* error.message; // => 'Syntax Error: Expected Name'
|
|
1254
|
+
* error.locations; // => [{ line: 1, column: 8 }]
|
|
1255
|
+
* ```
|
|
1256
|
+
*/
|
|
1257
|
+
function syntaxError(source, position, description) {
|
|
1258
|
+
return new _GraphQLError.GraphQLError(`Syntax Error: ${description}`, {
|
|
1259
|
+
source,
|
|
1260
|
+
positions: [position]
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
}));
|
|
1264
|
+
//#endregion
|
|
1265
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/ast.js
|
|
1266
|
+
var require_ast = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1267
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1268
|
+
exports.Token = exports.QueryDocumentKeys = exports.OperationTypeNode = exports.Location = void 0;
|
|
1269
|
+
exports.isNode = isNode;
|
|
1270
|
+
/** @category AST */
|
|
1271
|
+
/**
|
|
1272
|
+
* Contains a range of UTF-8 character offsets and token references that
|
|
1273
|
+
* identify the region of the source from which the AST derived.
|
|
1274
|
+
*/
|
|
1275
|
+
var Location = class {
|
|
1276
|
+
/** The character offset at which this Node begins. */
|
|
1277
|
+
/** The character offset at which this Node ends. */
|
|
1278
|
+
/** The Token at which this Node begins. */
|
|
1279
|
+
/** The Token at which this Node ends. */
|
|
1280
|
+
/** The Source document the AST represents. */
|
|
1281
|
+
/**
|
|
1282
|
+
* Creates a Location instance.
|
|
1283
|
+
* @param startToken - The start token.
|
|
1284
|
+
* @param endToken - The end token.
|
|
1285
|
+
* @param source - Source document used to derive error locations.
|
|
1286
|
+
* @example
|
|
1287
|
+
* ```ts
|
|
1288
|
+
* import { Location, Source, Token, TokenKind } from 'graphql/language';
|
|
1289
|
+
*
|
|
1290
|
+
* const source = new Source('{ hello }');
|
|
1291
|
+
* const startToken = new Token(TokenKind.BRACE_L, 0, 1, 1, 1);
|
|
1292
|
+
* const endToken = new Token(TokenKind.BRACE_R, 8, 9, 1, 9);
|
|
1293
|
+
* const location = new Location(startToken, endToken, source);
|
|
1294
|
+
*
|
|
1295
|
+
* location.start; // => 0
|
|
1296
|
+
* location.end; // => 9
|
|
1297
|
+
* location.source.body; // => '{ hello }'
|
|
1298
|
+
* ```
|
|
1299
|
+
*/
|
|
1300
|
+
constructor(startToken, endToken, source) {
|
|
1301
|
+
this.start = startToken.start;
|
|
1302
|
+
this.end = endToken.end;
|
|
1303
|
+
this.startToken = startToken;
|
|
1304
|
+
this.endToken = endToken;
|
|
1305
|
+
this.source = source;
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
1309
|
+
* @returns The built-in string tag for this object.
|
|
1310
|
+
*/
|
|
1311
|
+
get [Symbol.toStringTag]() {
|
|
1312
|
+
return "Location";
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Returns a JSON representation of this location.
|
|
1316
|
+
* @returns The JSON-serializable representation.
|
|
1317
|
+
* @example
|
|
1318
|
+
* ```ts
|
|
1319
|
+
* import { parse } from 'graphql/language';
|
|
1320
|
+
*
|
|
1321
|
+
* const document = parse('{ hello }');
|
|
1322
|
+
* const location = document.loc?.toJSON();
|
|
1323
|
+
*
|
|
1324
|
+
* location; // => { start: 0, end: 9 }
|
|
1325
|
+
* ```
|
|
1326
|
+
*/
|
|
1327
|
+
toJSON() {
|
|
1328
|
+
return {
|
|
1329
|
+
start: this.start,
|
|
1330
|
+
end: this.end
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
};
|
|
1334
|
+
/**
|
|
1335
|
+
* Represents a range of characters represented by a lexical token
|
|
1336
|
+
* within a Source.
|
|
1337
|
+
*/
|
|
1338
|
+
exports.Location = Location;
|
|
1339
|
+
var Token = class {
|
|
1340
|
+
/** The kind of Token. */
|
|
1341
|
+
/** The character offset at which this Node begins. */
|
|
1342
|
+
/** The character offset at which this Node ends. */
|
|
1343
|
+
/** The 1-indexed line number on which this Token appears. */
|
|
1344
|
+
/** The 1-indexed column number at which this Token begins. */
|
|
1345
|
+
/**
|
|
1346
|
+
* For non-punctuation tokens, represents the interpreted value of the token.
|
|
1347
|
+
*
|
|
1348
|
+
* Note: is undefined for punctuation tokens, but typed as string for
|
|
1349
|
+
* convenience in the parser.
|
|
1350
|
+
*/
|
|
1351
|
+
/**
|
|
1352
|
+
* Tokens exist as nodes in a double-linked-list amongst all tokens
|
|
1353
|
+
* including ignored tokens. <SOF> is always the first node and <EOF>
|
|
1354
|
+
* the last.
|
|
1355
|
+
*/
|
|
1356
|
+
/** Next token in the token stream, including ignored tokens. */
|
|
1357
|
+
/**
|
|
1358
|
+
* Creates a Token instance.
|
|
1359
|
+
* @param kind - Token kind produced by lexical analysis.
|
|
1360
|
+
* @param start - Character offset where this token begins.
|
|
1361
|
+
* @param end - Character offset where this token ends.
|
|
1362
|
+
* @param line - One-indexed line number where this token begins.
|
|
1363
|
+
* @param column - One-indexed column number where this token begins.
|
|
1364
|
+
* @param value - Interpreted value for non-punctuation tokens.
|
|
1365
|
+
* @example
|
|
1366
|
+
* ```ts
|
|
1367
|
+
* import { Token, TokenKind } from 'graphql/language';
|
|
1368
|
+
*
|
|
1369
|
+
* const token = new Token(TokenKind.NAME, 2, 7, 1, 3, 'hello');
|
|
1370
|
+
*
|
|
1371
|
+
* token.kind; // => TokenKind.NAME
|
|
1372
|
+
* token.value; // => 'hello'
|
|
1373
|
+
* token.toJSON(); // => { kind: 'Name', value: 'hello', line: 1, column: 3 }
|
|
1374
|
+
* ```
|
|
1375
|
+
*/
|
|
1376
|
+
constructor(kind, start, end, line, column, value) {
|
|
1377
|
+
this.kind = kind;
|
|
1378
|
+
this.start = start;
|
|
1379
|
+
this.end = end;
|
|
1380
|
+
this.line = line;
|
|
1381
|
+
this.column = column;
|
|
1382
|
+
this.value = value;
|
|
1383
|
+
this.prev = null;
|
|
1384
|
+
this.next = null;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
1388
|
+
* @returns The built-in string tag for this object.
|
|
1389
|
+
*/
|
|
1390
|
+
get [Symbol.toStringTag]() {
|
|
1391
|
+
return "Token";
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* Returns a JSON representation of this token.
|
|
1395
|
+
* @returns The JSON-serializable representation.
|
|
1396
|
+
* @example
|
|
1397
|
+
* ```ts
|
|
1398
|
+
* import { Lexer, Source } from 'graphql/language';
|
|
1399
|
+
*
|
|
1400
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
1401
|
+
* const token = lexer.advance().toJSON();
|
|
1402
|
+
*
|
|
1403
|
+
* token; // => { kind: '{', value: undefined, line: 1, column: 1 }
|
|
1404
|
+
* ```
|
|
1405
|
+
*/
|
|
1406
|
+
toJSON() {
|
|
1407
|
+
return {
|
|
1408
|
+
kind: this.kind,
|
|
1409
|
+
value: this.value,
|
|
1410
|
+
line: this.line,
|
|
1411
|
+
column: this.column
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
};
|
|
1415
|
+
/** The list of all possible AST node types. */
|
|
1416
|
+
exports.Token = Token;
|
|
1417
|
+
/** @internal */
|
|
1418
|
+
const QueryDocumentKeys = {
|
|
1419
|
+
Name: [],
|
|
1420
|
+
Document: ["definitions"],
|
|
1421
|
+
OperationDefinition: [
|
|
1422
|
+
"description",
|
|
1423
|
+
"name",
|
|
1424
|
+
"variableDefinitions",
|
|
1425
|
+
"directives",
|
|
1426
|
+
"selectionSet"
|
|
1427
|
+
],
|
|
1428
|
+
VariableDefinition: [
|
|
1429
|
+
"description",
|
|
1430
|
+
"variable",
|
|
1431
|
+
"type",
|
|
1432
|
+
"defaultValue",
|
|
1433
|
+
"directives"
|
|
1434
|
+
],
|
|
1435
|
+
Variable: ["name"],
|
|
1436
|
+
SelectionSet: ["selections"],
|
|
1437
|
+
Field: [
|
|
1438
|
+
"alias",
|
|
1439
|
+
"name",
|
|
1440
|
+
"arguments",
|
|
1441
|
+
"directives",
|
|
1442
|
+
"selectionSet"
|
|
1443
|
+
],
|
|
1444
|
+
Argument: ["name", "value"],
|
|
1445
|
+
FragmentSpread: ["name", "directives"],
|
|
1446
|
+
InlineFragment: [
|
|
1447
|
+
"typeCondition",
|
|
1448
|
+
"directives",
|
|
1449
|
+
"selectionSet"
|
|
1450
|
+
],
|
|
1451
|
+
FragmentDefinition: [
|
|
1452
|
+
"description",
|
|
1453
|
+
"name",
|
|
1454
|
+
"variableDefinitions",
|
|
1455
|
+
"typeCondition",
|
|
1456
|
+
"directives",
|
|
1457
|
+
"selectionSet"
|
|
1458
|
+
],
|
|
1459
|
+
IntValue: [],
|
|
1460
|
+
FloatValue: [],
|
|
1461
|
+
StringValue: [],
|
|
1462
|
+
BooleanValue: [],
|
|
1463
|
+
NullValue: [],
|
|
1464
|
+
EnumValue: [],
|
|
1465
|
+
ListValue: ["values"],
|
|
1466
|
+
ObjectValue: ["fields"],
|
|
1467
|
+
ObjectField: ["name", "value"],
|
|
1468
|
+
Directive: ["name", "arguments"],
|
|
1469
|
+
NamedType: ["name"],
|
|
1470
|
+
ListType: ["type"],
|
|
1471
|
+
NonNullType: ["type"],
|
|
1472
|
+
SchemaDefinition: [
|
|
1473
|
+
"description",
|
|
1474
|
+
"directives",
|
|
1475
|
+
"operationTypes"
|
|
1476
|
+
],
|
|
1477
|
+
OperationTypeDefinition: ["type"],
|
|
1478
|
+
ScalarTypeDefinition: [
|
|
1479
|
+
"description",
|
|
1480
|
+
"name",
|
|
1481
|
+
"directives"
|
|
1482
|
+
],
|
|
1483
|
+
ObjectTypeDefinition: [
|
|
1484
|
+
"description",
|
|
1485
|
+
"name",
|
|
1486
|
+
"interfaces",
|
|
1487
|
+
"directives",
|
|
1488
|
+
"fields"
|
|
1489
|
+
],
|
|
1490
|
+
FieldDefinition: [
|
|
1491
|
+
"description",
|
|
1492
|
+
"name",
|
|
1493
|
+
"arguments",
|
|
1494
|
+
"type",
|
|
1495
|
+
"directives"
|
|
1496
|
+
],
|
|
1497
|
+
InputValueDefinition: [
|
|
1498
|
+
"description",
|
|
1499
|
+
"name",
|
|
1500
|
+
"type",
|
|
1501
|
+
"defaultValue",
|
|
1502
|
+
"directives"
|
|
1503
|
+
],
|
|
1504
|
+
InterfaceTypeDefinition: [
|
|
1505
|
+
"description",
|
|
1506
|
+
"name",
|
|
1507
|
+
"interfaces",
|
|
1508
|
+
"directives",
|
|
1509
|
+
"fields"
|
|
1510
|
+
],
|
|
1511
|
+
UnionTypeDefinition: [
|
|
1512
|
+
"description",
|
|
1513
|
+
"name",
|
|
1514
|
+
"directives",
|
|
1515
|
+
"types"
|
|
1516
|
+
],
|
|
1517
|
+
EnumTypeDefinition: [
|
|
1518
|
+
"description",
|
|
1519
|
+
"name",
|
|
1520
|
+
"directives",
|
|
1521
|
+
"values"
|
|
1522
|
+
],
|
|
1523
|
+
EnumValueDefinition: [
|
|
1524
|
+
"description",
|
|
1525
|
+
"name",
|
|
1526
|
+
"directives"
|
|
1527
|
+
],
|
|
1528
|
+
InputObjectTypeDefinition: [
|
|
1529
|
+
"description",
|
|
1530
|
+
"name",
|
|
1531
|
+
"directives",
|
|
1532
|
+
"fields"
|
|
1533
|
+
],
|
|
1534
|
+
DirectiveDefinition: [
|
|
1535
|
+
"description",
|
|
1536
|
+
"name",
|
|
1537
|
+
"arguments",
|
|
1538
|
+
"directives",
|
|
1539
|
+
"locations"
|
|
1540
|
+
],
|
|
1541
|
+
SchemaExtension: ["directives", "operationTypes"],
|
|
1542
|
+
DirectiveExtension: ["name", "directives"],
|
|
1543
|
+
ScalarTypeExtension: ["name", "directives"],
|
|
1544
|
+
ObjectTypeExtension: [
|
|
1545
|
+
"name",
|
|
1546
|
+
"interfaces",
|
|
1547
|
+
"directives",
|
|
1548
|
+
"fields"
|
|
1549
|
+
],
|
|
1550
|
+
InterfaceTypeExtension: [
|
|
1551
|
+
"name",
|
|
1552
|
+
"interfaces",
|
|
1553
|
+
"directives",
|
|
1554
|
+
"fields"
|
|
1555
|
+
],
|
|
1556
|
+
UnionTypeExtension: [
|
|
1557
|
+
"name",
|
|
1558
|
+
"directives",
|
|
1559
|
+
"types"
|
|
1560
|
+
],
|
|
1561
|
+
EnumTypeExtension: [
|
|
1562
|
+
"name",
|
|
1563
|
+
"directives",
|
|
1564
|
+
"values"
|
|
1565
|
+
],
|
|
1566
|
+
InputObjectTypeExtension: [
|
|
1567
|
+
"name",
|
|
1568
|
+
"directives",
|
|
1569
|
+
"fields"
|
|
1570
|
+
],
|
|
1571
|
+
TypeCoordinate: ["name"],
|
|
1572
|
+
MemberCoordinate: ["name", "memberName"],
|
|
1573
|
+
ArgumentCoordinate: [
|
|
1574
|
+
"name",
|
|
1575
|
+
"fieldName",
|
|
1576
|
+
"argumentName"
|
|
1577
|
+
],
|
|
1578
|
+
DirectiveCoordinate: ["name"],
|
|
1579
|
+
DirectiveArgumentCoordinate: ["name", "argumentName"]
|
|
1580
|
+
};
|
|
1581
|
+
exports.QueryDocumentKeys = QueryDocumentKeys;
|
|
1582
|
+
const kindValues = new Set(Object.keys(QueryDocumentKeys));
|
|
1583
|
+
/** @internal */
|
|
1584
|
+
function isNode(maybeNode) {
|
|
1585
|
+
const maybeKind = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.kind;
|
|
1586
|
+
return typeof maybeKind === "string" && kindValues.has(maybeKind);
|
|
1587
|
+
}
|
|
1588
|
+
/** An identifier in a GraphQL document. */
|
|
1589
|
+
/**
|
|
1590
|
+
* The operation types supported by GraphQL executable definitions.
|
|
1591
|
+
* @category Kinds
|
|
1592
|
+
*/
|
|
1593
|
+
var OperationTypeNode;
|
|
1594
|
+
exports.OperationTypeNode = OperationTypeNode;
|
|
1595
|
+
(function(OperationTypeNode) {
|
|
1596
|
+
OperationTypeNode["QUERY"] = "query";
|
|
1597
|
+
OperationTypeNode["MUTATION"] = "mutation";
|
|
1598
|
+
OperationTypeNode["SUBSCRIPTION"] = "subscription";
|
|
1599
|
+
})(OperationTypeNode || (exports.OperationTypeNode = OperationTypeNode = {}));
|
|
1600
|
+
}));
|
|
1601
|
+
/** A variable declaration in an operation or legacy fragment definition. */
|
|
1602
|
+
//#endregion
|
|
1603
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/directiveLocation.js
|
|
1604
|
+
var require_directiveLocation = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1605
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1606
|
+
exports.DirectiveLocation = void 0;
|
|
1607
|
+
/** @category Kinds */
|
|
1608
|
+
/** The set of allowed directive location values. */
|
|
1609
|
+
var DirectiveLocation;
|
|
1610
|
+
exports.DirectiveLocation = DirectiveLocation;
|
|
1611
|
+
(function(DirectiveLocation) {
|
|
1612
|
+
DirectiveLocation["QUERY"] = "QUERY";
|
|
1613
|
+
DirectiveLocation["MUTATION"] = "MUTATION";
|
|
1614
|
+
DirectiveLocation["SUBSCRIPTION"] = "SUBSCRIPTION";
|
|
1615
|
+
DirectiveLocation["FIELD"] = "FIELD";
|
|
1616
|
+
DirectiveLocation["FRAGMENT_DEFINITION"] = "FRAGMENT_DEFINITION";
|
|
1617
|
+
DirectiveLocation["FRAGMENT_SPREAD"] = "FRAGMENT_SPREAD";
|
|
1618
|
+
DirectiveLocation["INLINE_FRAGMENT"] = "INLINE_FRAGMENT";
|
|
1619
|
+
DirectiveLocation["VARIABLE_DEFINITION"] = "VARIABLE_DEFINITION";
|
|
1620
|
+
DirectiveLocation["SCHEMA"] = "SCHEMA";
|
|
1621
|
+
DirectiveLocation["SCALAR"] = "SCALAR";
|
|
1622
|
+
DirectiveLocation["OBJECT"] = "OBJECT";
|
|
1623
|
+
DirectiveLocation["FIELD_DEFINITION"] = "FIELD_DEFINITION";
|
|
1624
|
+
DirectiveLocation["ARGUMENT_DEFINITION"] = "ARGUMENT_DEFINITION";
|
|
1625
|
+
DirectiveLocation["INTERFACE"] = "INTERFACE";
|
|
1626
|
+
DirectiveLocation["UNION"] = "UNION";
|
|
1627
|
+
DirectiveLocation["ENUM"] = "ENUM";
|
|
1628
|
+
DirectiveLocation["ENUM_VALUE"] = "ENUM_VALUE";
|
|
1629
|
+
DirectiveLocation["INPUT_OBJECT"] = "INPUT_OBJECT";
|
|
1630
|
+
DirectiveLocation["INPUT_FIELD_DEFINITION"] = "INPUT_FIELD_DEFINITION";
|
|
1631
|
+
DirectiveLocation["DIRECTIVE_DEFINITION"] = "DIRECTIVE_DEFINITION";
|
|
1632
|
+
})(DirectiveLocation || (exports.DirectiveLocation = DirectiveLocation = {}));
|
|
1633
|
+
}));
|
|
1634
|
+
/**
|
|
1635
|
+
* Deprecated legacy alias for the enum type representing directive location
|
|
1636
|
+
* values. This alias will be removed in v17. In v17, `DirectiveLocation` is
|
|
1637
|
+
* exported as the single public symbol for both the runtime object and the
|
|
1638
|
+
* corresponding TypeScript type.
|
|
1639
|
+
* @deprecated Will be removed in v17. In v17, use `DirectiveLocation` as both
|
|
1640
|
+
* the runtime value and the type.
|
|
1641
|
+
*/
|
|
1642
|
+
//#endregion
|
|
1643
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/characterClasses.js
|
|
1644
|
+
var require_characterClasses = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1645
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1646
|
+
exports.isDigit = isDigit;
|
|
1647
|
+
exports.isLetter = isLetter;
|
|
1648
|
+
exports.isNameContinue = isNameContinue;
|
|
1649
|
+
exports.isNameStart = isNameStart;
|
|
1650
|
+
exports.isWhiteSpace = isWhiteSpace;
|
|
1651
|
+
/**
|
|
1652
|
+
* ```
|
|
1653
|
+
* WhiteSpace ::
|
|
1654
|
+
* - "Horizontal Tab (U+0009)"
|
|
1655
|
+
* - "Space (U+0020)"
|
|
1656
|
+
* ```
|
|
1657
|
+
* @internal
|
|
1658
|
+
*/
|
|
1659
|
+
function isWhiteSpace(code) {
|
|
1660
|
+
return code === 9 || code === 32;
|
|
1661
|
+
}
|
|
1662
|
+
/**
|
|
1663
|
+
* ```
|
|
1664
|
+
* Digit :: one of
|
|
1665
|
+
* - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
|
|
1666
|
+
* ```
|
|
1667
|
+
* @internal
|
|
1668
|
+
*/
|
|
1669
|
+
function isDigit(code) {
|
|
1670
|
+
return code >= 48 && code <= 57;
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* ```
|
|
1674
|
+
* Letter :: one of
|
|
1675
|
+
* - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M`
|
|
1676
|
+
* - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z`
|
|
1677
|
+
* - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m`
|
|
1678
|
+
* - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z`
|
|
1679
|
+
* ```
|
|
1680
|
+
* @internal
|
|
1681
|
+
*/
|
|
1682
|
+
function isLetter(code) {
|
|
1683
|
+
return code >= 97 && code <= 122 || code >= 65 && code <= 90;
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* ```
|
|
1687
|
+
* NameStart ::
|
|
1688
|
+
* - Letter
|
|
1689
|
+
* - `_`
|
|
1690
|
+
* ```
|
|
1691
|
+
* @internal
|
|
1692
|
+
*/
|
|
1693
|
+
function isNameStart(code) {
|
|
1694
|
+
return isLetter(code) || code === 95;
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* ```
|
|
1698
|
+
* NameContinue ::
|
|
1699
|
+
* - Letter
|
|
1700
|
+
* - Digit
|
|
1701
|
+
* - `_`
|
|
1702
|
+
* ```
|
|
1703
|
+
* @internal
|
|
1704
|
+
*/
|
|
1705
|
+
function isNameContinue(code) {
|
|
1706
|
+
return isLetter(code) || isDigit(code) || code === 95;
|
|
1707
|
+
}
|
|
1708
|
+
}));
|
|
1709
|
+
//#endregion
|
|
1710
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/blockString.js
|
|
1711
|
+
var require_blockString = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1712
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1713
|
+
exports.dedentBlockStringLines = dedentBlockStringLines;
|
|
1714
|
+
exports.isPrintableAsBlockString = isPrintableAsBlockString;
|
|
1715
|
+
exports.printBlockString = printBlockString;
|
|
1716
|
+
var _characterClasses = require_characterClasses();
|
|
1717
|
+
/**
|
|
1718
|
+
* Produces the value of a block string from its parsed raw value, similar to
|
|
1719
|
+
* CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
|
|
1720
|
+
*
|
|
1721
|
+
* This implements the GraphQL spec's BlockStringValue() static algorithm.
|
|
1722
|
+
*
|
|
1723
|
+
* @internal
|
|
1724
|
+
*/
|
|
1725
|
+
function dedentBlockStringLines(lines) {
|
|
1726
|
+
var _firstNonEmptyLine2;
|
|
1727
|
+
let commonIndent = Number.MAX_SAFE_INTEGER;
|
|
1728
|
+
let firstNonEmptyLine = null;
|
|
1729
|
+
let lastNonEmptyLine = -1;
|
|
1730
|
+
for (let i = 0; i < lines.length; ++i) {
|
|
1731
|
+
var _firstNonEmptyLine;
|
|
1732
|
+
const line = lines[i];
|
|
1733
|
+
const indent = leadingWhitespace(line);
|
|
1734
|
+
if (indent === line.length) continue;
|
|
1735
|
+
firstNonEmptyLine = (_firstNonEmptyLine = firstNonEmptyLine) !== null && _firstNonEmptyLine !== void 0 ? _firstNonEmptyLine : i;
|
|
1736
|
+
lastNonEmptyLine = i;
|
|
1737
|
+
if (i !== 0 && indent < commonIndent) commonIndent = indent;
|
|
1738
|
+
}
|
|
1739
|
+
return lines.map((line, i) => i === 0 ? line : line.slice(commonIndent)).slice((_firstNonEmptyLine2 = firstNonEmptyLine) !== null && _firstNonEmptyLine2 !== void 0 ? _firstNonEmptyLine2 : 0, lastNonEmptyLine + 1);
|
|
1740
|
+
}
|
|
1741
|
+
function leadingWhitespace(str) {
|
|
1742
|
+
let i = 0;
|
|
1743
|
+
while (i < str.length && (0, _characterClasses.isWhiteSpace)(str.charCodeAt(i))) ++i;
|
|
1744
|
+
return i;
|
|
1745
|
+
}
|
|
1746
|
+
/** @internal */
|
|
1747
|
+
function isPrintableAsBlockString(value) {
|
|
1748
|
+
if (value === "") return true;
|
|
1749
|
+
let isEmptyLine = true;
|
|
1750
|
+
let hasIndent = false;
|
|
1751
|
+
let hasCommonIndent = true;
|
|
1752
|
+
let seenNonEmptyLine = false;
|
|
1753
|
+
for (let i = 0; i < value.length; ++i) switch (value.codePointAt(i)) {
|
|
1754
|
+
case 0:
|
|
1755
|
+
case 1:
|
|
1756
|
+
case 2:
|
|
1757
|
+
case 3:
|
|
1758
|
+
case 4:
|
|
1759
|
+
case 5:
|
|
1760
|
+
case 6:
|
|
1761
|
+
case 7:
|
|
1762
|
+
case 8:
|
|
1763
|
+
case 11:
|
|
1764
|
+
case 12:
|
|
1765
|
+
case 14:
|
|
1766
|
+
case 15: return false;
|
|
1767
|
+
case 13: return false;
|
|
1768
|
+
case 10:
|
|
1769
|
+
if (isEmptyLine && !seenNonEmptyLine) return false;
|
|
1770
|
+
seenNonEmptyLine = true;
|
|
1771
|
+
isEmptyLine = true;
|
|
1772
|
+
hasIndent = false;
|
|
1773
|
+
break;
|
|
1774
|
+
case 9:
|
|
1775
|
+
case 32:
|
|
1776
|
+
hasIndent || (hasIndent = isEmptyLine);
|
|
1777
|
+
break;
|
|
1778
|
+
default:
|
|
1779
|
+
hasCommonIndent && (hasCommonIndent = hasIndent);
|
|
1780
|
+
isEmptyLine = false;
|
|
1781
|
+
}
|
|
1782
|
+
if (isEmptyLine) return false;
|
|
1783
|
+
if (hasCommonIndent && seenNonEmptyLine) return false;
|
|
1784
|
+
return true;
|
|
1785
|
+
}
|
|
1786
|
+
/**
|
|
1787
|
+
* Print a block string in the indented block form by adding a leading and
|
|
1788
|
+
* trailing blank line. However, if a block string starts with whitespace and is
|
|
1789
|
+
* a single-line, adding a leading blank line would strip that whitespace.
|
|
1790
|
+
*
|
|
1791
|
+
* @internal
|
|
1792
|
+
*/
|
|
1793
|
+
function printBlockString(value, options) {
|
|
1794
|
+
const escapedValue = value.replace(/"""/g, "\\\"\"\"");
|
|
1795
|
+
const lines = escapedValue.split(/\r\n|[\n\r]/g);
|
|
1796
|
+
const isSingleLine = lines.length === 1;
|
|
1797
|
+
const forceLeadingNewLine = lines.length > 1 && lines.slice(1).every((line) => line.length === 0 || (0, _characterClasses.isWhiteSpace)(line.charCodeAt(0)));
|
|
1798
|
+
const hasTrailingTripleQuotes = escapedValue.endsWith("\\\"\"\"");
|
|
1799
|
+
const hasTrailingQuote = value.endsWith("\"") && !hasTrailingTripleQuotes;
|
|
1800
|
+
const hasTrailingSlash = value.endsWith("\\");
|
|
1801
|
+
const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash;
|
|
1802
|
+
const printAsMultipleLines = !(options !== null && options !== void 0 && options.minimize) && (!isSingleLine || value.length > 70 || forceTrailingNewline || forceLeadingNewLine || hasTrailingTripleQuotes);
|
|
1803
|
+
let result = "";
|
|
1804
|
+
const skipLeadingNewLine = isSingleLine && (0, _characterClasses.isWhiteSpace)(value.charCodeAt(0));
|
|
1805
|
+
if (printAsMultipleLines && !skipLeadingNewLine || forceLeadingNewLine) result += "\n";
|
|
1806
|
+
result += escapedValue;
|
|
1807
|
+
if (printAsMultipleLines || forceTrailingNewline) result += "\n";
|
|
1808
|
+
return "\"\"\"" + result + "\"\"\"";
|
|
1809
|
+
}
|
|
1810
|
+
}));
|
|
1811
|
+
//#endregion
|
|
1812
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/tokenKind.js
|
|
1813
|
+
var require_tokenKind = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1814
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1815
|
+
exports.TokenKind = void 0;
|
|
1816
|
+
/** @category Lexing */
|
|
1817
|
+
/**
|
|
1818
|
+
* An exported enum describing the different kinds of tokens that the
|
|
1819
|
+
* lexer emits.
|
|
1820
|
+
*/
|
|
1821
|
+
var TokenKind;
|
|
1822
|
+
exports.TokenKind = TokenKind;
|
|
1823
|
+
(function(TokenKind) {
|
|
1824
|
+
TokenKind["SOF"] = "<SOF>";
|
|
1825
|
+
TokenKind["EOF"] = "<EOF>";
|
|
1826
|
+
TokenKind["BANG"] = "!";
|
|
1827
|
+
TokenKind["DOLLAR"] = "$";
|
|
1828
|
+
TokenKind["AMP"] = "&";
|
|
1829
|
+
TokenKind["PAREN_L"] = "(";
|
|
1830
|
+
TokenKind["PAREN_R"] = ")";
|
|
1831
|
+
TokenKind["DOT"] = ".";
|
|
1832
|
+
TokenKind["SPREAD"] = "...";
|
|
1833
|
+
TokenKind["COLON"] = ":";
|
|
1834
|
+
TokenKind["EQUALS"] = "=";
|
|
1835
|
+
TokenKind["AT"] = "@";
|
|
1836
|
+
TokenKind["BRACKET_L"] = "[";
|
|
1837
|
+
TokenKind["BRACKET_R"] = "]";
|
|
1838
|
+
TokenKind["BRACE_L"] = "{";
|
|
1839
|
+
TokenKind["PIPE"] = "|";
|
|
1840
|
+
TokenKind["BRACE_R"] = "}";
|
|
1841
|
+
TokenKind["NAME"] = "Name";
|
|
1842
|
+
TokenKind["INT"] = "Int";
|
|
1843
|
+
TokenKind["FLOAT"] = "Float";
|
|
1844
|
+
TokenKind["STRING"] = "String";
|
|
1845
|
+
TokenKind["BLOCK_STRING"] = "BlockString";
|
|
1846
|
+
TokenKind["COMMENT"] = "Comment";
|
|
1847
|
+
})(TokenKind || (exports.TokenKind = TokenKind = {}));
|
|
1848
|
+
}));
|
|
1849
|
+
/**
|
|
1850
|
+
* Deprecated legacy alias for the enum type representing token kind values.
|
|
1851
|
+
* This alias will be removed in v17. In v17, `TokenKind` is exported as the
|
|
1852
|
+
* single public symbol for both the runtime object and the corresponding
|
|
1853
|
+
* TypeScript type.
|
|
1854
|
+
* @deprecated Will be removed in v17. In v17, use `TokenKind` as both the
|
|
1855
|
+
* runtime value and the type.
|
|
1856
|
+
*/
|
|
1857
|
+
//#endregion
|
|
1858
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/lexer.js
|
|
1859
|
+
var require_lexer = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1860
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1861
|
+
exports.Lexer = void 0;
|
|
1862
|
+
exports.createToken = createToken;
|
|
1863
|
+
exports.isPunctuatorTokenKind = isPunctuatorTokenKind;
|
|
1864
|
+
exports.printCodePointAt = printCodePointAt;
|
|
1865
|
+
exports.readName = readName;
|
|
1866
|
+
var _syntaxError = require_syntaxError();
|
|
1867
|
+
var _ast = require_ast();
|
|
1868
|
+
var _blockString = require_blockString();
|
|
1869
|
+
var _characterClasses = require_characterClasses();
|
|
1870
|
+
var _tokenKind = require_tokenKind();
|
|
1871
|
+
/** @category Lexing */
|
|
1872
|
+
/**
|
|
1873
|
+
* Given a Source object, creates a Lexer for that source.
|
|
1874
|
+
* A Lexer is a stateful stream generator in that every time
|
|
1875
|
+
* it is advanced, it returns the next token in the Source. Assuming the
|
|
1876
|
+
* source lexes, the final Token emitted by the lexer will be of kind
|
|
1877
|
+
* EOF, after which the lexer will repeatedly return the same EOF token
|
|
1878
|
+
* whenever called.
|
|
1879
|
+
*/
|
|
1880
|
+
var Lexer = class {
|
|
1881
|
+
/** Source document used to derive error locations. */
|
|
1882
|
+
/** Most recent non-ignored token returned by the lexer. */
|
|
1883
|
+
/** Current non-ignored token at the lexer cursor. */
|
|
1884
|
+
/** The (1-indexed) line containing the current token. */
|
|
1885
|
+
/** Character offset where the current line starts. */
|
|
1886
|
+
/**
|
|
1887
|
+
* Creates a Lexer instance.
|
|
1888
|
+
* @param source - Source document used to derive error locations.
|
|
1889
|
+
* @example
|
|
1890
|
+
* ```ts
|
|
1891
|
+
* import { Lexer, Source, TokenKind } from 'graphql/language';
|
|
1892
|
+
*
|
|
1893
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
1894
|
+
*
|
|
1895
|
+
* lexer.token.kind; // => TokenKind.SOF
|
|
1896
|
+
* lexer.advance().kind; // => TokenKind.BRACE_L
|
|
1897
|
+
* lexer.advance().value; // => 'hello'
|
|
1898
|
+
* lexer.advance().kind; // => TokenKind.BRACE_R
|
|
1899
|
+
* ```
|
|
1900
|
+
*/
|
|
1901
|
+
constructor(source) {
|
|
1902
|
+
const startOfFileToken = new _ast.Token(_tokenKind.TokenKind.SOF, 0, 0, 0, 0);
|
|
1903
|
+
this.source = source;
|
|
1904
|
+
this.lastToken = startOfFileToken;
|
|
1905
|
+
this.token = startOfFileToken;
|
|
1906
|
+
this.line = 1;
|
|
1907
|
+
this.lineStart = 0;
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
1911
|
+
* @returns The built-in string tag for this object.
|
|
1912
|
+
*/
|
|
1913
|
+
get [Symbol.toStringTag]() {
|
|
1914
|
+
return "Lexer";
|
|
1915
|
+
}
|
|
1916
|
+
/**
|
|
1917
|
+
* Advances the token stream to the next non-ignored token.
|
|
1918
|
+
* @returns The next non-ignored token.
|
|
1919
|
+
* @example
|
|
1920
|
+
* ```ts
|
|
1921
|
+
* import { Lexer, Source } from 'graphql/language';
|
|
1922
|
+
*
|
|
1923
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
1924
|
+
* const token = lexer.advance();
|
|
1925
|
+
*
|
|
1926
|
+
* token.kind; // => '{'
|
|
1927
|
+
* lexer.token; // => token
|
|
1928
|
+
* ```
|
|
1929
|
+
*/
|
|
1930
|
+
advance() {
|
|
1931
|
+
this.lastToken = this.token;
|
|
1932
|
+
return this.token = this.lookahead();
|
|
1933
|
+
}
|
|
1934
|
+
/**
|
|
1935
|
+
* Looks ahead and returns the next non-ignored token, but does not change
|
|
1936
|
+
* the state of Lexer.
|
|
1937
|
+
* @returns The next non-ignored token without advancing the lexer.
|
|
1938
|
+
* @example
|
|
1939
|
+
* ```ts
|
|
1940
|
+
* import { Lexer, Source } from 'graphql/language';
|
|
1941
|
+
*
|
|
1942
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
1943
|
+
* const token = lexer.lookahead();
|
|
1944
|
+
*
|
|
1945
|
+
* token.kind; // => '{'
|
|
1946
|
+
* lexer.token.kind; // => '<SOF>'
|
|
1947
|
+
* ```
|
|
1948
|
+
*/
|
|
1949
|
+
lookahead() {
|
|
1950
|
+
let token = this.token;
|
|
1951
|
+
if (token.kind !== _tokenKind.TokenKind.EOF) do
|
|
1952
|
+
if (token.next) token = token.next;
|
|
1953
|
+
else {
|
|
1954
|
+
const nextToken = readNextToken(this, token.end);
|
|
1955
|
+
token.next = nextToken;
|
|
1956
|
+
nextToken.prev = token;
|
|
1957
|
+
token = nextToken;
|
|
1958
|
+
}
|
|
1959
|
+
while (token.kind === _tokenKind.TokenKind.COMMENT);
|
|
1960
|
+
return token;
|
|
1961
|
+
}
|
|
1962
|
+
};
|
|
1963
|
+
/** @internal */
|
|
1964
|
+
exports.Lexer = Lexer;
|
|
1965
|
+
function isPunctuatorTokenKind(kind) {
|
|
1966
|
+
return kind === _tokenKind.TokenKind.BANG || kind === _tokenKind.TokenKind.DOLLAR || kind === _tokenKind.TokenKind.AMP || kind === _tokenKind.TokenKind.PAREN_L || kind === _tokenKind.TokenKind.PAREN_R || kind === _tokenKind.TokenKind.DOT || kind === _tokenKind.TokenKind.SPREAD || kind === _tokenKind.TokenKind.COLON || kind === _tokenKind.TokenKind.EQUALS || kind === _tokenKind.TokenKind.AT || kind === _tokenKind.TokenKind.BRACKET_L || kind === _tokenKind.TokenKind.BRACKET_R || kind === _tokenKind.TokenKind.BRACE_L || kind === _tokenKind.TokenKind.PIPE || kind === _tokenKind.TokenKind.BRACE_R;
|
|
1967
|
+
}
|
|
1968
|
+
/**
|
|
1969
|
+
* A Unicode scalar value is any Unicode code point except surrogate code
|
|
1970
|
+
* points. In other words, the inclusive ranges of values 0x0000 to 0xD7FF and
|
|
1971
|
+
* 0xE000 to 0x10FFFF.
|
|
1972
|
+
*
|
|
1973
|
+
* SourceCharacter ::
|
|
1974
|
+
* - "Any Unicode scalar value"
|
|
1975
|
+
*
|
|
1976
|
+
* @internal
|
|
1977
|
+
*/
|
|
1978
|
+
function isUnicodeScalarValue(code) {
|
|
1979
|
+
return code >= 0 && code <= 55295 || code >= 57344 && code <= 1114111;
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* The GraphQL specification defines source text as a sequence of unicode scalar
|
|
1983
|
+
* values (which Unicode defines to exclude surrogate code points). However
|
|
1984
|
+
* JavaScript defines strings as a sequence of UTF-16 code units which may
|
|
1985
|
+
* include surrogates. A surrogate pair is a valid source character as it
|
|
1986
|
+
* encodes a supplementary code point (above U+FFFF), but unpaired surrogate
|
|
1987
|
+
* code points are not valid source characters.
|
|
1988
|
+
*
|
|
1989
|
+
* @internal
|
|
1990
|
+
*/
|
|
1991
|
+
function isSupplementaryCodePoint(body, location) {
|
|
1992
|
+
return isLeadingSurrogate(body.charCodeAt(location)) && isTrailingSurrogate(body.charCodeAt(location + 1));
|
|
1993
|
+
}
|
|
1994
|
+
function isLeadingSurrogate(code) {
|
|
1995
|
+
return code >= 55296 && code <= 56319;
|
|
1996
|
+
}
|
|
1997
|
+
function isTrailingSurrogate(code) {
|
|
1998
|
+
return code >= 56320 && code <= 57343;
|
|
1999
|
+
}
|
|
2000
|
+
/**
|
|
2001
|
+
* Prints the code point (or end of file reference) at a given location in a
|
|
2002
|
+
* source for use in error messages.
|
|
2003
|
+
*
|
|
2004
|
+
* Printable ASCII is printed quoted, while other points are printed in Unicode
|
|
2005
|
+
* code point form (ie. U+1234).
|
|
2006
|
+
*
|
|
2007
|
+
* @internal
|
|
2008
|
+
*/
|
|
2009
|
+
function printCodePointAt(lexer, location) {
|
|
2010
|
+
const code = lexer.source.body.codePointAt(location);
|
|
2011
|
+
if (code === void 0) return _tokenKind.TokenKind.EOF;
|
|
2012
|
+
else if (code >= 32 && code <= 126) {
|
|
2013
|
+
const char = String.fromCodePoint(code);
|
|
2014
|
+
return char === "\"" ? "'\"'" : `"${char}"`;
|
|
2015
|
+
}
|
|
2016
|
+
return "U+" + code.toString(16).toUpperCase().padStart(4, "0");
|
|
2017
|
+
}
|
|
2018
|
+
/**
|
|
2019
|
+
* Create a token with line and column location information.
|
|
2020
|
+
*
|
|
2021
|
+
* @internal
|
|
2022
|
+
*/
|
|
2023
|
+
function createToken(lexer, kind, start, end, value) {
|
|
2024
|
+
const line = lexer.line;
|
|
2025
|
+
const col = 1 + start - lexer.lineStart;
|
|
2026
|
+
return new _ast.Token(kind, start, end, line, col, value);
|
|
2027
|
+
}
|
|
2028
|
+
/**
|
|
2029
|
+
* Gets the next token from the source starting at the given position.
|
|
2030
|
+
*
|
|
2031
|
+
* This skips over whitespace until it finds the next lexable token, then lexes
|
|
2032
|
+
* punctuators immediately or calls the appropriate helper function for more
|
|
2033
|
+
* complicated tokens.
|
|
2034
|
+
*
|
|
2035
|
+
* @internal
|
|
2036
|
+
*/
|
|
2037
|
+
function readNextToken(lexer, start) {
|
|
2038
|
+
const body = lexer.source.body;
|
|
2039
|
+
const bodyLength = body.length;
|
|
2040
|
+
let position = start;
|
|
2041
|
+
while (position < bodyLength) {
|
|
2042
|
+
const code = body.charCodeAt(position);
|
|
2043
|
+
switch (code) {
|
|
2044
|
+
case 65279:
|
|
2045
|
+
case 9:
|
|
2046
|
+
case 32:
|
|
2047
|
+
case 44:
|
|
2048
|
+
++position;
|
|
2049
|
+
continue;
|
|
2050
|
+
case 10:
|
|
2051
|
+
++position;
|
|
2052
|
+
++lexer.line;
|
|
2053
|
+
lexer.lineStart = position;
|
|
2054
|
+
continue;
|
|
2055
|
+
case 13:
|
|
2056
|
+
if (body.charCodeAt(position + 1) === 10) position += 2;
|
|
2057
|
+
else ++position;
|
|
2058
|
+
++lexer.line;
|
|
2059
|
+
lexer.lineStart = position;
|
|
2060
|
+
continue;
|
|
2061
|
+
case 35: return readComment(lexer, position);
|
|
2062
|
+
case 33: return createToken(lexer, _tokenKind.TokenKind.BANG, position, position + 1);
|
|
2063
|
+
case 36: return createToken(lexer, _tokenKind.TokenKind.DOLLAR, position, position + 1);
|
|
2064
|
+
case 38: return createToken(lexer, _tokenKind.TokenKind.AMP, position, position + 1);
|
|
2065
|
+
case 40: return createToken(lexer, _tokenKind.TokenKind.PAREN_L, position, position + 1);
|
|
2066
|
+
case 41: return createToken(lexer, _tokenKind.TokenKind.PAREN_R, position, position + 1);
|
|
2067
|
+
case 46:
|
|
2068
|
+
if (body.charCodeAt(position + 1) === 46 && body.charCodeAt(position + 2) === 46) return createToken(lexer, _tokenKind.TokenKind.SPREAD, position, position + 3);
|
|
2069
|
+
break;
|
|
2070
|
+
case 58: return createToken(lexer, _tokenKind.TokenKind.COLON, position, position + 1);
|
|
2071
|
+
case 61: return createToken(lexer, _tokenKind.TokenKind.EQUALS, position, position + 1);
|
|
2072
|
+
case 64: return createToken(lexer, _tokenKind.TokenKind.AT, position, position + 1);
|
|
2073
|
+
case 91: return createToken(lexer, _tokenKind.TokenKind.BRACKET_L, position, position + 1);
|
|
2074
|
+
case 93: return createToken(lexer, _tokenKind.TokenKind.BRACKET_R, position, position + 1);
|
|
2075
|
+
case 123: return createToken(lexer, _tokenKind.TokenKind.BRACE_L, position, position + 1);
|
|
2076
|
+
case 124: return createToken(lexer, _tokenKind.TokenKind.PIPE, position, position + 1);
|
|
2077
|
+
case 125: return createToken(lexer, _tokenKind.TokenKind.BRACE_R, position, position + 1);
|
|
2078
|
+
case 34:
|
|
2079
|
+
if (body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) return readBlockString(lexer, position);
|
|
2080
|
+
return readString(lexer, position);
|
|
2081
|
+
}
|
|
2082
|
+
if ((0, _characterClasses.isDigit)(code) || code === 45) return readNumber(lexer, position, code);
|
|
2083
|
+
if ((0, _characterClasses.isNameStart)(code)) return readName(lexer, position);
|
|
2084
|
+
throw (0, _syntaxError.syntaxError)(lexer.source, position, code === 39 ? "Unexpected single quote character ('), did you mean to use a double quote (\")?" : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position) ? `Unexpected character: ${printCodePointAt(lexer, position)}.` : `Invalid character: ${printCodePointAt(lexer, position)}.`);
|
|
2085
|
+
}
|
|
2086
|
+
return createToken(lexer, _tokenKind.TokenKind.EOF, bodyLength, bodyLength);
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* Reads a comment token from the source file.
|
|
2090
|
+
*
|
|
2091
|
+
* ```
|
|
2092
|
+
* Comment :: # CommentChar* [lookahead != CommentChar]
|
|
2093
|
+
*
|
|
2094
|
+
* CommentChar :: SourceCharacter but not LineTerminator
|
|
2095
|
+
* ```
|
|
2096
|
+
*
|
|
2097
|
+
* @internal
|
|
2098
|
+
*/
|
|
2099
|
+
function readComment(lexer, start) {
|
|
2100
|
+
const body = lexer.source.body;
|
|
2101
|
+
const bodyLength = body.length;
|
|
2102
|
+
let position = start + 1;
|
|
2103
|
+
while (position < bodyLength) {
|
|
2104
|
+
const code = body.charCodeAt(position);
|
|
2105
|
+
if (code === 10 || code === 13) break;
|
|
2106
|
+
if (isUnicodeScalarValue(code)) ++position;
|
|
2107
|
+
else if (isSupplementaryCodePoint(body, position)) position += 2;
|
|
2108
|
+
else break;
|
|
2109
|
+
}
|
|
2110
|
+
return createToken(lexer, _tokenKind.TokenKind.COMMENT, start, position, body.slice(start + 1, position));
|
|
2111
|
+
}
|
|
2112
|
+
/**
|
|
2113
|
+
* Reads a number token from the source file, either a FloatValue or an IntValue
|
|
2114
|
+
* depending on whether a FractionalPart or ExponentPart is encountered.
|
|
2115
|
+
*
|
|
2116
|
+
* ```
|
|
2117
|
+
* IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}]
|
|
2118
|
+
*
|
|
2119
|
+
* IntegerPart ::
|
|
2120
|
+
* - NegativeSign? 0
|
|
2121
|
+
* - NegativeSign? NonZeroDigit Digit*
|
|
2122
|
+
*
|
|
2123
|
+
* NegativeSign :: -
|
|
2124
|
+
*
|
|
2125
|
+
* NonZeroDigit :: Digit but not `0`
|
|
2126
|
+
*
|
|
2127
|
+
* FloatValue ::
|
|
2128
|
+
* - IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}]
|
|
2129
|
+
* - IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}]
|
|
2130
|
+
* - IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}]
|
|
2131
|
+
*
|
|
2132
|
+
* FractionalPart :: . Digit+
|
|
2133
|
+
*
|
|
2134
|
+
* ExponentPart :: ExponentIndicator Sign? Digit+
|
|
2135
|
+
*
|
|
2136
|
+
* ExponentIndicator :: one of `e` `E`
|
|
2137
|
+
*
|
|
2138
|
+
* Sign :: one of + -
|
|
2139
|
+
* ```
|
|
2140
|
+
*
|
|
2141
|
+
* @internal
|
|
2142
|
+
*/
|
|
2143
|
+
function readNumber(lexer, start, firstCode) {
|
|
2144
|
+
const body = lexer.source.body;
|
|
2145
|
+
let position = start;
|
|
2146
|
+
let code = firstCode;
|
|
2147
|
+
let isFloat = false;
|
|
2148
|
+
if (code === 45) code = body.charCodeAt(++position);
|
|
2149
|
+
if (code === 48) {
|
|
2150
|
+
code = body.charCodeAt(++position);
|
|
2151
|
+
if ((0, _characterClasses.isDigit)(code)) throw (0, _syntaxError.syntaxError)(lexer.source, position, `Invalid number, unexpected digit after 0: ${printCodePointAt(lexer, position)}.`);
|
|
2152
|
+
} else {
|
|
2153
|
+
position = readDigits(lexer, position, code);
|
|
2154
|
+
code = body.charCodeAt(position);
|
|
2155
|
+
}
|
|
2156
|
+
if (code === 46) {
|
|
2157
|
+
isFloat = true;
|
|
2158
|
+
code = body.charCodeAt(++position);
|
|
2159
|
+
position = readDigits(lexer, position, code);
|
|
2160
|
+
code = body.charCodeAt(position);
|
|
2161
|
+
}
|
|
2162
|
+
if (code === 69 || code === 101) {
|
|
2163
|
+
isFloat = true;
|
|
2164
|
+
code = body.charCodeAt(++position);
|
|
2165
|
+
if (code === 43 || code === 45) code = body.charCodeAt(++position);
|
|
2166
|
+
position = readDigits(lexer, position, code);
|
|
2167
|
+
code = body.charCodeAt(position);
|
|
2168
|
+
}
|
|
2169
|
+
if (code === 46 || (0, _characterClasses.isNameStart)(code)) throw (0, _syntaxError.syntaxError)(lexer.source, position, `Invalid number, expected digit but got: ${printCodePointAt(lexer, position)}.`);
|
|
2170
|
+
return createToken(lexer, isFloat ? _tokenKind.TokenKind.FLOAT : _tokenKind.TokenKind.INT, start, position, body.slice(start, position));
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Returns the new position in the source after reading one or more digits.
|
|
2174
|
+
*
|
|
2175
|
+
* @internal
|
|
2176
|
+
*/
|
|
2177
|
+
function readDigits(lexer, start, firstCode) {
|
|
2178
|
+
if (!(0, _characterClasses.isDigit)(firstCode)) throw (0, _syntaxError.syntaxError)(lexer.source, start, `Invalid number, expected digit but got: ${printCodePointAt(lexer, start)}.`);
|
|
2179
|
+
const body = lexer.source.body;
|
|
2180
|
+
let position = start + 1;
|
|
2181
|
+
while ((0, _characterClasses.isDigit)(body.charCodeAt(position))) ++position;
|
|
2182
|
+
return position;
|
|
2183
|
+
}
|
|
2184
|
+
/**
|
|
2185
|
+
* Reads a single-quote string token from the source file.
|
|
2186
|
+
*
|
|
2187
|
+
* ```
|
|
2188
|
+
* StringValue ::
|
|
2189
|
+
* - `""` [lookahead != `"`]
|
|
2190
|
+
* - `"` StringCharacter+ `"`
|
|
2191
|
+
*
|
|
2192
|
+
* StringCharacter ::
|
|
2193
|
+
* - SourceCharacter but not `"` or `\` or LineTerminator
|
|
2194
|
+
* - `\u` EscapedUnicode
|
|
2195
|
+
* - `\` EscapedCharacter
|
|
2196
|
+
*
|
|
2197
|
+
* EscapedUnicode ::
|
|
2198
|
+
* - `{` HexDigit+ `}`
|
|
2199
|
+
* - HexDigit HexDigit HexDigit HexDigit
|
|
2200
|
+
*
|
|
2201
|
+
* EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t`
|
|
2202
|
+
* ```
|
|
2203
|
+
*
|
|
2204
|
+
* @internal
|
|
2205
|
+
*/
|
|
2206
|
+
function readString(lexer, start) {
|
|
2207
|
+
const body = lexer.source.body;
|
|
2208
|
+
const bodyLength = body.length;
|
|
2209
|
+
let position = start + 1;
|
|
2210
|
+
let chunkStart = position;
|
|
2211
|
+
let value = "";
|
|
2212
|
+
while (position < bodyLength) {
|
|
2213
|
+
const code = body.charCodeAt(position);
|
|
2214
|
+
if (code === 34) {
|
|
2215
|
+
value += body.slice(chunkStart, position);
|
|
2216
|
+
return createToken(lexer, _tokenKind.TokenKind.STRING, start, position + 1, value);
|
|
2217
|
+
}
|
|
2218
|
+
if (code === 92) {
|
|
2219
|
+
value += body.slice(chunkStart, position);
|
|
2220
|
+
const escape = body.charCodeAt(position + 1) === 117 ? body.charCodeAt(position + 2) === 123 ? readEscapedUnicodeVariableWidth(lexer, position) : readEscapedUnicodeFixedWidth(lexer, position) : readEscapedCharacter(lexer, position);
|
|
2221
|
+
value += escape.value;
|
|
2222
|
+
position += escape.size;
|
|
2223
|
+
chunkStart = position;
|
|
2224
|
+
continue;
|
|
2225
|
+
}
|
|
2226
|
+
if (code === 10 || code === 13) break;
|
|
2227
|
+
if (isUnicodeScalarValue(code)) ++position;
|
|
2228
|
+
else if (isSupplementaryCodePoint(body, position)) position += 2;
|
|
2229
|
+
else throw (0, _syntaxError.syntaxError)(lexer.source, position, `Invalid character within String: ${printCodePointAt(lexer, position)}.`);
|
|
2230
|
+
}
|
|
2231
|
+
throw (0, _syntaxError.syntaxError)(lexer.source, position, "Unterminated string.");
|
|
2232
|
+
}
|
|
2233
|
+
function readEscapedUnicodeVariableWidth(lexer, position) {
|
|
2234
|
+
const body = lexer.source.body;
|
|
2235
|
+
let point = 0;
|
|
2236
|
+
let size = 3;
|
|
2237
|
+
while (size < 12) {
|
|
2238
|
+
const code = body.charCodeAt(position + size++);
|
|
2239
|
+
if (code === 125) {
|
|
2240
|
+
if (size < 5 || !isUnicodeScalarValue(point)) break;
|
|
2241
|
+
return {
|
|
2242
|
+
value: String.fromCodePoint(point),
|
|
2243
|
+
size
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2246
|
+
point = point << 4 | readHexDigit(code);
|
|
2247
|
+
if (point < 0) break;
|
|
2248
|
+
}
|
|
2249
|
+
throw (0, _syntaxError.syntaxError)(lexer.source, position, `Invalid Unicode escape sequence: "${body.slice(position, position + size)}".`);
|
|
2250
|
+
}
|
|
2251
|
+
function readEscapedUnicodeFixedWidth(lexer, position) {
|
|
2252
|
+
const body = lexer.source.body;
|
|
2253
|
+
const code = read16BitHexCode(body, position + 2);
|
|
2254
|
+
if (isUnicodeScalarValue(code)) return {
|
|
2255
|
+
value: String.fromCodePoint(code),
|
|
2256
|
+
size: 6
|
|
2257
|
+
};
|
|
2258
|
+
if (isLeadingSurrogate(code)) {
|
|
2259
|
+
if (body.charCodeAt(position + 6) === 92 && body.charCodeAt(position + 7) === 117) {
|
|
2260
|
+
const trailingCode = read16BitHexCode(body, position + 8);
|
|
2261
|
+
if (isTrailingSurrogate(trailingCode)) return {
|
|
2262
|
+
value: String.fromCodePoint(code, trailingCode),
|
|
2263
|
+
size: 12
|
|
2264
|
+
};
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
throw (0, _syntaxError.syntaxError)(lexer.source, position, `Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`);
|
|
2268
|
+
}
|
|
2269
|
+
/**
|
|
2270
|
+
* Reads four hexadecimal characters and returns the positive integer that 16bit
|
|
2271
|
+
* hexadecimal string represents. For example, "000f" will return 15, and "dead"
|
|
2272
|
+
* will return 57005.
|
|
2273
|
+
*
|
|
2274
|
+
* Returns a negative number if any char was not a valid hexadecimal digit.
|
|
2275
|
+
*
|
|
2276
|
+
* @internal
|
|
2277
|
+
*/
|
|
2278
|
+
function read16BitHexCode(body, position) {
|
|
2279
|
+
return readHexDigit(body.charCodeAt(position)) << 12 | readHexDigit(body.charCodeAt(position + 1)) << 8 | readHexDigit(body.charCodeAt(position + 2)) << 4 | readHexDigit(body.charCodeAt(position + 3));
|
|
2280
|
+
}
|
|
2281
|
+
/**
|
|
2282
|
+
* Reads a hexadecimal character and returns its positive integer value (0-15).
|
|
2283
|
+
*
|
|
2284
|
+
* '0' becomes 0, '9' becomes 9
|
|
2285
|
+
* 'A' becomes 10, 'F' becomes 15
|
|
2286
|
+
* 'a' becomes 10, 'f' becomes 15
|
|
2287
|
+
*
|
|
2288
|
+
* Returns -1 if the provided character code was not a valid hexadecimal digit.
|
|
2289
|
+
*
|
|
2290
|
+
* HexDigit :: one of
|
|
2291
|
+
* - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
|
|
2292
|
+
* - `A` `B` `C` `D` `E` `F`
|
|
2293
|
+
* - `a` `b` `c` `d` `e` `f`
|
|
2294
|
+
*
|
|
2295
|
+
* @internal
|
|
2296
|
+
*/
|
|
2297
|
+
function readHexDigit(code) {
|
|
2298
|
+
return code >= 48 && code <= 57 ? code - 48 : code >= 65 && code <= 70 ? code - 55 : code >= 97 && code <= 102 ? code - 87 : -1;
|
|
2299
|
+
}
|
|
2300
|
+
/**
|
|
2301
|
+
* | Escaped Character | Code Point | Character Name |
|
|
2302
|
+
* | ----------------- | ---------- | ---------------------------- |
|
|
2303
|
+
* | `"` | U+0022 | double quote |
|
|
2304
|
+
* | `\` | U+005C | reverse solidus (back slash) |
|
|
2305
|
+
* | `/` | U+002F | solidus (forward slash) |
|
|
2306
|
+
* | `b` | U+0008 | backspace |
|
|
2307
|
+
* | `f` | U+000C | form feed |
|
|
2308
|
+
* | `n` | U+000A | line feed (new line) |
|
|
2309
|
+
* | `r` | U+000D | carriage return |
|
|
2310
|
+
* | `t` | U+0009 | horizontal tab |
|
|
2311
|
+
*
|
|
2312
|
+
* @internal
|
|
2313
|
+
*/
|
|
2314
|
+
function readEscapedCharacter(lexer, position) {
|
|
2315
|
+
const body = lexer.source.body;
|
|
2316
|
+
switch (body.charCodeAt(position + 1)) {
|
|
2317
|
+
case 34: return {
|
|
2318
|
+
value: "\"",
|
|
2319
|
+
size: 2
|
|
2320
|
+
};
|
|
2321
|
+
case 92: return {
|
|
2322
|
+
value: "\\",
|
|
2323
|
+
size: 2
|
|
2324
|
+
};
|
|
2325
|
+
case 47: return {
|
|
2326
|
+
value: "/",
|
|
2327
|
+
size: 2
|
|
2328
|
+
};
|
|
2329
|
+
case 98: return {
|
|
2330
|
+
value: "\b",
|
|
2331
|
+
size: 2
|
|
2332
|
+
};
|
|
2333
|
+
case 102: return {
|
|
2334
|
+
value: "\f",
|
|
2335
|
+
size: 2
|
|
2336
|
+
};
|
|
2337
|
+
case 110: return {
|
|
2338
|
+
value: "\n",
|
|
2339
|
+
size: 2
|
|
2340
|
+
};
|
|
2341
|
+
case 114: return {
|
|
2342
|
+
value: "\r",
|
|
2343
|
+
size: 2
|
|
2344
|
+
};
|
|
2345
|
+
case 116: return {
|
|
2346
|
+
value: " ",
|
|
2347
|
+
size: 2
|
|
2348
|
+
};
|
|
2349
|
+
}
|
|
2350
|
+
throw (0, _syntaxError.syntaxError)(lexer.source, position, `Invalid character escape sequence: "${body.slice(position, position + 2)}".`);
|
|
2351
|
+
}
|
|
2352
|
+
/**
|
|
2353
|
+
* Reads a block string token from the source file.
|
|
2354
|
+
*
|
|
2355
|
+
* ```
|
|
2356
|
+
* StringValue ::
|
|
2357
|
+
* - `"""` BlockStringCharacter* `"""`
|
|
2358
|
+
*
|
|
2359
|
+
* BlockStringCharacter ::
|
|
2360
|
+
* - SourceCharacter but not `"""` or `\"""`
|
|
2361
|
+
* - `\"""`
|
|
2362
|
+
* ```
|
|
2363
|
+
*
|
|
2364
|
+
* @internal
|
|
2365
|
+
*/
|
|
2366
|
+
function readBlockString(lexer, start) {
|
|
2367
|
+
const body = lexer.source.body;
|
|
2368
|
+
const bodyLength = body.length;
|
|
2369
|
+
let lineStart = lexer.lineStart;
|
|
2370
|
+
let position = start + 3;
|
|
2371
|
+
let chunkStart = position;
|
|
2372
|
+
let currentLine = "";
|
|
2373
|
+
const blockLines = [];
|
|
2374
|
+
while (position < bodyLength) {
|
|
2375
|
+
const code = body.charCodeAt(position);
|
|
2376
|
+
if (code === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
|
|
2377
|
+
currentLine += body.slice(chunkStart, position);
|
|
2378
|
+
blockLines.push(currentLine);
|
|
2379
|
+
const token = createToken(lexer, _tokenKind.TokenKind.BLOCK_STRING, start, position + 3, (0, _blockString.dedentBlockStringLines)(blockLines).join("\n"));
|
|
2380
|
+
lexer.line += blockLines.length - 1;
|
|
2381
|
+
lexer.lineStart = lineStart;
|
|
2382
|
+
return token;
|
|
2383
|
+
}
|
|
2384
|
+
if (code === 92 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34 && body.charCodeAt(position + 3) === 34) {
|
|
2385
|
+
currentLine += body.slice(chunkStart, position);
|
|
2386
|
+
chunkStart = position + 1;
|
|
2387
|
+
position += 4;
|
|
2388
|
+
continue;
|
|
2389
|
+
}
|
|
2390
|
+
if (code === 10 || code === 13) {
|
|
2391
|
+
currentLine += body.slice(chunkStart, position);
|
|
2392
|
+
blockLines.push(currentLine);
|
|
2393
|
+
if (code === 13 && body.charCodeAt(position + 1) === 10) position += 2;
|
|
2394
|
+
else ++position;
|
|
2395
|
+
currentLine = "";
|
|
2396
|
+
chunkStart = position;
|
|
2397
|
+
lineStart = position;
|
|
2398
|
+
continue;
|
|
2399
|
+
}
|
|
2400
|
+
if (isUnicodeScalarValue(code)) ++position;
|
|
2401
|
+
else if (isSupplementaryCodePoint(body, position)) position += 2;
|
|
2402
|
+
else throw (0, _syntaxError.syntaxError)(lexer.source, position, `Invalid character within String: ${printCodePointAt(lexer, position)}.`);
|
|
2403
|
+
}
|
|
2404
|
+
throw (0, _syntaxError.syntaxError)(lexer.source, position, "Unterminated string.");
|
|
2405
|
+
}
|
|
2406
|
+
/**
|
|
2407
|
+
* Reads an alphanumeric + underscore name from the source.
|
|
2408
|
+
*
|
|
2409
|
+
* ```
|
|
2410
|
+
* Name ::
|
|
2411
|
+
* - NameStart NameContinue* [lookahead != NameContinue]
|
|
2412
|
+
* ```
|
|
2413
|
+
*
|
|
2414
|
+
* @internal
|
|
2415
|
+
*/
|
|
2416
|
+
function readName(lexer, start) {
|
|
2417
|
+
const body = lexer.source.body;
|
|
2418
|
+
const bodyLength = body.length;
|
|
2419
|
+
let position = start + 1;
|
|
2420
|
+
while (position < bodyLength) {
|
|
2421
|
+
const code = body.charCodeAt(position);
|
|
2422
|
+
if ((0, _characterClasses.isNameContinue)(code)) ++position;
|
|
2423
|
+
else break;
|
|
2424
|
+
}
|
|
2425
|
+
return createToken(lexer, _tokenKind.TokenKind.NAME, start, position, body.slice(start, position));
|
|
2426
|
+
}
|
|
2427
|
+
}));
|
|
2428
|
+
//#endregion
|
|
2429
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/schemaCoordinateLexer.js
|
|
2430
|
+
var require_schemaCoordinateLexer = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2431
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2432
|
+
exports.SchemaCoordinateLexer = void 0;
|
|
2433
|
+
var _syntaxError = require_syntaxError();
|
|
2434
|
+
var _ast = require_ast();
|
|
2435
|
+
var _characterClasses = require_characterClasses();
|
|
2436
|
+
var _lexer = require_lexer();
|
|
2437
|
+
var _tokenKind = require_tokenKind();
|
|
2438
|
+
/**
|
|
2439
|
+
* Given a Source schema coordinate, creates a Lexer for that source.
|
|
2440
|
+
* A SchemaCoordinateLexer is a stateful stream generator in that every time
|
|
2441
|
+
* it is advanced, it returns the next token in the Source. Assuming the
|
|
2442
|
+
* source lexes, the final Token emitted by the lexer will be of kind
|
|
2443
|
+
* EOF, after which the lexer will repeatedly return the same EOF token
|
|
2444
|
+
* whenever called.
|
|
2445
|
+
*
|
|
2446
|
+
* @internal
|
|
2447
|
+
*/
|
|
2448
|
+
var SchemaCoordinateLexer = class {
|
|
2449
|
+
/** The previously focused non-ignored token. */
|
|
2450
|
+
/** The currently focused non-ignored token. */
|
|
2451
|
+
/**
|
|
2452
|
+
* The (1-indexed) line containing the current token.
|
|
2453
|
+
* Since a schema coordinate may not contain newline, this value is always 1.
|
|
2454
|
+
*/
|
|
2455
|
+
line = 1;
|
|
2456
|
+
/**
|
|
2457
|
+
* The character offset at which the current line begins.
|
|
2458
|
+
* Since a schema coordinate may not contain newline, this value is always 0.
|
|
2459
|
+
*/
|
|
2460
|
+
lineStart = 0;
|
|
2461
|
+
constructor(source) {
|
|
2462
|
+
const startOfFileToken = new _ast.Token(_tokenKind.TokenKind.SOF, 0, 0, 0, 0);
|
|
2463
|
+
this.source = source;
|
|
2464
|
+
this.lastToken = startOfFileToken;
|
|
2465
|
+
this.token = startOfFileToken;
|
|
2466
|
+
}
|
|
2467
|
+
get [Symbol.toStringTag]() {
|
|
2468
|
+
return "SchemaCoordinateLexer";
|
|
2469
|
+
}
|
|
2470
|
+
/**
|
|
2471
|
+
* Advances the token stream to the next non-ignored token.
|
|
2472
|
+
*
|
|
2473
|
+
* @internal
|
|
2474
|
+
*/
|
|
2475
|
+
advance() {
|
|
2476
|
+
this.lastToken = this.token;
|
|
2477
|
+
return this.token = this.lookahead();
|
|
2478
|
+
}
|
|
2479
|
+
/**
|
|
2480
|
+
* Looks ahead and returns the next non-ignored token, but does not change
|
|
2481
|
+
* the current Lexer token.
|
|
2482
|
+
*
|
|
2483
|
+
* @internal
|
|
2484
|
+
*/
|
|
2485
|
+
lookahead() {
|
|
2486
|
+
let token = this.token;
|
|
2487
|
+
if (token.kind !== _tokenKind.TokenKind.EOF) {
|
|
2488
|
+
const nextToken = readNextToken(this, token.end);
|
|
2489
|
+
token.next = nextToken;
|
|
2490
|
+
nextToken.prev = token;
|
|
2491
|
+
token = nextToken;
|
|
2492
|
+
}
|
|
2493
|
+
return token;
|
|
2494
|
+
}
|
|
2495
|
+
};
|
|
2496
|
+
/**
|
|
2497
|
+
* Gets the next token from the source starting at the given position.
|
|
2498
|
+
*
|
|
2499
|
+
* @internal
|
|
2500
|
+
*/
|
|
2501
|
+
exports.SchemaCoordinateLexer = SchemaCoordinateLexer;
|
|
2502
|
+
function readNextToken(lexer, start) {
|
|
2503
|
+
const body = lexer.source.body;
|
|
2504
|
+
const bodyLength = body.length;
|
|
2505
|
+
const position = start;
|
|
2506
|
+
if (position < bodyLength) {
|
|
2507
|
+
const code = body.charCodeAt(position);
|
|
2508
|
+
switch (code) {
|
|
2509
|
+
case 46: return (0, _lexer.createToken)(lexer, _tokenKind.TokenKind.DOT, position, position + 1);
|
|
2510
|
+
case 40: return (0, _lexer.createToken)(lexer, _tokenKind.TokenKind.PAREN_L, position, position + 1);
|
|
2511
|
+
case 41: return (0, _lexer.createToken)(lexer, _tokenKind.TokenKind.PAREN_R, position, position + 1);
|
|
2512
|
+
case 58: return (0, _lexer.createToken)(lexer, _tokenKind.TokenKind.COLON, position, position + 1);
|
|
2513
|
+
case 64: return (0, _lexer.createToken)(lexer, _tokenKind.TokenKind.AT, position, position + 1);
|
|
2514
|
+
}
|
|
2515
|
+
if ((0, _characterClasses.isNameStart)(code)) return (0, _lexer.readName)(lexer, position);
|
|
2516
|
+
throw (0, _syntaxError.syntaxError)(lexer.source, position, `Invalid character: ${(0, _lexer.printCodePointAt)(lexer, position)}.`);
|
|
2517
|
+
}
|
|
2518
|
+
return (0, _lexer.createToken)(lexer, _tokenKind.TokenKind.EOF, bodyLength, bodyLength);
|
|
2519
|
+
}
|
|
2520
|
+
}));
|
|
2521
|
+
//#endregion
|
|
2522
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/jsutils/devAssert.js
|
|
2523
|
+
var require_devAssert = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2524
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2525
|
+
exports.devAssert = devAssert;
|
|
2526
|
+
/** @internal */
|
|
2527
|
+
function devAssert(condition, message) {
|
|
2528
|
+
if (!Boolean(condition)) throw new Error(message);
|
|
2529
|
+
}
|
|
2530
|
+
}));
|
|
2531
|
+
//#endregion
|
|
2532
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/jsutils/inspect.js
|
|
2533
|
+
var require_inspect = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2534
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2535
|
+
exports.inspect = inspect;
|
|
2536
|
+
const MAX_ARRAY_LENGTH = 10;
|
|
2537
|
+
const MAX_RECURSIVE_DEPTH = 2;
|
|
2538
|
+
/**
|
|
2539
|
+
* Used to print values in error messages.
|
|
2540
|
+
*
|
|
2541
|
+
* @internal
|
|
2542
|
+
*/
|
|
2543
|
+
function inspect(value) {
|
|
2544
|
+
return formatValue(value, []);
|
|
2545
|
+
}
|
|
2546
|
+
function formatValue(value, seenValues) {
|
|
2547
|
+
switch (typeof value) {
|
|
2548
|
+
case "string": return JSON.stringify(value);
|
|
2549
|
+
case "function": return value.name ? `[function ${value.name}]` : "[function]";
|
|
2550
|
+
case "object": return formatObjectValue(value, seenValues);
|
|
2551
|
+
default: return String(value);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
function formatObjectValue(value, previouslySeenValues) {
|
|
2555
|
+
if (value === null) return "null";
|
|
2556
|
+
if (previouslySeenValues.includes(value)) return "[Circular]";
|
|
2557
|
+
const seenValues = [...previouslySeenValues, value];
|
|
2558
|
+
if (isJSONable(value)) {
|
|
2559
|
+
const jsonValue = value.toJSON();
|
|
2560
|
+
if (jsonValue !== value) return typeof jsonValue === "string" ? jsonValue : formatValue(jsonValue, seenValues);
|
|
2561
|
+
} else if (Array.isArray(value)) return formatArray(value, seenValues);
|
|
2562
|
+
return formatObject(value, seenValues);
|
|
2563
|
+
}
|
|
2564
|
+
function isJSONable(value) {
|
|
2565
|
+
return typeof value.toJSON === "function";
|
|
2566
|
+
}
|
|
2567
|
+
function formatObject(object, seenValues) {
|
|
2568
|
+
const entries = Object.entries(object);
|
|
2569
|
+
if (entries.length === 0) return "{}";
|
|
2570
|
+
if (seenValues.length > MAX_RECURSIVE_DEPTH) return "[" + getObjectTag(object) + "]";
|
|
2571
|
+
return "{ " + entries.map(([key, value]) => key + ": " + formatValue(value, seenValues)).join(", ") + " }";
|
|
2572
|
+
}
|
|
2573
|
+
function formatArray(array, seenValues) {
|
|
2574
|
+
if (array.length === 0) return "[]";
|
|
2575
|
+
if (seenValues.length > MAX_RECURSIVE_DEPTH) return "[Array]";
|
|
2576
|
+
const len = Math.min(MAX_ARRAY_LENGTH, array.length);
|
|
2577
|
+
const remaining = array.length - len;
|
|
2578
|
+
const items = [];
|
|
2579
|
+
for (let i = 0; i < len; ++i) items.push(formatValue(array[i], seenValues));
|
|
2580
|
+
if (remaining === 1) items.push("... 1 more item");
|
|
2581
|
+
else if (remaining > 1) items.push(`... ${remaining} more items`);
|
|
2582
|
+
return "[" + items.join(", ") + "]";
|
|
2583
|
+
}
|
|
2584
|
+
function getObjectTag(object) {
|
|
2585
|
+
const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
|
|
2586
|
+
if (tag === "Object" && typeof object.constructor === "function") {
|
|
2587
|
+
const name = object.constructor.name;
|
|
2588
|
+
if (typeof name === "string" && name !== "") return name;
|
|
2589
|
+
}
|
|
2590
|
+
return tag;
|
|
2591
|
+
}
|
|
2592
|
+
}));
|
|
2593
|
+
//#endregion
|
|
2594
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/jsutils/instanceOf.js
|
|
2595
|
+
var require_instanceOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2596
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2597
|
+
exports.instanceOf = void 0;
|
|
2598
|
+
var _inspect = require_inspect();
|
|
2599
|
+
exports.instanceOf = globalThis.process && process.env.NODE_ENV === "production" ? function instanceOf(value, constructor) {
|
|
2600
|
+
return value instanceof constructor;
|
|
2601
|
+
} : function instanceOf(value, constructor) {
|
|
2602
|
+
if (value instanceof constructor) return true;
|
|
2603
|
+
if (typeof value === "object" && value !== null) {
|
|
2604
|
+
var _value$constructor;
|
|
2605
|
+
const className = constructor.prototype[Symbol.toStringTag];
|
|
2606
|
+
if (className === (Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name)) {
|
|
2607
|
+
const stringifiedValue = (0, _inspect.inspect)(value);
|
|
2608
|
+
throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm.
|
|
2609
|
+
|
|
2610
|
+
Ensure that there is only one instance of "graphql" in the node_modules
|
|
2611
|
+
directory. If different versions of "graphql" are the dependencies of other
|
|
2612
|
+
relied on modules, use "resolutions" to ensure only one version is installed.
|
|
2613
|
+
|
|
2614
|
+
https://yarnpkg.com/en/docs/selective-version-resolutions
|
|
2615
|
+
|
|
2616
|
+
Duplicate "graphql" modules cannot be used at the same time since different
|
|
2617
|
+
versions may have different capabilities and behavior. The data from one
|
|
2618
|
+
version used in the function from another could produce confusing and
|
|
2619
|
+
spurious results.`);
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
return false;
|
|
2623
|
+
};
|
|
2624
|
+
}));
|
|
2625
|
+
//#endregion
|
|
2626
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/source.js
|
|
2627
|
+
var require_source = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2628
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2629
|
+
exports.Source = void 0;
|
|
2630
|
+
exports.isSource = isSource;
|
|
2631
|
+
var _devAssert = require_devAssert();
|
|
2632
|
+
var _inspect = require_inspect();
|
|
2633
|
+
var _instanceOf = require_instanceOf();
|
|
2634
|
+
/** @category Source */
|
|
2635
|
+
/**
|
|
2636
|
+
* A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
|
|
2637
|
+
* optional, but they are useful for clients who store GraphQL documents in source files.
|
|
2638
|
+
* For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
|
|
2639
|
+
* be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
|
|
2640
|
+
* The `line` and `column` properties in `locationOffset` are 1-indexed.
|
|
2641
|
+
*/
|
|
2642
|
+
var Source = class {
|
|
2643
|
+
/** The GraphQL source text. */
|
|
2644
|
+
/** Name used in diagnostics for this source, such as a file path or request name. */
|
|
2645
|
+
/** One-indexed line and column where this source begins. */
|
|
2646
|
+
/**
|
|
2647
|
+
* Creates a Source instance.
|
|
2648
|
+
* @param body - The GraphQL source text.
|
|
2649
|
+
* @param name - Name used in diagnostics for this source.
|
|
2650
|
+
* @param locationOffset - One-indexed line and column where this source begins.
|
|
2651
|
+
* @example
|
|
2652
|
+
* ```ts
|
|
2653
|
+
* import { Source } from 'graphql/language';
|
|
2654
|
+
*
|
|
2655
|
+
* const source = new Source(
|
|
2656
|
+
* 'type Query { greeting: String }',
|
|
2657
|
+
* 'schema.graphql',
|
|
2658
|
+
* { line: 10, column: 1 },
|
|
2659
|
+
* );
|
|
2660
|
+
*
|
|
2661
|
+
* source.body; // => 'type Query { greeting: String }'
|
|
2662
|
+
* source.name; // => 'schema.graphql'
|
|
2663
|
+
* source.locationOffset; // => { line: 10, column: 1 }
|
|
2664
|
+
* ```
|
|
2665
|
+
*/
|
|
2666
|
+
constructor(body, name = "GraphQL request", locationOffset = {
|
|
2667
|
+
line: 1,
|
|
2668
|
+
column: 1
|
|
2669
|
+
}) {
|
|
2670
|
+
typeof body === "string" || (0, _devAssert.devAssert)(false, `Body must be a string. Received: ${(0, _inspect.inspect)(body)}.`);
|
|
2671
|
+
this.body = body;
|
|
2672
|
+
this.name = name;
|
|
2673
|
+
this.locationOffset = locationOffset;
|
|
2674
|
+
this.locationOffset.line > 0 || (0, _devAssert.devAssert)(false, "line in locationOffset is 1-indexed and must be positive.");
|
|
2675
|
+
this.locationOffset.column > 0 || (0, _devAssert.devAssert)(false, "column in locationOffset is 1-indexed and must be positive.");
|
|
2676
|
+
}
|
|
2677
|
+
/**
|
|
2678
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
2679
|
+
* @returns The built-in string tag for this object.
|
|
2680
|
+
*/
|
|
2681
|
+
get [Symbol.toStringTag]() {
|
|
2682
|
+
return "Source";
|
|
2683
|
+
}
|
|
2684
|
+
};
|
|
2685
|
+
/**
|
|
2686
|
+
* Test if the given value is a Source object.
|
|
2687
|
+
*
|
|
2688
|
+
* @internal
|
|
2689
|
+
*/
|
|
2690
|
+
exports.Source = Source;
|
|
2691
|
+
function isSource(source) {
|
|
2692
|
+
return (0, _instanceOf.instanceOf)(source, Source);
|
|
2693
|
+
}
|
|
2694
|
+
}));
|
|
2695
|
+
//#endregion
|
|
2696
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/parser.js
|
|
2697
|
+
var require_parser = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2698
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2699
|
+
exports.Parser = void 0;
|
|
2700
|
+
exports.parse = parse;
|
|
2701
|
+
var _syntaxError = require_syntaxError();
|
|
2702
|
+
var _ast = require_ast();
|
|
2703
|
+
var _directiveLocation = require_directiveLocation();
|
|
2704
|
+
var _kinds = require_kinds();
|
|
2705
|
+
var _lexer = require_lexer();
|
|
2706
|
+
require_schemaCoordinateLexer();
|
|
2707
|
+
var _source = require_source();
|
|
2708
|
+
var _tokenKind = require_tokenKind();
|
|
2709
|
+
/** @category Parsing */
|
|
2710
|
+
/**
|
|
2711
|
+
* Given a GraphQL source, parses it into a Document.
|
|
2712
|
+
* Throws GraphQLError if a syntax error is encountered.
|
|
2713
|
+
* @param source - A GraphQL source string or source object.
|
|
2714
|
+
* @param options - Optional parser configuration.
|
|
2715
|
+
* @returns The parsed GraphQL document AST.
|
|
2716
|
+
* @example
|
|
2717
|
+
* ```ts
|
|
2718
|
+
* // Parse a GraphQL document with the default parser options.
|
|
2719
|
+
* import { parse } from 'graphql/language';
|
|
2720
|
+
*
|
|
2721
|
+
* const document = parse('{ hero { name } }');
|
|
2722
|
+
*
|
|
2723
|
+
* document.kind; // => 'Document'
|
|
2724
|
+
* ```
|
|
2725
|
+
* @example
|
|
2726
|
+
* ```ts
|
|
2727
|
+
* // This variant enables parser options and provides an explicit lexer.
|
|
2728
|
+
* import { Lexer, Source, parse } from 'graphql/language';
|
|
2729
|
+
*
|
|
2730
|
+
* const document = parse('fragment A($var: Boolean) on Query { field }', {
|
|
2731
|
+
* allowLegacyFragmentVariables: true,
|
|
2732
|
+
* maxTokens: 20,
|
|
2733
|
+
* noLocation: true,
|
|
2734
|
+
* });
|
|
2735
|
+
* const directiveDocument = parse('directive @foo @bar on FIELD', {
|
|
2736
|
+
* experimentalDirectivesOnDirectiveDefinitions: true,
|
|
2737
|
+
* });
|
|
2738
|
+
* const source = new Source('{ hero }');
|
|
2739
|
+
* const lexerDocument = parse(source, { lexer: new Lexer(source) });
|
|
2740
|
+
*
|
|
2741
|
+
* document.definitions[0].kind; // => 'FragmentDefinition'
|
|
2742
|
+
* document.loc; // => undefined
|
|
2743
|
+
* directiveDocument.definitions[0].kind; // => 'DirectiveDefinition'
|
|
2744
|
+
* lexerDocument.definitions[0].kind; // => 'OperationDefinition'
|
|
2745
|
+
* ```
|
|
2746
|
+
*/
|
|
2747
|
+
function parse(source, options) {
|
|
2748
|
+
const parser = new Parser(source, options);
|
|
2749
|
+
const document = parser.parseDocument();
|
|
2750
|
+
Object.defineProperty(document, "tokenCount", {
|
|
2751
|
+
enumerable: false,
|
|
2752
|
+
value: parser.tokenCount
|
|
2753
|
+
});
|
|
2754
|
+
return document;
|
|
2755
|
+
}
|
|
2756
|
+
/**
|
|
2757
|
+
* This class is exported only to assist people in implementing their own parsers
|
|
2758
|
+
* without duplicating too much code and should be used only as last resort for cases
|
|
2759
|
+
* such as experimental syntax or if certain features could not be contributed upstream.
|
|
2760
|
+
*
|
|
2761
|
+
* It is still part of the internal API and is versioned, so any changes to it are never
|
|
2762
|
+
* considered breaking changes. If you still need to support multiple versions of the
|
|
2763
|
+
* library, please use the `versionInfo` variable for version detection.
|
|
2764
|
+
*
|
|
2765
|
+
* @internal
|
|
2766
|
+
*/
|
|
2767
|
+
var Parser = class {
|
|
2768
|
+
constructor(source, options = {}) {
|
|
2769
|
+
const { lexer, ..._options } = options;
|
|
2770
|
+
if (lexer) this._lexer = lexer;
|
|
2771
|
+
else {
|
|
2772
|
+
const sourceObj = (0, _source.isSource)(source) ? source : new _source.Source(source);
|
|
2773
|
+
this._lexer = new _lexer.Lexer(sourceObj);
|
|
2774
|
+
}
|
|
2775
|
+
this._options = _options;
|
|
2776
|
+
this._tokenCounter = 0;
|
|
2777
|
+
}
|
|
2778
|
+
get tokenCount() {
|
|
2779
|
+
return this._tokenCounter;
|
|
2780
|
+
}
|
|
2781
|
+
/**
|
|
2782
|
+
* Converts a name lex token into a name parse node.
|
|
2783
|
+
*
|
|
2784
|
+
* @internal
|
|
2785
|
+
*/
|
|
2786
|
+
parseName() {
|
|
2787
|
+
const token = this.expectToken(_tokenKind.TokenKind.NAME);
|
|
2788
|
+
return this.node(token, {
|
|
2789
|
+
kind: _kinds.Kind.NAME,
|
|
2790
|
+
value: token.value
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2793
|
+
/**
|
|
2794
|
+
* Document : Definition+
|
|
2795
|
+
*
|
|
2796
|
+
* @internal
|
|
2797
|
+
*/
|
|
2798
|
+
parseDocument() {
|
|
2799
|
+
return this.node(this._lexer.token, {
|
|
2800
|
+
kind: _kinds.Kind.DOCUMENT,
|
|
2801
|
+
definitions: this.many(_tokenKind.TokenKind.SOF, this.parseDefinition, _tokenKind.TokenKind.EOF)
|
|
2802
|
+
});
|
|
2803
|
+
}
|
|
2804
|
+
/**
|
|
2805
|
+
* Definition :
|
|
2806
|
+
* - ExecutableDefinition
|
|
2807
|
+
* - TypeSystemDefinition
|
|
2808
|
+
* - TypeSystemExtension
|
|
2809
|
+
*
|
|
2810
|
+
* ExecutableDefinition :
|
|
2811
|
+
* - OperationDefinition
|
|
2812
|
+
* - FragmentDefinition
|
|
2813
|
+
*
|
|
2814
|
+
* TypeSystemDefinition :
|
|
2815
|
+
* - SchemaDefinition
|
|
2816
|
+
* - TypeDefinition
|
|
2817
|
+
* - DirectiveDefinition
|
|
2818
|
+
*
|
|
2819
|
+
* TypeDefinition :
|
|
2820
|
+
* - ScalarTypeDefinition
|
|
2821
|
+
* - ObjectTypeDefinition
|
|
2822
|
+
* - InterfaceTypeDefinition
|
|
2823
|
+
* - UnionTypeDefinition
|
|
2824
|
+
* - EnumTypeDefinition
|
|
2825
|
+
* - InputObjectTypeDefinition
|
|
2826
|
+
*
|
|
2827
|
+
* @internal
|
|
2828
|
+
*/
|
|
2829
|
+
parseDefinition() {
|
|
2830
|
+
if (this.peek(_tokenKind.TokenKind.BRACE_L)) return this.parseOperationDefinition();
|
|
2831
|
+
const hasDescription = this.peekDescription();
|
|
2832
|
+
const keywordToken = hasDescription ? this._lexer.lookahead() : this._lexer.token;
|
|
2833
|
+
if (hasDescription && keywordToken.kind === _tokenKind.TokenKind.BRACE_L) throw (0, _syntaxError.syntaxError)(this._lexer.source, this._lexer.token.start, "Unexpected description, descriptions are not supported on shorthand queries.");
|
|
2834
|
+
if (keywordToken.kind === _tokenKind.TokenKind.NAME) {
|
|
2835
|
+
switch (keywordToken.value) {
|
|
2836
|
+
case "schema": return this.parseSchemaDefinition();
|
|
2837
|
+
case "scalar": return this.parseScalarTypeDefinition();
|
|
2838
|
+
case "type": return this.parseObjectTypeDefinition();
|
|
2839
|
+
case "interface": return this.parseInterfaceTypeDefinition();
|
|
2840
|
+
case "union": return this.parseUnionTypeDefinition();
|
|
2841
|
+
case "enum": return this.parseEnumTypeDefinition();
|
|
2842
|
+
case "input": return this.parseInputObjectTypeDefinition();
|
|
2843
|
+
case "directive": return this.parseDirectiveDefinition();
|
|
2844
|
+
}
|
|
2845
|
+
switch (keywordToken.value) {
|
|
2846
|
+
case "query":
|
|
2847
|
+
case "mutation":
|
|
2848
|
+
case "subscription": return this.parseOperationDefinition();
|
|
2849
|
+
case "fragment": return this.parseFragmentDefinition();
|
|
2850
|
+
}
|
|
2851
|
+
if (hasDescription) throw (0, _syntaxError.syntaxError)(this._lexer.source, this._lexer.token.start, "Unexpected description, only GraphQL definitions support descriptions.");
|
|
2852
|
+
switch (keywordToken.value) {
|
|
2853
|
+
case "extend": return this.parseTypeSystemExtension();
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
throw this.unexpected(keywordToken);
|
|
2857
|
+
}
|
|
2858
|
+
/**
|
|
2859
|
+
* OperationDefinition :
|
|
2860
|
+
* - SelectionSet
|
|
2861
|
+
* - OperationType Name? VariableDefinitions? Directives? SelectionSet
|
|
2862
|
+
*
|
|
2863
|
+
* @internal
|
|
2864
|
+
*/
|
|
2865
|
+
parseOperationDefinition() {
|
|
2866
|
+
const start = this._lexer.token;
|
|
2867
|
+
if (this.peek(_tokenKind.TokenKind.BRACE_L)) return this.node(start, {
|
|
2868
|
+
kind: _kinds.Kind.OPERATION_DEFINITION,
|
|
2869
|
+
operation: _ast.OperationTypeNode.QUERY,
|
|
2870
|
+
description: void 0,
|
|
2871
|
+
name: void 0,
|
|
2872
|
+
variableDefinitions: [],
|
|
2873
|
+
directives: [],
|
|
2874
|
+
selectionSet: this.parseSelectionSet()
|
|
2875
|
+
});
|
|
2876
|
+
const description = this.parseDescription();
|
|
2877
|
+
const operation = this.parseOperationType();
|
|
2878
|
+
let name;
|
|
2879
|
+
if (this.peek(_tokenKind.TokenKind.NAME)) name = this.parseName();
|
|
2880
|
+
return this.node(start, {
|
|
2881
|
+
kind: _kinds.Kind.OPERATION_DEFINITION,
|
|
2882
|
+
operation,
|
|
2883
|
+
description,
|
|
2884
|
+
name,
|
|
2885
|
+
variableDefinitions: this.parseVariableDefinitions(),
|
|
2886
|
+
directives: this.parseDirectives(false),
|
|
2887
|
+
selectionSet: this.parseSelectionSet()
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
/**
|
|
2891
|
+
* OperationType : one of query mutation subscription
|
|
2892
|
+
*
|
|
2893
|
+
* @internal
|
|
2894
|
+
*/
|
|
2895
|
+
parseOperationType() {
|
|
2896
|
+
const operationToken = this.expectToken(_tokenKind.TokenKind.NAME);
|
|
2897
|
+
switch (operationToken.value) {
|
|
2898
|
+
case "query": return _ast.OperationTypeNode.QUERY;
|
|
2899
|
+
case "mutation": return _ast.OperationTypeNode.MUTATION;
|
|
2900
|
+
case "subscription": return _ast.OperationTypeNode.SUBSCRIPTION;
|
|
2901
|
+
}
|
|
2902
|
+
throw this.unexpected(operationToken);
|
|
2903
|
+
}
|
|
2904
|
+
/**
|
|
2905
|
+
* VariableDefinitions : ( VariableDefinition+ )
|
|
2906
|
+
*
|
|
2907
|
+
* @internal
|
|
2908
|
+
*/
|
|
2909
|
+
parseVariableDefinitions() {
|
|
2910
|
+
return this.optionalMany(_tokenKind.TokenKind.PAREN_L, this.parseVariableDefinition, _tokenKind.TokenKind.PAREN_R);
|
|
2911
|
+
}
|
|
2912
|
+
/**
|
|
2913
|
+
* VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
|
|
2914
|
+
*
|
|
2915
|
+
* @internal
|
|
2916
|
+
*/
|
|
2917
|
+
parseVariableDefinition() {
|
|
2918
|
+
return this.node(this._lexer.token, {
|
|
2919
|
+
kind: _kinds.Kind.VARIABLE_DEFINITION,
|
|
2920
|
+
description: this.parseDescription(),
|
|
2921
|
+
variable: this.parseVariable(),
|
|
2922
|
+
type: (this.expectToken(_tokenKind.TokenKind.COLON), this.parseTypeReference()),
|
|
2923
|
+
defaultValue: this.expectOptionalToken(_tokenKind.TokenKind.EQUALS) ? this.parseConstValueLiteral() : void 0,
|
|
2924
|
+
directives: this.parseConstDirectives()
|
|
2925
|
+
});
|
|
2926
|
+
}
|
|
2927
|
+
/**
|
|
2928
|
+
* Variable : $ Name
|
|
2929
|
+
*
|
|
2930
|
+
* @internal
|
|
2931
|
+
*/
|
|
2932
|
+
parseVariable() {
|
|
2933
|
+
const start = this._lexer.token;
|
|
2934
|
+
this.expectToken(_tokenKind.TokenKind.DOLLAR);
|
|
2935
|
+
return this.node(start, {
|
|
2936
|
+
kind: _kinds.Kind.VARIABLE,
|
|
2937
|
+
name: this.parseName()
|
|
2938
|
+
});
|
|
2939
|
+
}
|
|
2940
|
+
/**
|
|
2941
|
+
* ```
|
|
2942
|
+
* SelectionSet : { Selection+ }
|
|
2943
|
+
* ```
|
|
2944
|
+
*
|
|
2945
|
+
* @internal
|
|
2946
|
+
*/
|
|
2947
|
+
parseSelectionSet() {
|
|
2948
|
+
return this.node(this._lexer.token, {
|
|
2949
|
+
kind: _kinds.Kind.SELECTION_SET,
|
|
2950
|
+
selections: this.many(_tokenKind.TokenKind.BRACE_L, this.parseSelection, _tokenKind.TokenKind.BRACE_R)
|
|
2951
|
+
});
|
|
2952
|
+
}
|
|
2953
|
+
/**
|
|
2954
|
+
* Selection :
|
|
2955
|
+
* - Field
|
|
2956
|
+
* - FragmentSpread
|
|
2957
|
+
* - InlineFragment
|
|
2958
|
+
*
|
|
2959
|
+
* @internal
|
|
2960
|
+
*/
|
|
2961
|
+
parseSelection() {
|
|
2962
|
+
return this.peek(_tokenKind.TokenKind.SPREAD) ? this.parseFragment() : this.parseField();
|
|
2963
|
+
}
|
|
2964
|
+
/**
|
|
2965
|
+
* Field : Alias? Name Arguments? Directives? SelectionSet?
|
|
2966
|
+
*
|
|
2967
|
+
* Alias : Name :
|
|
2968
|
+
*
|
|
2969
|
+
* @internal
|
|
2970
|
+
*/
|
|
2971
|
+
parseField() {
|
|
2972
|
+
const start = this._lexer.token;
|
|
2973
|
+
const nameOrAlias = this.parseName();
|
|
2974
|
+
let alias;
|
|
2975
|
+
let name;
|
|
2976
|
+
if (this.expectOptionalToken(_tokenKind.TokenKind.COLON)) {
|
|
2977
|
+
alias = nameOrAlias;
|
|
2978
|
+
name = this.parseName();
|
|
2979
|
+
} else name = nameOrAlias;
|
|
2980
|
+
return this.node(start, {
|
|
2981
|
+
kind: _kinds.Kind.FIELD,
|
|
2982
|
+
alias,
|
|
2983
|
+
name,
|
|
2984
|
+
arguments: this.parseArguments(false),
|
|
2985
|
+
directives: this.parseDirectives(false),
|
|
2986
|
+
selectionSet: this.peek(_tokenKind.TokenKind.BRACE_L) ? this.parseSelectionSet() : void 0
|
|
2987
|
+
});
|
|
2988
|
+
}
|
|
2989
|
+
/**
|
|
2990
|
+
* Arguments[Const] : ( Argument[?Const]+ )
|
|
2991
|
+
*
|
|
2992
|
+
* @internal
|
|
2993
|
+
*/
|
|
2994
|
+
parseArguments(isConst) {
|
|
2995
|
+
const item = isConst ? this.parseConstArgument : this.parseArgument;
|
|
2996
|
+
return this.optionalMany(_tokenKind.TokenKind.PAREN_L, item, _tokenKind.TokenKind.PAREN_R);
|
|
2997
|
+
}
|
|
2998
|
+
/**
|
|
2999
|
+
* Argument[Const] : Name : Value[?Const]
|
|
3000
|
+
*
|
|
3001
|
+
* @internal
|
|
3002
|
+
*/
|
|
3003
|
+
parseArgument(isConst = false) {
|
|
3004
|
+
const start = this._lexer.token;
|
|
3005
|
+
const name = this.parseName();
|
|
3006
|
+
this.expectToken(_tokenKind.TokenKind.COLON);
|
|
3007
|
+
return this.node(start, {
|
|
3008
|
+
kind: _kinds.Kind.ARGUMENT,
|
|
3009
|
+
name,
|
|
3010
|
+
value: this.parseValueLiteral(isConst)
|
|
3011
|
+
});
|
|
3012
|
+
}
|
|
3013
|
+
parseConstArgument() {
|
|
3014
|
+
return this.parseArgument(true);
|
|
3015
|
+
}
|
|
3016
|
+
/**
|
|
3017
|
+
* Corresponds to both FragmentSpread and InlineFragment in the spec.
|
|
3018
|
+
*
|
|
3019
|
+
* FragmentSpread : ... FragmentName Directives?
|
|
3020
|
+
*
|
|
3021
|
+
* InlineFragment : ... TypeCondition? Directives? SelectionSet
|
|
3022
|
+
*
|
|
3023
|
+
* @internal
|
|
3024
|
+
*/
|
|
3025
|
+
parseFragment() {
|
|
3026
|
+
const start = this._lexer.token;
|
|
3027
|
+
this.expectToken(_tokenKind.TokenKind.SPREAD);
|
|
3028
|
+
const hasTypeCondition = this.expectOptionalKeyword("on");
|
|
3029
|
+
if (!hasTypeCondition && this.peek(_tokenKind.TokenKind.NAME)) return this.node(start, {
|
|
3030
|
+
kind: _kinds.Kind.FRAGMENT_SPREAD,
|
|
3031
|
+
name: this.parseFragmentName(),
|
|
3032
|
+
directives: this.parseDirectives(false)
|
|
3033
|
+
});
|
|
3034
|
+
return this.node(start, {
|
|
3035
|
+
kind: _kinds.Kind.INLINE_FRAGMENT,
|
|
3036
|
+
typeCondition: hasTypeCondition ? this.parseNamedType() : void 0,
|
|
3037
|
+
directives: this.parseDirectives(false),
|
|
3038
|
+
selectionSet: this.parseSelectionSet()
|
|
3039
|
+
});
|
|
3040
|
+
}
|
|
3041
|
+
/**
|
|
3042
|
+
* FragmentDefinition :
|
|
3043
|
+
* - fragment FragmentName on TypeCondition Directives? SelectionSet
|
|
3044
|
+
*
|
|
3045
|
+
* TypeCondition : NamedType
|
|
3046
|
+
*
|
|
3047
|
+
* @internal
|
|
3048
|
+
*/
|
|
3049
|
+
parseFragmentDefinition() {
|
|
3050
|
+
const start = this._lexer.token;
|
|
3051
|
+
const description = this.parseDescription();
|
|
3052
|
+
this.expectKeyword("fragment");
|
|
3053
|
+
if (this._options.allowLegacyFragmentVariables === true) return this.node(start, {
|
|
3054
|
+
kind: _kinds.Kind.FRAGMENT_DEFINITION,
|
|
3055
|
+
description,
|
|
3056
|
+
name: this.parseFragmentName(),
|
|
3057
|
+
variableDefinitions: this.parseVariableDefinitions(),
|
|
3058
|
+
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
|
|
3059
|
+
directives: this.parseDirectives(false),
|
|
3060
|
+
selectionSet: this.parseSelectionSet()
|
|
3061
|
+
});
|
|
3062
|
+
return this.node(start, {
|
|
3063
|
+
kind: _kinds.Kind.FRAGMENT_DEFINITION,
|
|
3064
|
+
description,
|
|
3065
|
+
name: this.parseFragmentName(),
|
|
3066
|
+
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
|
|
3067
|
+
directives: this.parseDirectives(false),
|
|
3068
|
+
selectionSet: this.parseSelectionSet()
|
|
3069
|
+
});
|
|
3070
|
+
}
|
|
3071
|
+
/**
|
|
3072
|
+
* FragmentName : Name but not `on`
|
|
3073
|
+
*
|
|
3074
|
+
* @internal
|
|
3075
|
+
*/
|
|
3076
|
+
parseFragmentName() {
|
|
3077
|
+
if (this._lexer.token.value === "on") throw this.unexpected();
|
|
3078
|
+
return this.parseName();
|
|
3079
|
+
}
|
|
3080
|
+
/**
|
|
3081
|
+
* Value[Const] :
|
|
3082
|
+
* - [~Const] Variable
|
|
3083
|
+
* - IntValue
|
|
3084
|
+
* - FloatValue
|
|
3085
|
+
* - StringValue
|
|
3086
|
+
* - BooleanValue
|
|
3087
|
+
* - NullValue
|
|
3088
|
+
* - EnumValue
|
|
3089
|
+
* - ListValue[?Const]
|
|
3090
|
+
* - ObjectValue[?Const]
|
|
3091
|
+
*
|
|
3092
|
+
* BooleanValue : one of `true` `false`
|
|
3093
|
+
*
|
|
3094
|
+
* NullValue : `null`
|
|
3095
|
+
*
|
|
3096
|
+
* EnumValue : Name but not `true`, `false` or `null`
|
|
3097
|
+
*
|
|
3098
|
+
* @internal
|
|
3099
|
+
*/
|
|
3100
|
+
parseValueLiteral(isConst) {
|
|
3101
|
+
const token = this._lexer.token;
|
|
3102
|
+
switch (token.kind) {
|
|
3103
|
+
case _tokenKind.TokenKind.BRACKET_L: return this.parseList(isConst);
|
|
3104
|
+
case _tokenKind.TokenKind.BRACE_L: return this.parseObject(isConst);
|
|
3105
|
+
case _tokenKind.TokenKind.INT:
|
|
3106
|
+
this.advanceLexer();
|
|
3107
|
+
return this.node(token, {
|
|
3108
|
+
kind: _kinds.Kind.INT,
|
|
3109
|
+
value: token.value
|
|
3110
|
+
});
|
|
3111
|
+
case _tokenKind.TokenKind.FLOAT:
|
|
3112
|
+
this.advanceLexer();
|
|
3113
|
+
return this.node(token, {
|
|
3114
|
+
kind: _kinds.Kind.FLOAT,
|
|
3115
|
+
value: token.value
|
|
3116
|
+
});
|
|
3117
|
+
case _tokenKind.TokenKind.STRING:
|
|
3118
|
+
case _tokenKind.TokenKind.BLOCK_STRING: return this.parseStringLiteral();
|
|
3119
|
+
case _tokenKind.TokenKind.NAME:
|
|
3120
|
+
this.advanceLexer();
|
|
3121
|
+
switch (token.value) {
|
|
3122
|
+
case "true": return this.node(token, {
|
|
3123
|
+
kind: _kinds.Kind.BOOLEAN,
|
|
3124
|
+
value: true
|
|
3125
|
+
});
|
|
3126
|
+
case "false": return this.node(token, {
|
|
3127
|
+
kind: _kinds.Kind.BOOLEAN,
|
|
3128
|
+
value: false
|
|
3129
|
+
});
|
|
3130
|
+
case "null": return this.node(token, { kind: _kinds.Kind.NULL });
|
|
3131
|
+
default: return this.node(token, {
|
|
3132
|
+
kind: _kinds.Kind.ENUM,
|
|
3133
|
+
value: token.value
|
|
3134
|
+
});
|
|
3135
|
+
}
|
|
3136
|
+
case _tokenKind.TokenKind.DOLLAR:
|
|
3137
|
+
if (isConst) {
|
|
3138
|
+
this.expectToken(_tokenKind.TokenKind.DOLLAR);
|
|
3139
|
+
if (this._lexer.token.kind === _tokenKind.TokenKind.NAME) {
|
|
3140
|
+
const varName = this._lexer.token.value;
|
|
3141
|
+
throw (0, _syntaxError.syntaxError)(this._lexer.source, token.start, `Unexpected variable "$${varName}" in constant value.`);
|
|
3142
|
+
} else throw this.unexpected(token);
|
|
3143
|
+
}
|
|
3144
|
+
return this.parseVariable();
|
|
3145
|
+
default: throw this.unexpected();
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
parseConstValueLiteral() {
|
|
3149
|
+
return this.parseValueLiteral(true);
|
|
3150
|
+
}
|
|
3151
|
+
parseStringLiteral() {
|
|
3152
|
+
const token = this._lexer.token;
|
|
3153
|
+
this.advanceLexer();
|
|
3154
|
+
return this.node(token, {
|
|
3155
|
+
kind: _kinds.Kind.STRING,
|
|
3156
|
+
value: token.value,
|
|
3157
|
+
block: token.kind === _tokenKind.TokenKind.BLOCK_STRING
|
|
3158
|
+
});
|
|
3159
|
+
}
|
|
3160
|
+
/**
|
|
3161
|
+
* ListValue[Const] :
|
|
3162
|
+
* - [ ]
|
|
3163
|
+
* - [ Value[?Const]+ ]
|
|
3164
|
+
*
|
|
3165
|
+
* @internal
|
|
3166
|
+
*/
|
|
3167
|
+
parseList(isConst) {
|
|
3168
|
+
const item = () => this.parseValueLiteral(isConst);
|
|
3169
|
+
return this.node(this._lexer.token, {
|
|
3170
|
+
kind: _kinds.Kind.LIST,
|
|
3171
|
+
values: this.any(_tokenKind.TokenKind.BRACKET_L, item, _tokenKind.TokenKind.BRACKET_R)
|
|
3172
|
+
});
|
|
3173
|
+
}
|
|
3174
|
+
/**
|
|
3175
|
+
* ```
|
|
3176
|
+
* ObjectValue[Const] :
|
|
3177
|
+
* - { }
|
|
3178
|
+
* - { ObjectField[?Const]+ }
|
|
3179
|
+
* ```
|
|
3180
|
+
*
|
|
3181
|
+
* @internal
|
|
3182
|
+
*/
|
|
3183
|
+
parseObject(isConst) {
|
|
3184
|
+
const item = () => this.parseObjectField(isConst);
|
|
3185
|
+
return this.node(this._lexer.token, {
|
|
3186
|
+
kind: _kinds.Kind.OBJECT,
|
|
3187
|
+
fields: this.any(_tokenKind.TokenKind.BRACE_L, item, _tokenKind.TokenKind.BRACE_R)
|
|
3188
|
+
});
|
|
3189
|
+
}
|
|
3190
|
+
/**
|
|
3191
|
+
* ObjectField[Const] : Name : Value[?Const]
|
|
3192
|
+
*
|
|
3193
|
+
* @internal
|
|
3194
|
+
*/
|
|
3195
|
+
parseObjectField(isConst) {
|
|
3196
|
+
const start = this._lexer.token;
|
|
3197
|
+
const name = this.parseName();
|
|
3198
|
+
this.expectToken(_tokenKind.TokenKind.COLON);
|
|
3199
|
+
return this.node(start, {
|
|
3200
|
+
kind: _kinds.Kind.OBJECT_FIELD,
|
|
3201
|
+
name,
|
|
3202
|
+
value: this.parseValueLiteral(isConst)
|
|
3203
|
+
});
|
|
3204
|
+
}
|
|
3205
|
+
/**
|
|
3206
|
+
* Directives[Const] : Directive[?Const]+
|
|
3207
|
+
*
|
|
3208
|
+
* @internal
|
|
3209
|
+
*/
|
|
3210
|
+
parseDirectives(isConst) {
|
|
3211
|
+
const directives = [];
|
|
3212
|
+
while (this.peek(_tokenKind.TokenKind.AT)) directives.push(this.parseDirective(isConst));
|
|
3213
|
+
return directives;
|
|
3214
|
+
}
|
|
3215
|
+
parseConstDirectives() {
|
|
3216
|
+
return this.parseDirectives(true);
|
|
3217
|
+
}
|
|
3218
|
+
/**
|
|
3219
|
+
* ```
|
|
3220
|
+
* Directive[Const] : @ Name Arguments[?Const]?
|
|
3221
|
+
* ```
|
|
3222
|
+
*
|
|
3223
|
+
* @internal
|
|
3224
|
+
*/
|
|
3225
|
+
parseDirective(isConst) {
|
|
3226
|
+
const start = this._lexer.token;
|
|
3227
|
+
this.expectToken(_tokenKind.TokenKind.AT);
|
|
3228
|
+
return this.node(start, {
|
|
3229
|
+
kind: _kinds.Kind.DIRECTIVE,
|
|
3230
|
+
name: this.parseName(),
|
|
3231
|
+
arguments: this.parseArguments(isConst)
|
|
3232
|
+
});
|
|
3233
|
+
}
|
|
3234
|
+
/**
|
|
3235
|
+
* Type :
|
|
3236
|
+
* - NamedType
|
|
3237
|
+
* - ListType
|
|
3238
|
+
* - NonNullType
|
|
3239
|
+
*
|
|
3240
|
+
* @internal
|
|
3241
|
+
*/
|
|
3242
|
+
parseTypeReference() {
|
|
3243
|
+
const start = this._lexer.token;
|
|
3244
|
+
let type;
|
|
3245
|
+
if (this.expectOptionalToken(_tokenKind.TokenKind.BRACKET_L)) {
|
|
3246
|
+
const innerType = this.parseTypeReference();
|
|
3247
|
+
this.expectToken(_tokenKind.TokenKind.BRACKET_R);
|
|
3248
|
+
type = this.node(start, {
|
|
3249
|
+
kind: _kinds.Kind.LIST_TYPE,
|
|
3250
|
+
type: innerType
|
|
3251
|
+
});
|
|
3252
|
+
} else type = this.parseNamedType();
|
|
3253
|
+
if (this.expectOptionalToken(_tokenKind.TokenKind.BANG)) return this.node(start, {
|
|
3254
|
+
kind: _kinds.Kind.NON_NULL_TYPE,
|
|
3255
|
+
type
|
|
3256
|
+
});
|
|
3257
|
+
return type;
|
|
3258
|
+
}
|
|
3259
|
+
/**
|
|
3260
|
+
* NamedType : Name
|
|
3261
|
+
*
|
|
3262
|
+
* @internal
|
|
3263
|
+
*/
|
|
3264
|
+
parseNamedType() {
|
|
3265
|
+
return this.node(this._lexer.token, {
|
|
3266
|
+
kind: _kinds.Kind.NAMED_TYPE,
|
|
3267
|
+
name: this.parseName()
|
|
3268
|
+
});
|
|
3269
|
+
}
|
|
3270
|
+
peekDescription() {
|
|
3271
|
+
return this.peek(_tokenKind.TokenKind.STRING) || this.peek(_tokenKind.TokenKind.BLOCK_STRING);
|
|
3272
|
+
}
|
|
3273
|
+
/**
|
|
3274
|
+
* Description : StringValue
|
|
3275
|
+
*
|
|
3276
|
+
* @internal
|
|
3277
|
+
*/
|
|
3278
|
+
parseDescription() {
|
|
3279
|
+
if (this.peekDescription()) return this.parseStringLiteral();
|
|
3280
|
+
}
|
|
3281
|
+
/**
|
|
3282
|
+
* ```
|
|
3283
|
+
* SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
|
|
3284
|
+
* ```
|
|
3285
|
+
*
|
|
3286
|
+
* @internal
|
|
3287
|
+
*/
|
|
3288
|
+
parseSchemaDefinition() {
|
|
3289
|
+
const start = this._lexer.token;
|
|
3290
|
+
const description = this.parseDescription();
|
|
3291
|
+
this.expectKeyword("schema");
|
|
3292
|
+
const directives = this.parseConstDirectives();
|
|
3293
|
+
const operationTypes = this.many(_tokenKind.TokenKind.BRACE_L, this.parseOperationTypeDefinition, _tokenKind.TokenKind.BRACE_R);
|
|
3294
|
+
return this.node(start, {
|
|
3295
|
+
kind: _kinds.Kind.SCHEMA_DEFINITION,
|
|
3296
|
+
description,
|
|
3297
|
+
directives,
|
|
3298
|
+
operationTypes
|
|
3299
|
+
});
|
|
3300
|
+
}
|
|
3301
|
+
/**
|
|
3302
|
+
* OperationTypeDefinition : OperationType : NamedType
|
|
3303
|
+
*
|
|
3304
|
+
* @internal
|
|
3305
|
+
*/
|
|
3306
|
+
parseOperationTypeDefinition() {
|
|
3307
|
+
const start = this._lexer.token;
|
|
3308
|
+
const operation = this.parseOperationType();
|
|
3309
|
+
this.expectToken(_tokenKind.TokenKind.COLON);
|
|
3310
|
+
const type = this.parseNamedType();
|
|
3311
|
+
return this.node(start, {
|
|
3312
|
+
kind: _kinds.Kind.OPERATION_TYPE_DEFINITION,
|
|
3313
|
+
operation,
|
|
3314
|
+
type
|
|
3315
|
+
});
|
|
3316
|
+
}
|
|
3317
|
+
/**
|
|
3318
|
+
* ScalarTypeDefinition : Description? scalar Name Directives[Const]?
|
|
3319
|
+
*
|
|
3320
|
+
* @internal
|
|
3321
|
+
*/
|
|
3322
|
+
parseScalarTypeDefinition() {
|
|
3323
|
+
const start = this._lexer.token;
|
|
3324
|
+
const description = this.parseDescription();
|
|
3325
|
+
this.expectKeyword("scalar");
|
|
3326
|
+
const name = this.parseName();
|
|
3327
|
+
const directives = this.parseConstDirectives();
|
|
3328
|
+
return this.node(start, {
|
|
3329
|
+
kind: _kinds.Kind.SCALAR_TYPE_DEFINITION,
|
|
3330
|
+
description,
|
|
3331
|
+
name,
|
|
3332
|
+
directives
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
/**
|
|
3336
|
+
* ObjectTypeDefinition :
|
|
3337
|
+
* Description?
|
|
3338
|
+
* type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
|
|
3339
|
+
*
|
|
3340
|
+
* @internal
|
|
3341
|
+
*/
|
|
3342
|
+
parseObjectTypeDefinition() {
|
|
3343
|
+
const start = this._lexer.token;
|
|
3344
|
+
const description = this.parseDescription();
|
|
3345
|
+
this.expectKeyword("type");
|
|
3346
|
+
const name = this.parseName();
|
|
3347
|
+
const interfaces = this.parseImplementsInterfaces();
|
|
3348
|
+
const directives = this.parseConstDirectives();
|
|
3349
|
+
const fields = this.parseFieldsDefinition();
|
|
3350
|
+
return this.node(start, {
|
|
3351
|
+
kind: _kinds.Kind.OBJECT_TYPE_DEFINITION,
|
|
3352
|
+
description,
|
|
3353
|
+
name,
|
|
3354
|
+
interfaces,
|
|
3355
|
+
directives,
|
|
3356
|
+
fields
|
|
3357
|
+
});
|
|
3358
|
+
}
|
|
3359
|
+
/**
|
|
3360
|
+
* ImplementsInterfaces :
|
|
3361
|
+
* - implements `&`? NamedType
|
|
3362
|
+
* - ImplementsInterfaces & NamedType
|
|
3363
|
+
*
|
|
3364
|
+
* @internal
|
|
3365
|
+
*/
|
|
3366
|
+
parseImplementsInterfaces() {
|
|
3367
|
+
return this.expectOptionalKeyword("implements") ? this.delimitedMany(_tokenKind.TokenKind.AMP, this.parseNamedType) : [];
|
|
3368
|
+
}
|
|
3369
|
+
/**
|
|
3370
|
+
* ```
|
|
3371
|
+
* FieldsDefinition : { FieldDefinition+ }
|
|
3372
|
+
* ```
|
|
3373
|
+
*
|
|
3374
|
+
* @internal
|
|
3375
|
+
*/
|
|
3376
|
+
parseFieldsDefinition() {
|
|
3377
|
+
return this.optionalMany(_tokenKind.TokenKind.BRACE_L, this.parseFieldDefinition, _tokenKind.TokenKind.BRACE_R);
|
|
3378
|
+
}
|
|
3379
|
+
/**
|
|
3380
|
+
* FieldDefinition :
|
|
3381
|
+
* - Description? Name ArgumentsDefinition? : Type Directives[Const]?
|
|
3382
|
+
*
|
|
3383
|
+
* @internal
|
|
3384
|
+
*/
|
|
3385
|
+
parseFieldDefinition() {
|
|
3386
|
+
const start = this._lexer.token;
|
|
3387
|
+
const description = this.parseDescription();
|
|
3388
|
+
const name = this.parseName();
|
|
3389
|
+
const args = this.parseArgumentDefs();
|
|
3390
|
+
this.expectToken(_tokenKind.TokenKind.COLON);
|
|
3391
|
+
const type = this.parseTypeReference();
|
|
3392
|
+
const directives = this.parseConstDirectives();
|
|
3393
|
+
return this.node(start, {
|
|
3394
|
+
kind: _kinds.Kind.FIELD_DEFINITION,
|
|
3395
|
+
description,
|
|
3396
|
+
name,
|
|
3397
|
+
arguments: args,
|
|
3398
|
+
type,
|
|
3399
|
+
directives
|
|
3400
|
+
});
|
|
3401
|
+
}
|
|
3402
|
+
/**
|
|
3403
|
+
* ArgumentsDefinition : ( InputValueDefinition+ )
|
|
3404
|
+
*
|
|
3405
|
+
* @internal
|
|
3406
|
+
*/
|
|
3407
|
+
parseArgumentDefs() {
|
|
3408
|
+
return this.optionalMany(_tokenKind.TokenKind.PAREN_L, this.parseInputValueDef, _tokenKind.TokenKind.PAREN_R);
|
|
3409
|
+
}
|
|
3410
|
+
/**
|
|
3411
|
+
* InputValueDefinition :
|
|
3412
|
+
* - Description? Name : Type DefaultValue? Directives[Const]?
|
|
3413
|
+
*
|
|
3414
|
+
* @internal
|
|
3415
|
+
*/
|
|
3416
|
+
parseInputValueDef() {
|
|
3417
|
+
const start = this._lexer.token;
|
|
3418
|
+
const description = this.parseDescription();
|
|
3419
|
+
const name = this.parseName();
|
|
3420
|
+
this.expectToken(_tokenKind.TokenKind.COLON);
|
|
3421
|
+
const type = this.parseTypeReference();
|
|
3422
|
+
let defaultValue;
|
|
3423
|
+
if (this.expectOptionalToken(_tokenKind.TokenKind.EQUALS)) defaultValue = this.parseConstValueLiteral();
|
|
3424
|
+
const directives = this.parseConstDirectives();
|
|
3425
|
+
return this.node(start, {
|
|
3426
|
+
kind: _kinds.Kind.INPUT_VALUE_DEFINITION,
|
|
3427
|
+
description,
|
|
3428
|
+
name,
|
|
3429
|
+
type,
|
|
3430
|
+
defaultValue,
|
|
3431
|
+
directives
|
|
3432
|
+
});
|
|
3433
|
+
}
|
|
3434
|
+
/**
|
|
3435
|
+
* InterfaceTypeDefinition :
|
|
3436
|
+
* - Description? interface Name Directives[Const]? FieldsDefinition?
|
|
3437
|
+
*
|
|
3438
|
+
* @internal
|
|
3439
|
+
*/
|
|
3440
|
+
parseInterfaceTypeDefinition() {
|
|
3441
|
+
const start = this._lexer.token;
|
|
3442
|
+
const description = this.parseDescription();
|
|
3443
|
+
this.expectKeyword("interface");
|
|
3444
|
+
const name = this.parseName();
|
|
3445
|
+
const interfaces = this.parseImplementsInterfaces();
|
|
3446
|
+
const directives = this.parseConstDirectives();
|
|
3447
|
+
const fields = this.parseFieldsDefinition();
|
|
3448
|
+
return this.node(start, {
|
|
3449
|
+
kind: _kinds.Kind.INTERFACE_TYPE_DEFINITION,
|
|
3450
|
+
description,
|
|
3451
|
+
name,
|
|
3452
|
+
interfaces,
|
|
3453
|
+
directives,
|
|
3454
|
+
fields
|
|
3455
|
+
});
|
|
3456
|
+
}
|
|
3457
|
+
/**
|
|
3458
|
+
* UnionTypeDefinition :
|
|
3459
|
+
* - Description? union Name Directives[Const]? UnionMemberTypes?
|
|
3460
|
+
*
|
|
3461
|
+
* @internal
|
|
3462
|
+
*/
|
|
3463
|
+
parseUnionTypeDefinition() {
|
|
3464
|
+
const start = this._lexer.token;
|
|
3465
|
+
const description = this.parseDescription();
|
|
3466
|
+
this.expectKeyword("union");
|
|
3467
|
+
const name = this.parseName();
|
|
3468
|
+
const directives = this.parseConstDirectives();
|
|
3469
|
+
const types = this.parseUnionMemberTypes();
|
|
3470
|
+
return this.node(start, {
|
|
3471
|
+
kind: _kinds.Kind.UNION_TYPE_DEFINITION,
|
|
3472
|
+
description,
|
|
3473
|
+
name,
|
|
3474
|
+
directives,
|
|
3475
|
+
types
|
|
3476
|
+
});
|
|
3477
|
+
}
|
|
3478
|
+
/**
|
|
3479
|
+
* UnionMemberTypes :
|
|
3480
|
+
* - = `|`? NamedType
|
|
3481
|
+
* - UnionMemberTypes | NamedType
|
|
3482
|
+
*
|
|
3483
|
+
* @internal
|
|
3484
|
+
*/
|
|
3485
|
+
parseUnionMemberTypes() {
|
|
3486
|
+
return this.expectOptionalToken(_tokenKind.TokenKind.EQUALS) ? this.delimitedMany(_tokenKind.TokenKind.PIPE, this.parseNamedType) : [];
|
|
3487
|
+
}
|
|
3488
|
+
/**
|
|
3489
|
+
* EnumTypeDefinition :
|
|
3490
|
+
* - Description? enum Name Directives[Const]? EnumValuesDefinition?
|
|
3491
|
+
*
|
|
3492
|
+
* @internal
|
|
3493
|
+
*/
|
|
3494
|
+
parseEnumTypeDefinition() {
|
|
3495
|
+
const start = this._lexer.token;
|
|
3496
|
+
const description = this.parseDescription();
|
|
3497
|
+
this.expectKeyword("enum");
|
|
3498
|
+
const name = this.parseName();
|
|
3499
|
+
const directives = this.parseConstDirectives();
|
|
3500
|
+
const values = this.parseEnumValuesDefinition();
|
|
3501
|
+
return this.node(start, {
|
|
3502
|
+
kind: _kinds.Kind.ENUM_TYPE_DEFINITION,
|
|
3503
|
+
description,
|
|
3504
|
+
name,
|
|
3505
|
+
directives,
|
|
3506
|
+
values
|
|
3507
|
+
});
|
|
3508
|
+
}
|
|
3509
|
+
/**
|
|
3510
|
+
* ```
|
|
3511
|
+
* EnumValuesDefinition : { EnumValueDefinition+ }
|
|
3512
|
+
* ```
|
|
3513
|
+
*
|
|
3514
|
+
* @internal
|
|
3515
|
+
*/
|
|
3516
|
+
parseEnumValuesDefinition() {
|
|
3517
|
+
return this.optionalMany(_tokenKind.TokenKind.BRACE_L, this.parseEnumValueDefinition, _tokenKind.TokenKind.BRACE_R);
|
|
3518
|
+
}
|
|
3519
|
+
/**
|
|
3520
|
+
* EnumValueDefinition : Description? EnumValue Directives[Const]?
|
|
3521
|
+
*
|
|
3522
|
+
* @internal
|
|
3523
|
+
*/
|
|
3524
|
+
parseEnumValueDefinition() {
|
|
3525
|
+
const start = this._lexer.token;
|
|
3526
|
+
const description = this.parseDescription();
|
|
3527
|
+
const name = this.parseEnumValueName();
|
|
3528
|
+
const directives = this.parseConstDirectives();
|
|
3529
|
+
return this.node(start, {
|
|
3530
|
+
kind: _kinds.Kind.ENUM_VALUE_DEFINITION,
|
|
3531
|
+
description,
|
|
3532
|
+
name,
|
|
3533
|
+
directives
|
|
3534
|
+
});
|
|
3535
|
+
}
|
|
3536
|
+
/**
|
|
3537
|
+
* EnumValue : Name but not `true`, `false` or `null`
|
|
3538
|
+
*
|
|
3539
|
+
* @internal
|
|
3540
|
+
*/
|
|
3541
|
+
parseEnumValueName() {
|
|
3542
|
+
if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null") throw (0, _syntaxError.syntaxError)(this._lexer.source, this._lexer.token.start, `${getTokenDesc(this._lexer.token)} is reserved and cannot be used for an enum value.`);
|
|
3543
|
+
return this.parseName();
|
|
3544
|
+
}
|
|
3545
|
+
/**
|
|
3546
|
+
* InputObjectTypeDefinition :
|
|
3547
|
+
* - Description? input Name Directives[Const]? InputFieldsDefinition?
|
|
3548
|
+
*
|
|
3549
|
+
* @internal
|
|
3550
|
+
*/
|
|
3551
|
+
parseInputObjectTypeDefinition() {
|
|
3552
|
+
const start = this._lexer.token;
|
|
3553
|
+
const description = this.parseDescription();
|
|
3554
|
+
this.expectKeyword("input");
|
|
3555
|
+
const name = this.parseName();
|
|
3556
|
+
const directives = this.parseConstDirectives();
|
|
3557
|
+
const fields = this.parseInputFieldsDefinition();
|
|
3558
|
+
return this.node(start, {
|
|
3559
|
+
kind: _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
3560
|
+
description,
|
|
3561
|
+
name,
|
|
3562
|
+
directives,
|
|
3563
|
+
fields
|
|
3564
|
+
});
|
|
3565
|
+
}
|
|
3566
|
+
/**
|
|
3567
|
+
* ```
|
|
3568
|
+
* InputFieldsDefinition : { InputValueDefinition+ }
|
|
3569
|
+
* ```
|
|
3570
|
+
*
|
|
3571
|
+
* @internal
|
|
3572
|
+
*/
|
|
3573
|
+
parseInputFieldsDefinition() {
|
|
3574
|
+
return this.optionalMany(_tokenKind.TokenKind.BRACE_L, this.parseInputValueDef, _tokenKind.TokenKind.BRACE_R);
|
|
3575
|
+
}
|
|
3576
|
+
/**
|
|
3577
|
+
* TypeSystemExtension :
|
|
3578
|
+
* - SchemaExtension
|
|
3579
|
+
* - TypeExtension
|
|
3580
|
+
*
|
|
3581
|
+
* TypeExtension :
|
|
3582
|
+
* - ScalarTypeExtension
|
|
3583
|
+
* - ObjectTypeExtension
|
|
3584
|
+
* - InterfaceTypeExtension
|
|
3585
|
+
* - UnionTypeExtension
|
|
3586
|
+
* - EnumTypeExtension
|
|
3587
|
+
* - InputObjectTypeDefinition
|
|
3588
|
+
* - DirectiveDefinitionExtension
|
|
3589
|
+
*
|
|
3590
|
+
* @internal
|
|
3591
|
+
*/
|
|
3592
|
+
parseTypeSystemExtension() {
|
|
3593
|
+
const keywordToken = this._lexer.lookahead();
|
|
3594
|
+
if (keywordToken.kind === _tokenKind.TokenKind.NAME) switch (keywordToken.value) {
|
|
3595
|
+
case "schema": return this.parseSchemaExtension();
|
|
3596
|
+
case "scalar": return this.parseScalarTypeExtension();
|
|
3597
|
+
case "type": return this.parseObjectTypeExtension();
|
|
3598
|
+
case "interface": return this.parseInterfaceTypeExtension();
|
|
3599
|
+
case "union": return this.parseUnionTypeExtension();
|
|
3600
|
+
case "enum": return this.parseEnumTypeExtension();
|
|
3601
|
+
case "input": return this.parseInputObjectTypeExtension();
|
|
3602
|
+
case "directive": if (this._options.experimentalDirectivesOnDirectiveDefinitions) return this.parseDirectiveDefinitionExtension();
|
|
3603
|
+
}
|
|
3604
|
+
throw this.unexpected(keywordToken);
|
|
3605
|
+
}
|
|
3606
|
+
/**
|
|
3607
|
+
* ```
|
|
3608
|
+
* SchemaExtension :
|
|
3609
|
+
* - extend schema Directives[Const]? { OperationTypeDefinition+ }
|
|
3610
|
+
* - extend schema Directives[Const]
|
|
3611
|
+
* ```
|
|
3612
|
+
*
|
|
3613
|
+
* @internal
|
|
3614
|
+
*/
|
|
3615
|
+
parseSchemaExtension() {
|
|
3616
|
+
const start = this._lexer.token;
|
|
3617
|
+
this.expectKeyword("extend");
|
|
3618
|
+
this.expectKeyword("schema");
|
|
3619
|
+
const directives = this.parseConstDirectives();
|
|
3620
|
+
const operationTypes = this.optionalMany(_tokenKind.TokenKind.BRACE_L, this.parseOperationTypeDefinition, _tokenKind.TokenKind.BRACE_R);
|
|
3621
|
+
if (directives.length === 0 && operationTypes.length === 0) throw this.unexpected();
|
|
3622
|
+
return this.node(start, {
|
|
3623
|
+
kind: _kinds.Kind.SCHEMA_EXTENSION,
|
|
3624
|
+
directives,
|
|
3625
|
+
operationTypes
|
|
3626
|
+
});
|
|
3627
|
+
}
|
|
3628
|
+
/**
|
|
3629
|
+
* ScalarTypeExtension :
|
|
3630
|
+
* - extend scalar Name Directives[Const]
|
|
3631
|
+
*
|
|
3632
|
+
* @internal
|
|
3633
|
+
*/
|
|
3634
|
+
parseScalarTypeExtension() {
|
|
3635
|
+
const start = this._lexer.token;
|
|
3636
|
+
this.expectKeyword("extend");
|
|
3637
|
+
this.expectKeyword("scalar");
|
|
3638
|
+
const name = this.parseName();
|
|
3639
|
+
const directives = this.parseConstDirectives();
|
|
3640
|
+
if (directives.length === 0) throw this.unexpected();
|
|
3641
|
+
return this.node(start, {
|
|
3642
|
+
kind: _kinds.Kind.SCALAR_TYPE_EXTENSION,
|
|
3643
|
+
name,
|
|
3644
|
+
directives
|
|
3645
|
+
});
|
|
3646
|
+
}
|
|
3647
|
+
/**
|
|
3648
|
+
* ObjectTypeExtension :
|
|
3649
|
+
* - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
|
|
3650
|
+
* - extend type Name ImplementsInterfaces? Directives[Const]
|
|
3651
|
+
* - extend type Name ImplementsInterfaces
|
|
3652
|
+
*
|
|
3653
|
+
* @internal
|
|
3654
|
+
*/
|
|
3655
|
+
parseObjectTypeExtension() {
|
|
3656
|
+
const start = this._lexer.token;
|
|
3657
|
+
this.expectKeyword("extend");
|
|
3658
|
+
this.expectKeyword("type");
|
|
3659
|
+
const name = this.parseName();
|
|
3660
|
+
const interfaces = this.parseImplementsInterfaces();
|
|
3661
|
+
const directives = this.parseConstDirectives();
|
|
3662
|
+
const fields = this.parseFieldsDefinition();
|
|
3663
|
+
if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) throw this.unexpected();
|
|
3664
|
+
return this.node(start, {
|
|
3665
|
+
kind: _kinds.Kind.OBJECT_TYPE_EXTENSION,
|
|
3666
|
+
name,
|
|
3667
|
+
interfaces,
|
|
3668
|
+
directives,
|
|
3669
|
+
fields
|
|
3670
|
+
});
|
|
3671
|
+
}
|
|
3672
|
+
/**
|
|
3673
|
+
* InterfaceTypeExtension :
|
|
3674
|
+
* - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
|
|
3675
|
+
* - extend interface Name ImplementsInterfaces? Directives[Const]
|
|
3676
|
+
* - extend interface Name ImplementsInterfaces
|
|
3677
|
+
*
|
|
3678
|
+
* @internal
|
|
3679
|
+
*/
|
|
3680
|
+
parseInterfaceTypeExtension() {
|
|
3681
|
+
const start = this._lexer.token;
|
|
3682
|
+
this.expectKeyword("extend");
|
|
3683
|
+
this.expectKeyword("interface");
|
|
3684
|
+
const name = this.parseName();
|
|
3685
|
+
const interfaces = this.parseImplementsInterfaces();
|
|
3686
|
+
const directives = this.parseConstDirectives();
|
|
3687
|
+
const fields = this.parseFieldsDefinition();
|
|
3688
|
+
if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) throw this.unexpected();
|
|
3689
|
+
return this.node(start, {
|
|
3690
|
+
kind: _kinds.Kind.INTERFACE_TYPE_EXTENSION,
|
|
3691
|
+
name,
|
|
3692
|
+
interfaces,
|
|
3693
|
+
directives,
|
|
3694
|
+
fields
|
|
3695
|
+
});
|
|
3696
|
+
}
|
|
3697
|
+
/**
|
|
3698
|
+
* UnionTypeExtension :
|
|
3699
|
+
* - extend union Name Directives[Const]? UnionMemberTypes
|
|
3700
|
+
* - extend union Name Directives[Const]
|
|
3701
|
+
*
|
|
3702
|
+
* @internal
|
|
3703
|
+
*/
|
|
3704
|
+
parseUnionTypeExtension() {
|
|
3705
|
+
const start = this._lexer.token;
|
|
3706
|
+
this.expectKeyword("extend");
|
|
3707
|
+
this.expectKeyword("union");
|
|
3708
|
+
const name = this.parseName();
|
|
3709
|
+
const directives = this.parseConstDirectives();
|
|
3710
|
+
const types = this.parseUnionMemberTypes();
|
|
3711
|
+
if (directives.length === 0 && types.length === 0) throw this.unexpected();
|
|
3712
|
+
return this.node(start, {
|
|
3713
|
+
kind: _kinds.Kind.UNION_TYPE_EXTENSION,
|
|
3714
|
+
name,
|
|
3715
|
+
directives,
|
|
3716
|
+
types
|
|
3717
|
+
});
|
|
3718
|
+
}
|
|
3719
|
+
/**
|
|
3720
|
+
* EnumTypeExtension :
|
|
3721
|
+
* - extend enum Name Directives[Const]? EnumValuesDefinition
|
|
3722
|
+
* - extend enum Name Directives[Const]
|
|
3723
|
+
*
|
|
3724
|
+
* @internal
|
|
3725
|
+
*/
|
|
3726
|
+
parseEnumTypeExtension() {
|
|
3727
|
+
const start = this._lexer.token;
|
|
3728
|
+
this.expectKeyword("extend");
|
|
3729
|
+
this.expectKeyword("enum");
|
|
3730
|
+
const name = this.parseName();
|
|
3731
|
+
const directives = this.parseConstDirectives();
|
|
3732
|
+
const values = this.parseEnumValuesDefinition();
|
|
3733
|
+
if (directives.length === 0 && values.length === 0) throw this.unexpected();
|
|
3734
|
+
return this.node(start, {
|
|
3735
|
+
kind: _kinds.Kind.ENUM_TYPE_EXTENSION,
|
|
3736
|
+
name,
|
|
3737
|
+
directives,
|
|
3738
|
+
values
|
|
3739
|
+
});
|
|
3740
|
+
}
|
|
3741
|
+
/**
|
|
3742
|
+
* InputObjectTypeExtension :
|
|
3743
|
+
* - extend input Name Directives[Const]? InputFieldsDefinition
|
|
3744
|
+
* - extend input Name Directives[Const]
|
|
3745
|
+
*
|
|
3746
|
+
* @internal
|
|
3747
|
+
*/
|
|
3748
|
+
parseInputObjectTypeExtension() {
|
|
3749
|
+
const start = this._lexer.token;
|
|
3750
|
+
this.expectKeyword("extend");
|
|
3751
|
+
this.expectKeyword("input");
|
|
3752
|
+
const name = this.parseName();
|
|
3753
|
+
const directives = this.parseConstDirectives();
|
|
3754
|
+
const fields = this.parseInputFieldsDefinition();
|
|
3755
|
+
if (directives.length === 0 && fields.length === 0) throw this.unexpected();
|
|
3756
|
+
return this.node(start, {
|
|
3757
|
+
kind: _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION,
|
|
3758
|
+
name,
|
|
3759
|
+
directives,
|
|
3760
|
+
fields
|
|
3761
|
+
});
|
|
3762
|
+
}
|
|
3763
|
+
parseDirectiveDefinitionExtension() {
|
|
3764
|
+
const start = this._lexer.token;
|
|
3765
|
+
this.expectKeyword("extend");
|
|
3766
|
+
this.expectKeyword("directive");
|
|
3767
|
+
this.expectToken(_tokenKind.TokenKind.AT);
|
|
3768
|
+
const name = this.parseName();
|
|
3769
|
+
const directives = this.parseConstDirectives();
|
|
3770
|
+
if (directives.length === 0) throw this.unexpected();
|
|
3771
|
+
return this.node(start, {
|
|
3772
|
+
kind: _kinds.Kind.DIRECTIVE_EXTENSION,
|
|
3773
|
+
name,
|
|
3774
|
+
directives
|
|
3775
|
+
});
|
|
3776
|
+
}
|
|
3777
|
+
/**
|
|
3778
|
+
* ```
|
|
3779
|
+
* DirectiveDefinition :
|
|
3780
|
+
* - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
|
|
3781
|
+
* ```
|
|
3782
|
+
*
|
|
3783
|
+
* @internal
|
|
3784
|
+
*/
|
|
3785
|
+
parseDirectiveDefinition() {
|
|
3786
|
+
const start = this._lexer.token;
|
|
3787
|
+
const description = this.parseDescription();
|
|
3788
|
+
this.expectKeyword("directive");
|
|
3789
|
+
this.expectToken(_tokenKind.TokenKind.AT);
|
|
3790
|
+
const name = this.parseName();
|
|
3791
|
+
const args = this.parseArgumentDefs();
|
|
3792
|
+
const directives = this._options.experimentalDirectivesOnDirectiveDefinitions ? this.parseConstDirectives() : [];
|
|
3793
|
+
const repeatable = this.expectOptionalKeyword("repeatable");
|
|
3794
|
+
this.expectKeyword("on");
|
|
3795
|
+
const locations = this.parseDirectiveLocations();
|
|
3796
|
+
return this.node(start, {
|
|
3797
|
+
kind: _kinds.Kind.DIRECTIVE_DEFINITION,
|
|
3798
|
+
description,
|
|
3799
|
+
name,
|
|
3800
|
+
arguments: args,
|
|
3801
|
+
directives,
|
|
3802
|
+
repeatable,
|
|
3803
|
+
locations
|
|
3804
|
+
});
|
|
3805
|
+
}
|
|
3806
|
+
/**
|
|
3807
|
+
* DirectiveLocations :
|
|
3808
|
+
* - `|`? DirectiveLocation
|
|
3809
|
+
* - DirectiveLocations | DirectiveLocation
|
|
3810
|
+
*
|
|
3811
|
+
* @internal
|
|
3812
|
+
*/
|
|
3813
|
+
parseDirectiveLocations() {
|
|
3814
|
+
return this.delimitedMany(_tokenKind.TokenKind.PIPE, this.parseDirectiveLocation);
|
|
3815
|
+
}
|
|
3816
|
+
parseDirectiveLocation() {
|
|
3817
|
+
const start = this._lexer.token;
|
|
3818
|
+
const name = this.parseName();
|
|
3819
|
+
if (Object.prototype.hasOwnProperty.call(_directiveLocation.DirectiveLocation, name.value)) return name;
|
|
3820
|
+
throw this.unexpected(start);
|
|
3821
|
+
}
|
|
3822
|
+
/**
|
|
3823
|
+
* SchemaCoordinate :
|
|
3824
|
+
* - Name
|
|
3825
|
+
* - Name . Name
|
|
3826
|
+
* - Name . Name ( Name : )
|
|
3827
|
+
* - \@ Name
|
|
3828
|
+
* - \@ Name ( Name : )
|
|
3829
|
+
* @returns Parsed schema coordinate AST.
|
|
3830
|
+
* @example
|
|
3831
|
+
* ```ts
|
|
3832
|
+
* import { Parser, Source } from 'graphql/language';
|
|
3833
|
+
*
|
|
3834
|
+
* const typeCoordinate = new Parser(new Source('User.name')).parseSchemaCoordinate();
|
|
3835
|
+
* const directiveCoordinate = new Parser(new Source('@include(if:)')).parseSchemaCoordinate();
|
|
3836
|
+
*
|
|
3837
|
+
* typeCoordinate.name.value; // => 'User'
|
|
3838
|
+
* typeCoordinate.memberName?.value; // => 'name'
|
|
3839
|
+
* directiveCoordinate.name.value; // => 'deprecated'
|
|
3840
|
+
* directiveCoordinate.argumentName?.value; // => 'reason'
|
|
3841
|
+
* ```
|
|
3842
|
+
*/
|
|
3843
|
+
parseSchemaCoordinate() {
|
|
3844
|
+
const start = this._lexer.token;
|
|
3845
|
+
const ofDirective = this.expectOptionalToken(_tokenKind.TokenKind.AT);
|
|
3846
|
+
const name = this.parseName();
|
|
3847
|
+
let memberName;
|
|
3848
|
+
if (!ofDirective && this.expectOptionalToken(_tokenKind.TokenKind.DOT)) memberName = this.parseName();
|
|
3849
|
+
let argumentName;
|
|
3850
|
+
if ((ofDirective || memberName) && this.expectOptionalToken(_tokenKind.TokenKind.PAREN_L)) {
|
|
3851
|
+
argumentName = this.parseName();
|
|
3852
|
+
this.expectToken(_tokenKind.TokenKind.COLON);
|
|
3853
|
+
this.expectToken(_tokenKind.TokenKind.PAREN_R);
|
|
3854
|
+
}
|
|
3855
|
+
if (ofDirective) {
|
|
3856
|
+
if (argumentName) return this.node(start, {
|
|
3857
|
+
kind: _kinds.Kind.DIRECTIVE_ARGUMENT_COORDINATE,
|
|
3858
|
+
name,
|
|
3859
|
+
argumentName
|
|
3860
|
+
});
|
|
3861
|
+
return this.node(start, {
|
|
3862
|
+
kind: _kinds.Kind.DIRECTIVE_COORDINATE,
|
|
3863
|
+
name
|
|
3864
|
+
});
|
|
3865
|
+
} else if (memberName) {
|
|
3866
|
+
if (argumentName) return this.node(start, {
|
|
3867
|
+
kind: _kinds.Kind.ARGUMENT_COORDINATE,
|
|
3868
|
+
name,
|
|
3869
|
+
fieldName: memberName,
|
|
3870
|
+
argumentName
|
|
3871
|
+
});
|
|
3872
|
+
return this.node(start, {
|
|
3873
|
+
kind: _kinds.Kind.MEMBER_COORDINATE,
|
|
3874
|
+
name,
|
|
3875
|
+
memberName
|
|
3876
|
+
});
|
|
3877
|
+
}
|
|
3878
|
+
return this.node(start, {
|
|
3879
|
+
kind: _kinds.Kind.TYPE_COORDINATE,
|
|
3880
|
+
name
|
|
3881
|
+
});
|
|
3882
|
+
}
|
|
3883
|
+
/**
|
|
3884
|
+
* Returns a node that, if configured to do so, sets a "loc" field as a
|
|
3885
|
+
* location object, used to identify the place in the source that created a
|
|
3886
|
+
* given parsed object.
|
|
3887
|
+
*
|
|
3888
|
+
* @internal
|
|
3889
|
+
*/
|
|
3890
|
+
node(startToken, node) {
|
|
3891
|
+
if (this._options.noLocation !== true) node.loc = new _ast.Location(startToken, this._lexer.lastToken, this._lexer.source);
|
|
3892
|
+
return node;
|
|
3893
|
+
}
|
|
3894
|
+
/**
|
|
3895
|
+
* Determines if the next token is of a given kind
|
|
3896
|
+
*
|
|
3897
|
+
* @internal
|
|
3898
|
+
*/
|
|
3899
|
+
peek(kind) {
|
|
3900
|
+
return this._lexer.token.kind === kind;
|
|
3901
|
+
}
|
|
3902
|
+
/**
|
|
3903
|
+
* If the next token is of the given kind, return that token after advancing the lexer.
|
|
3904
|
+
* Otherwise, do not change the parser state and throw an error.
|
|
3905
|
+
*
|
|
3906
|
+
* @internal
|
|
3907
|
+
*/
|
|
3908
|
+
expectToken(kind) {
|
|
3909
|
+
const token = this._lexer.token;
|
|
3910
|
+
if (token.kind === kind) {
|
|
3911
|
+
this.advanceLexer();
|
|
3912
|
+
return token;
|
|
3913
|
+
}
|
|
3914
|
+
throw (0, _syntaxError.syntaxError)(this._lexer.source, token.start, `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`);
|
|
3915
|
+
}
|
|
3916
|
+
/**
|
|
3917
|
+
* If the next token is of the given kind, return "true" after advancing the lexer.
|
|
3918
|
+
* Otherwise, do not change the parser state and return "false".
|
|
3919
|
+
*
|
|
3920
|
+
* @internal
|
|
3921
|
+
*/
|
|
3922
|
+
expectOptionalToken(kind) {
|
|
3923
|
+
if (this._lexer.token.kind === kind) {
|
|
3924
|
+
this.advanceLexer();
|
|
3925
|
+
return true;
|
|
3926
|
+
}
|
|
3927
|
+
return false;
|
|
3928
|
+
}
|
|
3929
|
+
/**
|
|
3930
|
+
* If the next token is a given keyword, advance the lexer.
|
|
3931
|
+
* Otherwise, do not change the parser state and throw an error.
|
|
3932
|
+
*
|
|
3933
|
+
* @internal
|
|
3934
|
+
*/
|
|
3935
|
+
expectKeyword(value) {
|
|
3936
|
+
const token = this._lexer.token;
|
|
3937
|
+
if (token.kind === _tokenKind.TokenKind.NAME && token.value === value) this.advanceLexer();
|
|
3938
|
+
else throw (0, _syntaxError.syntaxError)(this._lexer.source, token.start, `Expected "${value}", found ${getTokenDesc(token)}.`);
|
|
3939
|
+
}
|
|
3940
|
+
/**
|
|
3941
|
+
* If the next token is a given keyword, return "true" after advancing the lexer.
|
|
3942
|
+
* Otherwise, do not change the parser state and return "false".
|
|
3943
|
+
*
|
|
3944
|
+
* @internal
|
|
3945
|
+
*/
|
|
3946
|
+
expectOptionalKeyword(value) {
|
|
3947
|
+
const token = this._lexer.token;
|
|
3948
|
+
if (token.kind === _tokenKind.TokenKind.NAME && token.value === value) {
|
|
3949
|
+
this.advanceLexer();
|
|
3950
|
+
return true;
|
|
3951
|
+
}
|
|
3952
|
+
return false;
|
|
3953
|
+
}
|
|
3954
|
+
/**
|
|
3955
|
+
* Helper function for creating an error when an unexpected lexed token is encountered.
|
|
3956
|
+
*
|
|
3957
|
+
* @internal
|
|
3958
|
+
*/
|
|
3959
|
+
unexpected(atToken) {
|
|
3960
|
+
const token = atToken !== null && atToken !== void 0 ? atToken : this._lexer.token;
|
|
3961
|
+
return (0, _syntaxError.syntaxError)(this._lexer.source, token.start, `Unexpected ${getTokenDesc(token)}.`);
|
|
3962
|
+
}
|
|
3963
|
+
/**
|
|
3964
|
+
* Returns a possibly empty list of parse nodes, determined by the parseFn.
|
|
3965
|
+
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
3966
|
+
* Advances the parser to the next lex token after the closing token.
|
|
3967
|
+
*
|
|
3968
|
+
* @internal
|
|
3969
|
+
*/
|
|
3970
|
+
any(openKind, parseFn, closeKind) {
|
|
3971
|
+
this.expectToken(openKind);
|
|
3972
|
+
const nodes = [];
|
|
3973
|
+
while (!this.expectOptionalToken(closeKind)) nodes.push(parseFn.call(this));
|
|
3974
|
+
return nodes;
|
|
3975
|
+
}
|
|
3976
|
+
/**
|
|
3977
|
+
* Returns a list of parse nodes, determined by the parseFn.
|
|
3978
|
+
* It can be empty only if open token is missing otherwise it will always return non-empty list
|
|
3979
|
+
* that begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
3980
|
+
* Advances the parser to the next lex token after the closing token.
|
|
3981
|
+
*
|
|
3982
|
+
* @internal
|
|
3983
|
+
*/
|
|
3984
|
+
optionalMany(openKind, parseFn, closeKind) {
|
|
3985
|
+
if (this.expectOptionalToken(openKind)) {
|
|
3986
|
+
const nodes = [];
|
|
3987
|
+
do
|
|
3988
|
+
nodes.push(parseFn.call(this));
|
|
3989
|
+
while (!this.expectOptionalToken(closeKind));
|
|
3990
|
+
return nodes;
|
|
3991
|
+
}
|
|
3992
|
+
return [];
|
|
3993
|
+
}
|
|
3994
|
+
/**
|
|
3995
|
+
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
3996
|
+
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
3997
|
+
* Advances the parser to the next lex token after the closing token.
|
|
3998
|
+
*
|
|
3999
|
+
* @internal
|
|
4000
|
+
*/
|
|
4001
|
+
many(openKind, parseFn, closeKind) {
|
|
4002
|
+
this.expectToken(openKind);
|
|
4003
|
+
const nodes = [];
|
|
4004
|
+
do
|
|
4005
|
+
nodes.push(parseFn.call(this));
|
|
4006
|
+
while (!this.expectOptionalToken(closeKind));
|
|
4007
|
+
return nodes;
|
|
4008
|
+
}
|
|
4009
|
+
/**
|
|
4010
|
+
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
4011
|
+
* This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
|
|
4012
|
+
* Advances the parser to the next lex token after last item in the list.
|
|
4013
|
+
*
|
|
4014
|
+
* @internal
|
|
4015
|
+
*/
|
|
4016
|
+
delimitedMany(delimiterKind, parseFn) {
|
|
4017
|
+
this.expectOptionalToken(delimiterKind);
|
|
4018
|
+
const nodes = [];
|
|
4019
|
+
do
|
|
4020
|
+
nodes.push(parseFn.call(this));
|
|
4021
|
+
while (this.expectOptionalToken(delimiterKind));
|
|
4022
|
+
return nodes;
|
|
4023
|
+
}
|
|
4024
|
+
advanceLexer() {
|
|
4025
|
+
const { maxTokens } = this._options;
|
|
4026
|
+
const token = this._lexer.advance();
|
|
4027
|
+
if (token.kind !== _tokenKind.TokenKind.EOF) {
|
|
4028
|
+
++this._tokenCounter;
|
|
4029
|
+
if (maxTokens !== void 0 && this._tokenCounter > maxTokens) throw (0, _syntaxError.syntaxError)(this._lexer.source, token.start, `Document contains more that ${maxTokens} tokens. Parsing aborted.`);
|
|
4030
|
+
}
|
|
4031
|
+
}
|
|
4032
|
+
};
|
|
4033
|
+
/**
|
|
4034
|
+
* A helper function to describe a token as a string for debugging.
|
|
4035
|
+
*
|
|
4036
|
+
* @internal
|
|
4037
|
+
*/
|
|
4038
|
+
exports.Parser = Parser;
|
|
4039
|
+
function getTokenDesc(token) {
|
|
4040
|
+
const value = token.value;
|
|
4041
|
+
return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : "");
|
|
4042
|
+
}
|
|
4043
|
+
/**
|
|
4044
|
+
* A helper function to describe a token kind as a string for debugging.
|
|
4045
|
+
*
|
|
4046
|
+
* @internal
|
|
4047
|
+
*/
|
|
4048
|
+
function getTokenKindDesc(kind) {
|
|
4049
|
+
return (0, _lexer.isPunctuatorTokenKind)(kind) ? `"${kind}"` : kind;
|
|
4050
|
+
}
|
|
4051
|
+
}));
|
|
4052
|
+
//#endregion
|
|
4053
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/printString.js
|
|
4054
|
+
var require_printString = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4055
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4056
|
+
exports.printString = printString;
|
|
4057
|
+
/**
|
|
4058
|
+
* Prints a string as a GraphQL StringValue literal. Replaces control characters
|
|
4059
|
+
* and excluded characters (" U+0022 and \\ U+005C) with escape sequences.
|
|
4060
|
+
*
|
|
4061
|
+
* @internal
|
|
4062
|
+
*/
|
|
4063
|
+
function printString(str) {
|
|
4064
|
+
return `"${str.replace(escapedRegExp, escapedReplacer)}"`;
|
|
4065
|
+
}
|
|
4066
|
+
/** @internal */
|
|
4067
|
+
const escapedRegExp = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
|
|
4068
|
+
function escapedReplacer(str) {
|
|
4069
|
+
return escapeSequences[str.charCodeAt(0)];
|
|
4070
|
+
}
|
|
4071
|
+
const escapeSequences = [
|
|
4072
|
+
"\\u0000",
|
|
4073
|
+
"\\u0001",
|
|
4074
|
+
"\\u0002",
|
|
4075
|
+
"\\u0003",
|
|
4076
|
+
"\\u0004",
|
|
4077
|
+
"\\u0005",
|
|
4078
|
+
"\\u0006",
|
|
4079
|
+
"\\u0007",
|
|
4080
|
+
"\\b",
|
|
4081
|
+
"\\t",
|
|
4082
|
+
"\\n",
|
|
4083
|
+
"\\u000B",
|
|
4084
|
+
"\\f",
|
|
4085
|
+
"\\r",
|
|
4086
|
+
"\\u000E",
|
|
4087
|
+
"\\u000F",
|
|
4088
|
+
"\\u0010",
|
|
4089
|
+
"\\u0011",
|
|
4090
|
+
"\\u0012",
|
|
4091
|
+
"\\u0013",
|
|
4092
|
+
"\\u0014",
|
|
4093
|
+
"\\u0015",
|
|
4094
|
+
"\\u0016",
|
|
4095
|
+
"\\u0017",
|
|
4096
|
+
"\\u0018",
|
|
4097
|
+
"\\u0019",
|
|
4098
|
+
"\\u001A",
|
|
4099
|
+
"\\u001B",
|
|
4100
|
+
"\\u001C",
|
|
4101
|
+
"\\u001D",
|
|
4102
|
+
"\\u001E",
|
|
4103
|
+
"\\u001F",
|
|
4104
|
+
"",
|
|
4105
|
+
"",
|
|
4106
|
+
"\\\"",
|
|
4107
|
+
"",
|
|
4108
|
+
"",
|
|
4109
|
+
"",
|
|
4110
|
+
"",
|
|
4111
|
+
"",
|
|
4112
|
+
"",
|
|
4113
|
+
"",
|
|
4114
|
+
"",
|
|
4115
|
+
"",
|
|
4116
|
+
"",
|
|
4117
|
+
"",
|
|
4118
|
+
"",
|
|
4119
|
+
"",
|
|
4120
|
+
"",
|
|
4121
|
+
"",
|
|
4122
|
+
"",
|
|
4123
|
+
"",
|
|
4124
|
+
"",
|
|
4125
|
+
"",
|
|
4126
|
+
"",
|
|
4127
|
+
"",
|
|
4128
|
+
"",
|
|
4129
|
+
"",
|
|
4130
|
+
"",
|
|
4131
|
+
"",
|
|
4132
|
+
"",
|
|
4133
|
+
"",
|
|
4134
|
+
"",
|
|
4135
|
+
"",
|
|
4136
|
+
"",
|
|
4137
|
+
"",
|
|
4138
|
+
"",
|
|
4139
|
+
"",
|
|
4140
|
+
"",
|
|
4141
|
+
"",
|
|
4142
|
+
"",
|
|
4143
|
+
"",
|
|
4144
|
+
"",
|
|
4145
|
+
"",
|
|
4146
|
+
"",
|
|
4147
|
+
"",
|
|
4148
|
+
"",
|
|
4149
|
+
"",
|
|
4150
|
+
"",
|
|
4151
|
+
"",
|
|
4152
|
+
"",
|
|
4153
|
+
"",
|
|
4154
|
+
"",
|
|
4155
|
+
"",
|
|
4156
|
+
"",
|
|
4157
|
+
"",
|
|
4158
|
+
"",
|
|
4159
|
+
"",
|
|
4160
|
+
"",
|
|
4161
|
+
"",
|
|
4162
|
+
"",
|
|
4163
|
+
"",
|
|
4164
|
+
"\\\\",
|
|
4165
|
+
"",
|
|
4166
|
+
"",
|
|
4167
|
+
"",
|
|
4168
|
+
"",
|
|
4169
|
+
"",
|
|
4170
|
+
"",
|
|
4171
|
+
"",
|
|
4172
|
+
"",
|
|
4173
|
+
"",
|
|
4174
|
+
"",
|
|
4175
|
+
"",
|
|
4176
|
+
"",
|
|
4177
|
+
"",
|
|
4178
|
+
"",
|
|
4179
|
+
"",
|
|
4180
|
+
"",
|
|
4181
|
+
"",
|
|
4182
|
+
"",
|
|
4183
|
+
"",
|
|
4184
|
+
"",
|
|
4185
|
+
"",
|
|
4186
|
+
"",
|
|
4187
|
+
"",
|
|
4188
|
+
"",
|
|
4189
|
+
"",
|
|
4190
|
+
"",
|
|
4191
|
+
"",
|
|
4192
|
+
"",
|
|
4193
|
+
"",
|
|
4194
|
+
"",
|
|
4195
|
+
"",
|
|
4196
|
+
"",
|
|
4197
|
+
"",
|
|
4198
|
+
"",
|
|
4199
|
+
"\\u007F",
|
|
4200
|
+
"\\u0080",
|
|
4201
|
+
"\\u0081",
|
|
4202
|
+
"\\u0082",
|
|
4203
|
+
"\\u0083",
|
|
4204
|
+
"\\u0084",
|
|
4205
|
+
"\\u0085",
|
|
4206
|
+
"\\u0086",
|
|
4207
|
+
"\\u0087",
|
|
4208
|
+
"\\u0088",
|
|
4209
|
+
"\\u0089",
|
|
4210
|
+
"\\u008A",
|
|
4211
|
+
"\\u008B",
|
|
4212
|
+
"\\u008C",
|
|
4213
|
+
"\\u008D",
|
|
4214
|
+
"\\u008E",
|
|
4215
|
+
"\\u008F",
|
|
4216
|
+
"\\u0090",
|
|
4217
|
+
"\\u0091",
|
|
4218
|
+
"\\u0092",
|
|
4219
|
+
"\\u0093",
|
|
4220
|
+
"\\u0094",
|
|
4221
|
+
"\\u0095",
|
|
4222
|
+
"\\u0096",
|
|
4223
|
+
"\\u0097",
|
|
4224
|
+
"\\u0098",
|
|
4225
|
+
"\\u0099",
|
|
4226
|
+
"\\u009A",
|
|
4227
|
+
"\\u009B",
|
|
4228
|
+
"\\u009C",
|
|
4229
|
+
"\\u009D",
|
|
4230
|
+
"\\u009E",
|
|
4231
|
+
"\\u009F"
|
|
4232
|
+
];
|
|
4233
|
+
}));
|
|
4234
|
+
//#endregion
|
|
4235
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/visitor.js
|
|
4236
|
+
var require_visitor = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4237
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4238
|
+
exports.BREAK = void 0;
|
|
4239
|
+
exports.getEnterLeaveForKind = getEnterLeaveForKind;
|
|
4240
|
+
exports.getVisitFn = getVisitFn;
|
|
4241
|
+
exports.visit = visit;
|
|
4242
|
+
exports.visitInParallel = visitInParallel;
|
|
4243
|
+
var _devAssert = require_devAssert();
|
|
4244
|
+
var _inspect = require_inspect();
|
|
4245
|
+
var _ast = require_ast();
|
|
4246
|
+
var _kinds = require_kinds();
|
|
4247
|
+
/** @category Visiting */
|
|
4248
|
+
/** A value that can be returned from a visitor function to stop traversal. */
|
|
4249
|
+
const BREAK = Object.freeze({});
|
|
4250
|
+
/**
|
|
4251
|
+
* visit() will walk through an AST using a depth-first traversal, calling
|
|
4252
|
+
* the visitor's enter function at each node in the traversal, and calling the
|
|
4253
|
+
* leave function after visiting that node and all of its child nodes.
|
|
4254
|
+
*
|
|
4255
|
+
* By returning different values from the enter and leave functions, the
|
|
4256
|
+
* behavior of the visitor can be altered, including skipping over a sub-tree of
|
|
4257
|
+
* the AST (by returning false), editing the AST by returning a value or null
|
|
4258
|
+
* to remove the value, or to stop the whole traversal by returning BREAK.
|
|
4259
|
+
*
|
|
4260
|
+
* When using visit() to edit an AST, the original AST will not be modified, and
|
|
4261
|
+
* a new version of the AST with the changes applied will be returned from the
|
|
4262
|
+
* visit function.
|
|
4263
|
+
* @param root - The AST node at which to start traversal.
|
|
4264
|
+
* @param visitor - The visitor or reducer functions to call while traversing.
|
|
4265
|
+
* @param visitorKeys - Optional map of child keys to visit for each AST node kind.
|
|
4266
|
+
* @returns The original AST, an edited AST, or a reduced value depending on the visitor.
|
|
4267
|
+
* @typeParam N - The root AST node type returned when visiting without reducing.
|
|
4268
|
+
* @example
|
|
4269
|
+
* ```ts
|
|
4270
|
+
* // Return values control traversal: undefined makes no change, false skips
|
|
4271
|
+
* // a subtree, BREAK stops traversal, null removes a node, and any other
|
|
4272
|
+
* // value replaces the current node.
|
|
4273
|
+
* import { Kind, parse, print, visit } from 'graphql/language';
|
|
4274
|
+
*
|
|
4275
|
+
* const document = parse('{ hero { name } }');
|
|
4276
|
+
* const editedAST = visit(document, {
|
|
4277
|
+
* Field: (node) => {
|
|
4278
|
+
* if (node.name.value === 'hero') {
|
|
4279
|
+
* return {
|
|
4280
|
+
* ...node,
|
|
4281
|
+
* name: { kind: Kind.NAME, value: 'human' },
|
|
4282
|
+
* };
|
|
4283
|
+
* }
|
|
4284
|
+
* },
|
|
4285
|
+
* });
|
|
4286
|
+
*
|
|
4287
|
+
* print(editedAST); // => '{\n human {\n name\n }\n}'
|
|
4288
|
+
* ```
|
|
4289
|
+
* @example
|
|
4290
|
+
* ```ts
|
|
4291
|
+
* // A named visitor function runs when entering nodes of that kind.
|
|
4292
|
+
* import { parse, visit } from 'graphql/language';
|
|
4293
|
+
*
|
|
4294
|
+
* const document = parse('{ hero { name } }');
|
|
4295
|
+
* const fieldNames = [];
|
|
4296
|
+
*
|
|
4297
|
+
* visit(document, {
|
|
4298
|
+
* Field: (node) => {
|
|
4299
|
+
* fieldNames.push(node.name.value);
|
|
4300
|
+
* },
|
|
4301
|
+
* });
|
|
4302
|
+
*
|
|
4303
|
+
* fieldNames; // => ['hero', 'name']
|
|
4304
|
+
* ```
|
|
4305
|
+
* @example
|
|
4306
|
+
* ```ts
|
|
4307
|
+
* // A named visitor object can provide separate enter and leave handlers for
|
|
4308
|
+
* // nodes of that kind.
|
|
4309
|
+
* import { parse, visit } from 'graphql/language';
|
|
4310
|
+
*
|
|
4311
|
+
* const document = parse('{ hero { name } }');
|
|
4312
|
+
* const events = [];
|
|
4313
|
+
*
|
|
4314
|
+
* visit(document, {
|
|
4315
|
+
* Field: {
|
|
4316
|
+
* enter: (node) => {
|
|
4317
|
+
* events.push(`enter:${node.name.value}`);
|
|
4318
|
+
* },
|
|
4319
|
+
* leave: (node) => {
|
|
4320
|
+
* events.push(`leave:${node.name.value}`);
|
|
4321
|
+
* },
|
|
4322
|
+
* },
|
|
4323
|
+
* });
|
|
4324
|
+
*
|
|
4325
|
+
* events; // => ['enter:hero', 'enter:name', 'leave:name', 'leave:hero']
|
|
4326
|
+
* ```
|
|
4327
|
+
* @example
|
|
4328
|
+
* ```ts
|
|
4329
|
+
* // Generic enter and leave handlers run for every node.
|
|
4330
|
+
* import { parse, visit } from 'graphql/language';
|
|
4331
|
+
*
|
|
4332
|
+
* const document = parse('{ hero { name } }');
|
|
4333
|
+
* let enterCount = 0;
|
|
4334
|
+
* let leaveCount = 0;
|
|
4335
|
+
*
|
|
4336
|
+
* visit(document, {
|
|
4337
|
+
* enter: (node) => {
|
|
4338
|
+
* enterCount += 1;
|
|
4339
|
+
* },
|
|
4340
|
+
* leave: (node) => {
|
|
4341
|
+
* leaveCount += 1;
|
|
4342
|
+
* },
|
|
4343
|
+
* });
|
|
4344
|
+
*
|
|
4345
|
+
* enterCount; // => leaveCount
|
|
4346
|
+
* enterCount > 0; // => true
|
|
4347
|
+
* ```
|
|
4348
|
+
*/
|
|
4349
|
+
exports.BREAK = BREAK;
|
|
4350
|
+
/** @internal */
|
|
4351
|
+
function visit(root, visitor, visitorKeys = _ast.QueryDocumentKeys) {
|
|
4352
|
+
const enterLeaveMap = /* @__PURE__ */ new Map();
|
|
4353
|
+
for (const kind of Object.values(_kinds.Kind)) enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind));
|
|
4354
|
+
let stack = void 0;
|
|
4355
|
+
let inArray = Array.isArray(root);
|
|
4356
|
+
let keys = [root];
|
|
4357
|
+
let index = -1;
|
|
4358
|
+
let edits = [];
|
|
4359
|
+
let node = root;
|
|
4360
|
+
let key = void 0;
|
|
4361
|
+
let parent = void 0;
|
|
4362
|
+
const path = [];
|
|
4363
|
+
const ancestors = [];
|
|
4364
|
+
do {
|
|
4365
|
+
index++;
|
|
4366
|
+
const isLeaving = index === keys.length;
|
|
4367
|
+
const isEdited = isLeaving && edits.length !== 0;
|
|
4368
|
+
if (isLeaving) {
|
|
4369
|
+
key = ancestors.length === 0 ? void 0 : path[path.length - 1];
|
|
4370
|
+
node = parent;
|
|
4371
|
+
parent = ancestors.pop();
|
|
4372
|
+
if (isEdited) {
|
|
4373
|
+
if (inArray) {
|
|
4374
|
+
node = node.slice();
|
|
4375
|
+
let editOffset = 0;
|
|
4376
|
+
for (const [editKey, editValue] of edits) {
|
|
4377
|
+
const arrayKey = editKey - editOffset;
|
|
4378
|
+
if (editValue === null) {
|
|
4379
|
+
node.splice(arrayKey, 1);
|
|
4380
|
+
editOffset++;
|
|
4381
|
+
} else node[arrayKey] = editValue;
|
|
4382
|
+
}
|
|
4383
|
+
} else {
|
|
4384
|
+
node = { ...node };
|
|
4385
|
+
for (const [editKey, editValue] of edits) node[editKey] = editValue;
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
index = stack.index;
|
|
4389
|
+
keys = stack.keys;
|
|
4390
|
+
edits = stack.edits;
|
|
4391
|
+
inArray = stack.inArray;
|
|
4392
|
+
stack = stack.prev;
|
|
4393
|
+
} else if (parent) {
|
|
4394
|
+
key = inArray ? index : keys[index];
|
|
4395
|
+
node = parent[key];
|
|
4396
|
+
if (node === null || node === void 0) continue;
|
|
4397
|
+
path.push(key);
|
|
4398
|
+
}
|
|
4399
|
+
let result;
|
|
4400
|
+
if (!Array.isArray(node)) {
|
|
4401
|
+
var _enterLeaveMap$get, _enterLeaveMap$get2;
|
|
4402
|
+
(0, _ast.isNode)(node) || (0, _devAssert.devAssert)(false, `Invalid AST Node: ${(0, _inspect.inspect)(node)}.`);
|
|
4403
|
+
const visitFn = isLeaving ? (_enterLeaveMap$get = enterLeaveMap.get(node.kind)) === null || _enterLeaveMap$get === void 0 ? void 0 : _enterLeaveMap$get.leave : (_enterLeaveMap$get2 = enterLeaveMap.get(node.kind)) === null || _enterLeaveMap$get2 === void 0 ? void 0 : _enterLeaveMap$get2.enter;
|
|
4404
|
+
result = visitFn === null || visitFn === void 0 ? void 0 : visitFn.call(visitor, node, key, parent, path, ancestors);
|
|
4405
|
+
if (result === BREAK) break;
|
|
4406
|
+
if (result === false) {
|
|
4407
|
+
if (!isLeaving) {
|
|
4408
|
+
path.pop();
|
|
4409
|
+
continue;
|
|
4410
|
+
}
|
|
4411
|
+
} else if (result !== void 0) {
|
|
4412
|
+
edits.push([key, result]);
|
|
4413
|
+
if (!isLeaving) {
|
|
4414
|
+
if ((0, _ast.isNode)(result)) node = result;
|
|
4415
|
+
else {
|
|
4416
|
+
path.pop();
|
|
4417
|
+
continue;
|
|
4418
|
+
}
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4421
|
+
}
|
|
4422
|
+
if (result === void 0 && isEdited) edits.push([key, node]);
|
|
4423
|
+
if (isLeaving) path.pop();
|
|
4424
|
+
else {
|
|
4425
|
+
var _node$kind;
|
|
4426
|
+
stack = {
|
|
4427
|
+
inArray,
|
|
4428
|
+
index,
|
|
4429
|
+
keys,
|
|
4430
|
+
edits,
|
|
4431
|
+
prev: stack
|
|
4432
|
+
};
|
|
4433
|
+
inArray = Array.isArray(node);
|
|
4434
|
+
keys = inArray ? node : (_node$kind = visitorKeys[node.kind]) !== null && _node$kind !== void 0 ? _node$kind : [];
|
|
4435
|
+
index = -1;
|
|
4436
|
+
edits = [];
|
|
4437
|
+
if (parent) ancestors.push(parent);
|
|
4438
|
+
parent = node;
|
|
4439
|
+
}
|
|
4440
|
+
} while (stack !== void 0);
|
|
4441
|
+
if (edits.length !== 0) return edits[edits.length - 1][1];
|
|
4442
|
+
return root;
|
|
4443
|
+
}
|
|
4444
|
+
/**
|
|
4445
|
+
* Creates a new visitor instance which delegates to many visitors to run in
|
|
4446
|
+
* parallel. Each visitor will be visited for each node before moving on.
|
|
4447
|
+
*
|
|
4448
|
+
* If a prior visitor edits a node, no following visitors will see that node.
|
|
4449
|
+
* @param visitors - The visitors to merge into one parallel visitor.
|
|
4450
|
+
* @returns A visitor that delegates traversal to each provided visitor.
|
|
4451
|
+
* @example
|
|
4452
|
+
* ```ts
|
|
4453
|
+
* import { parse, visit, visitInParallel } from 'graphql/language';
|
|
4454
|
+
*
|
|
4455
|
+
* const document = parse('{ hero { name } }');
|
|
4456
|
+
* const events = [];
|
|
4457
|
+
*
|
|
4458
|
+
* visit(
|
|
4459
|
+
* document,
|
|
4460
|
+
* visitInParallel([
|
|
4461
|
+
* { Field: (node) => { events.push(`field:${node.name.value}`); } },
|
|
4462
|
+
* { Name: (node) => { events.push(`name:${node.value}`); } },
|
|
4463
|
+
* ]),
|
|
4464
|
+
* );
|
|
4465
|
+
*
|
|
4466
|
+
* events; // => ['field:hero', 'name:hero', 'field:name', 'name:name']
|
|
4467
|
+
* ```
|
|
4468
|
+
*/
|
|
4469
|
+
function visitInParallel(visitors) {
|
|
4470
|
+
const skipping = new Array(visitors.length).fill(null);
|
|
4471
|
+
const mergedVisitor = Object.create(null);
|
|
4472
|
+
for (const kind of Object.values(_kinds.Kind)) {
|
|
4473
|
+
let hasVisitor = false;
|
|
4474
|
+
const enterList = new Array(visitors.length).fill(void 0);
|
|
4475
|
+
const leaveList = new Array(visitors.length).fill(void 0);
|
|
4476
|
+
for (let i = 0; i < visitors.length; ++i) {
|
|
4477
|
+
const { enter, leave } = getEnterLeaveForKind(visitors[i], kind);
|
|
4478
|
+
hasVisitor || (hasVisitor = enter != null || leave != null);
|
|
4479
|
+
enterList[i] = enter;
|
|
4480
|
+
leaveList[i] = leave;
|
|
4481
|
+
}
|
|
4482
|
+
if (!hasVisitor) continue;
|
|
4483
|
+
mergedVisitor[kind] = {
|
|
4484
|
+
enter(...args) {
|
|
4485
|
+
const node = args[0];
|
|
4486
|
+
for (let i = 0; i < visitors.length; i++) if (skipping[i] === null) {
|
|
4487
|
+
var _enterList$i;
|
|
4488
|
+
const result = (_enterList$i = enterList[i]) === null || _enterList$i === void 0 ? void 0 : _enterList$i.apply(visitors[i], args);
|
|
4489
|
+
if (result === false) skipping[i] = node;
|
|
4490
|
+
else if (result === BREAK) skipping[i] = BREAK;
|
|
4491
|
+
else if (result !== void 0) return result;
|
|
4492
|
+
}
|
|
4493
|
+
},
|
|
4494
|
+
leave(...args) {
|
|
4495
|
+
const node = args[0];
|
|
4496
|
+
for (let i = 0; i < visitors.length; i++) if (skipping[i] === null) {
|
|
4497
|
+
var _leaveList$i;
|
|
4498
|
+
const result = (_leaveList$i = leaveList[i]) === null || _leaveList$i === void 0 ? void 0 : _leaveList$i.apply(visitors[i], args);
|
|
4499
|
+
if (result === BREAK) skipping[i] = BREAK;
|
|
4500
|
+
else if (result !== void 0 && result !== false) return result;
|
|
4501
|
+
} else if (skipping[i] === node) skipping[i] = null;
|
|
4502
|
+
}
|
|
4503
|
+
};
|
|
4504
|
+
}
|
|
4505
|
+
return mergedVisitor;
|
|
4506
|
+
}
|
|
4507
|
+
/**
|
|
4508
|
+
* Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind.
|
|
4509
|
+
* @param visitor - The visitor object to inspect.
|
|
4510
|
+
* @param kind - The AST node kind to resolve handlers for.
|
|
4511
|
+
* @returns The enter and leave handlers that apply for the given node kind.
|
|
4512
|
+
* @example
|
|
4513
|
+
* ```ts
|
|
4514
|
+
* import { Kind, getEnterLeaveForKind } from 'graphql/language';
|
|
4515
|
+
*
|
|
4516
|
+
* const handlers = getEnterLeaveForKind({ Field: () => {} }, Kind.FIELD);
|
|
4517
|
+
*
|
|
4518
|
+
* typeof handlers.enter; // => 'function'
|
|
4519
|
+
* handlers.leave; // => undefined
|
|
4520
|
+
* ```
|
|
4521
|
+
*/
|
|
4522
|
+
function getEnterLeaveForKind(visitor, kind) {
|
|
4523
|
+
const kindVisitor = visitor[kind];
|
|
4524
|
+
if (typeof kindVisitor === "object") return kindVisitor;
|
|
4525
|
+
else if (typeof kindVisitor === "function") return {
|
|
4526
|
+
enter: kindVisitor,
|
|
4527
|
+
leave: void 0
|
|
4528
|
+
};
|
|
4529
|
+
return {
|
|
4530
|
+
enter: visitor.enter,
|
|
4531
|
+
leave: visitor.leave
|
|
4532
|
+
};
|
|
4533
|
+
}
|
|
4534
|
+
/**
|
|
4535
|
+
* Given a visitor instance, if it is leaving or not, and a node kind, return
|
|
4536
|
+
* the function the visitor runtime should call. This deprecated compatibility
|
|
4537
|
+
* helper delegates to `getEnterLeaveForKind`; call `getEnterLeaveForKind`
|
|
4538
|
+
* directly because getVisitFn will be removed in v17.
|
|
4539
|
+
* @param visitor - The visitor object to inspect.
|
|
4540
|
+
* @param kind - The AST node kind to resolve a handler for.
|
|
4541
|
+
* @param isLeaving - Whether to resolve the leave handler instead of the enter handler.
|
|
4542
|
+
* @returns The visit function that applies for the given node kind and traversal phase, if one exists.
|
|
4543
|
+
* @example
|
|
4544
|
+
* ```ts
|
|
4545
|
+
* import { Kind, getVisitFn } from 'graphql/language';
|
|
4546
|
+
*
|
|
4547
|
+
* const enter = getVisitFn({ Field: () => {} }, Kind.FIELD, false);
|
|
4548
|
+
* const leave = getVisitFn({ Field: () => {} }, Kind.FIELD, true);
|
|
4549
|
+
*
|
|
4550
|
+
* typeof enter; // => 'function'
|
|
4551
|
+
* leave; // => undefined
|
|
4552
|
+
* ```
|
|
4553
|
+
* @category Visiting
|
|
4554
|
+
* @deprecated Please use `getEnterLeaveForKind` instead. Will be removed in v17
|
|
4555
|
+
*/
|
|
4556
|
+
/* c8 ignore next 8 */
|
|
4557
|
+
function getVisitFn(visitor, kind, isLeaving) {
|
|
4558
|
+
const { enter, leave } = getEnterLeaveForKind(visitor, kind);
|
|
4559
|
+
return isLeaving ? leave : enter;
|
|
4560
|
+
}
|
|
4561
|
+
}));
|
|
4562
|
+
//#endregion
|
|
4563
|
+
//#region node_modules/.pnpm/graphql@16.14.2/node_modules/graphql/language/printer.js
|
|
4564
|
+
var require_printer = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4565
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4566
|
+
exports.print = print;
|
|
4567
|
+
var _blockString = require_blockString();
|
|
4568
|
+
var _printString = require_printString();
|
|
4569
|
+
var _visitor = require_visitor();
|
|
4570
|
+
/** @category Printing */
|
|
4571
|
+
/**
|
|
4572
|
+
* Converts an AST into a string, using one set of reasonable
|
|
4573
|
+
* formatting rules.
|
|
4574
|
+
* @param ast - The GraphQL AST node to print.
|
|
4575
|
+
* @returns A stable string representation of the AST.
|
|
4576
|
+
* @example
|
|
4577
|
+
* ```ts
|
|
4578
|
+
* import { parse, print } from 'graphql';
|
|
4579
|
+
*
|
|
4580
|
+
* const ast = parse('{ hero { name } }');
|
|
4581
|
+
* const text = print(ast);
|
|
4582
|
+
*
|
|
4583
|
+
* text; // => '{\n hero {\n name\n }\n}'
|
|
4584
|
+
* ```
|
|
4585
|
+
*/
|
|
4586
|
+
function print(ast) {
|
|
4587
|
+
return (0, _visitor.visit)(ast, printDocASTReducer);
|
|
4588
|
+
}
|
|
4589
|
+
const MAX_LINE_LENGTH = 80;
|
|
4590
|
+
const printDocASTReducer = {
|
|
4591
|
+
Name: { leave: (node) => node.value },
|
|
4592
|
+
Variable: { leave: (node) => "$" + node.name },
|
|
4593
|
+
Document: { leave: (node) => join(node.definitions, "\n\n") },
|
|
4594
|
+
OperationDefinition: { leave(node) {
|
|
4595
|
+
const varDefs = hasMultilineItems(node.variableDefinitions) ? wrap("(\n", join(node.variableDefinitions, "\n"), "\n)") : wrap("(", join(node.variableDefinitions, ", "), ")");
|
|
4596
|
+
const prefix = wrap("", node.description, "\n") + join([
|
|
4597
|
+
node.operation,
|
|
4598
|
+
join([node.name, varDefs]),
|
|
4599
|
+
join(node.directives, " ")
|
|
4600
|
+
], " ");
|
|
4601
|
+
return (prefix === "query" ? "" : prefix + " ") + node.selectionSet;
|
|
4602
|
+
} },
|
|
4603
|
+
VariableDefinition: { leave: ({ variable, type, defaultValue, directives, description }) => wrap("", description, "\n") + variable + ": " + type + wrap(" = ", defaultValue) + wrap(" ", join(directives, " ")) },
|
|
4604
|
+
SelectionSet: { leave: ({ selections }) => block(selections) },
|
|
4605
|
+
Field: { leave({ alias, name, arguments: args, directives, selectionSet }) {
|
|
4606
|
+
const prefix = wrap("", alias, ": ") + name;
|
|
4607
|
+
let argsLine = prefix + wrap("(", join(args, ", "), ")");
|
|
4608
|
+
if (argsLine.length > MAX_LINE_LENGTH) argsLine = prefix + wrap("(\n", indent(join(args, "\n")), "\n)");
|
|
4609
|
+
return join([
|
|
4610
|
+
argsLine,
|
|
4611
|
+
join(directives, " "),
|
|
4612
|
+
selectionSet
|
|
4613
|
+
], " ");
|
|
4614
|
+
} },
|
|
4615
|
+
Argument: { leave: ({ name, value }) => name + ": " + value },
|
|
4616
|
+
FragmentSpread: { leave: ({ name, directives }) => "..." + name + wrap(" ", join(directives, " ")) },
|
|
4617
|
+
InlineFragment: { leave: ({ typeCondition, directives, selectionSet }) => join([
|
|
4618
|
+
"...",
|
|
4619
|
+
wrap("on ", typeCondition),
|
|
4620
|
+
join(directives, " "),
|
|
4621
|
+
selectionSet
|
|
4622
|
+
], " ") },
|
|
4623
|
+
FragmentDefinition: { leave: ({ name, typeCondition, variableDefinitions, directives, selectionSet, description }) => wrap("", description, "\n") + `fragment ${name}${wrap("(", join(variableDefinitions, ", "), ")")} on ${typeCondition} ${wrap("", join(directives, " "), " ")}` + selectionSet },
|
|
4624
|
+
IntValue: { leave: ({ value }) => value },
|
|
4625
|
+
FloatValue: { leave: ({ value }) => value },
|
|
4626
|
+
StringValue: { leave: ({ value, block: isBlockString }) => isBlockString ? (0, _blockString.printBlockString)(value) : (0, _printString.printString)(value) },
|
|
4627
|
+
BooleanValue: { leave: ({ value }) => value ? "true" : "false" },
|
|
4628
|
+
NullValue: { leave: () => "null" },
|
|
4629
|
+
EnumValue: { leave: ({ value }) => value },
|
|
4630
|
+
ListValue: { leave: ({ values }) => "[" + join(values, ", ") + "]" },
|
|
4631
|
+
ObjectValue: { leave: ({ fields }) => "{" + join(fields, ", ") + "}" },
|
|
4632
|
+
ObjectField: { leave: ({ name, value }) => name + ": " + value },
|
|
4633
|
+
Directive: { leave: ({ name, arguments: args }) => "@" + name + wrap("(", join(args, ", "), ")") },
|
|
4634
|
+
NamedType: { leave: ({ name }) => name },
|
|
4635
|
+
ListType: { leave: ({ type }) => "[" + type + "]" },
|
|
4636
|
+
NonNullType: { leave: ({ type }) => type + "!" },
|
|
4637
|
+
SchemaDefinition: { leave: ({ description, directives, operationTypes }) => wrap("", description, "\n") + join([
|
|
4638
|
+
"schema",
|
|
4639
|
+
join(directives, " "),
|
|
4640
|
+
block(operationTypes)
|
|
4641
|
+
], " ") },
|
|
4642
|
+
OperationTypeDefinition: { leave: ({ operation, type }) => operation + ": " + type },
|
|
4643
|
+
ScalarTypeDefinition: { leave: ({ description, name, directives }) => wrap("", description, "\n") + join([
|
|
4644
|
+
"scalar",
|
|
4645
|
+
name,
|
|
4646
|
+
join(directives, " ")
|
|
4647
|
+
], " ") },
|
|
4648
|
+
ObjectTypeDefinition: { leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") + join([
|
|
4649
|
+
"type",
|
|
4650
|
+
name,
|
|
4651
|
+
wrap("implements ", join(interfaces, " & ")),
|
|
4652
|
+
join(directives, " "),
|
|
4653
|
+
block(fields)
|
|
4654
|
+
], " ") },
|
|
4655
|
+
FieldDefinition: { leave: ({ description, name, arguments: args, type, directives }) => wrap("", description, "\n") + name + (hasMultilineItems(args) ? wrap("(\n", indent(join(args, "\n")), "\n)") : wrap("(", join(args, ", "), ")")) + ": " + type + wrap(" ", join(directives, " ")) },
|
|
4656
|
+
InputValueDefinition: { leave: ({ description, name, type, defaultValue, directives }) => wrap("", description, "\n") + join([
|
|
4657
|
+
name + ": " + type,
|
|
4658
|
+
wrap("= ", defaultValue),
|
|
4659
|
+
join(directives, " ")
|
|
4660
|
+
], " ") },
|
|
4661
|
+
InterfaceTypeDefinition: { leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") + join([
|
|
4662
|
+
"interface",
|
|
4663
|
+
name,
|
|
4664
|
+
wrap("implements ", join(interfaces, " & ")),
|
|
4665
|
+
join(directives, " "),
|
|
4666
|
+
block(fields)
|
|
4667
|
+
], " ") },
|
|
4668
|
+
UnionTypeDefinition: { leave: ({ description, name, directives, types }) => wrap("", description, "\n") + join([
|
|
4669
|
+
"union",
|
|
4670
|
+
name,
|
|
4671
|
+
join(directives, " "),
|
|
4672
|
+
wrap("= ", join(types, " | "))
|
|
4673
|
+
], " ") },
|
|
4674
|
+
EnumTypeDefinition: { leave: ({ description, name, directives, values }) => wrap("", description, "\n") + join([
|
|
4675
|
+
"enum",
|
|
4676
|
+
name,
|
|
4677
|
+
join(directives, " "),
|
|
4678
|
+
block(values)
|
|
4679
|
+
], " ") },
|
|
4680
|
+
EnumValueDefinition: { leave: ({ description, name, directives }) => wrap("", description, "\n") + join([name, join(directives, " ")], " ") },
|
|
4681
|
+
InputObjectTypeDefinition: { leave: ({ description, name, directives, fields }) => wrap("", description, "\n") + join([
|
|
4682
|
+
"input",
|
|
4683
|
+
name,
|
|
4684
|
+
join(directives, " "),
|
|
4685
|
+
block(fields)
|
|
4686
|
+
], " ") },
|
|
4687
|
+
DirectiveDefinition: { leave: ({ description, name, arguments: args, directives, repeatable, locations }) => wrap("", description, "\n") + "directive @" + name + (hasMultilineItems(args) ? wrap("(\n", indent(join(args, "\n")), "\n)") : wrap("(", join(args, ", "), ")")) + wrap(" ", join(directives, " ")) + (repeatable ? " repeatable" : "") + " on " + join(locations, " | ") },
|
|
4688
|
+
SchemaExtension: { leave: ({ directives, operationTypes }) => join([
|
|
4689
|
+
"extend schema",
|
|
4690
|
+
join(directives, " "),
|
|
4691
|
+
block(operationTypes)
|
|
4692
|
+
], " ") },
|
|
4693
|
+
ScalarTypeExtension: { leave: ({ name, directives }) => join([
|
|
4694
|
+
"extend scalar",
|
|
4695
|
+
name,
|
|
4696
|
+
join(directives, " ")
|
|
4697
|
+
], " ") },
|
|
4698
|
+
ObjectTypeExtension: { leave: ({ name, interfaces, directives, fields }) => join([
|
|
4699
|
+
"extend type",
|
|
4700
|
+
name,
|
|
4701
|
+
wrap("implements ", join(interfaces, " & ")),
|
|
4702
|
+
join(directives, " "),
|
|
4703
|
+
block(fields)
|
|
4704
|
+
], " ") },
|
|
4705
|
+
InterfaceTypeExtension: { leave: ({ name, interfaces, directives, fields }) => join([
|
|
4706
|
+
"extend interface",
|
|
4707
|
+
name,
|
|
4708
|
+
wrap("implements ", join(interfaces, " & ")),
|
|
4709
|
+
join(directives, " "),
|
|
4710
|
+
block(fields)
|
|
4711
|
+
], " ") },
|
|
4712
|
+
UnionTypeExtension: { leave: ({ name, directives, types }) => join([
|
|
4713
|
+
"extend union",
|
|
4714
|
+
name,
|
|
4715
|
+
join(directives, " "),
|
|
4716
|
+
wrap("= ", join(types, " | "))
|
|
4717
|
+
], " ") },
|
|
4718
|
+
EnumTypeExtension: { leave: ({ name, directives, values }) => join([
|
|
4719
|
+
"extend enum",
|
|
4720
|
+
name,
|
|
4721
|
+
join(directives, " "),
|
|
4722
|
+
block(values)
|
|
4723
|
+
], " ") },
|
|
4724
|
+
InputObjectTypeExtension: { leave: ({ name, directives, fields }) => join([
|
|
4725
|
+
"extend input",
|
|
4726
|
+
name,
|
|
4727
|
+
join(directives, " "),
|
|
4728
|
+
block(fields)
|
|
4729
|
+
], " ") },
|
|
4730
|
+
DirectiveExtension: { leave: ({ name, directives }) => join(["extend directive @" + name, join(directives, " ")], " ") },
|
|
4731
|
+
TypeCoordinate: { leave: ({ name }) => name },
|
|
4732
|
+
MemberCoordinate: { leave: ({ name, memberName }) => join([name, wrap(".", memberName)]) },
|
|
4733
|
+
ArgumentCoordinate: { leave: ({ name, fieldName, argumentName }) => join([
|
|
4734
|
+
name,
|
|
4735
|
+
wrap(".", fieldName),
|
|
4736
|
+
wrap("(", argumentName, ":)")
|
|
4737
|
+
]) },
|
|
4738
|
+
DirectiveCoordinate: { leave: ({ name }) => join(["@", name]) },
|
|
4739
|
+
DirectiveArgumentCoordinate: { leave: ({ name, argumentName }) => join([
|
|
4740
|
+
"@",
|
|
4741
|
+
name,
|
|
4742
|
+
wrap("(", argumentName, ":)")
|
|
4743
|
+
]) }
|
|
4744
|
+
};
|
|
4745
|
+
/**
|
|
4746
|
+
* Given maybeArray, print an empty string if it is null or empty, otherwise
|
|
4747
|
+
* print all items together separated by separator if provided
|
|
4748
|
+
*
|
|
4749
|
+
* @internal
|
|
4750
|
+
*/
|
|
4751
|
+
function join(maybeArray, separator = "") {
|
|
4752
|
+
var _maybeArray$filter$jo;
|
|
4753
|
+
return (_maybeArray$filter$jo = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.filter((x) => x).join(separator)) !== null && _maybeArray$filter$jo !== void 0 ? _maybeArray$filter$jo : "";
|
|
4754
|
+
}
|
|
4755
|
+
/**
|
|
4756
|
+
* Given array, print each item on its own line, wrapped in an indented `{ }` block.
|
|
4757
|
+
*
|
|
4758
|
+
* @internal
|
|
4759
|
+
*/
|
|
4760
|
+
function block(array) {
|
|
4761
|
+
return wrap("{\n", indent(join(array, "\n")), "\n}");
|
|
4762
|
+
}
|
|
4763
|
+
/**
|
|
4764
|
+
* If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.
|
|
4765
|
+
*
|
|
4766
|
+
* @internal
|
|
4767
|
+
*/
|
|
4768
|
+
function wrap(start, maybeString, end = "") {
|
|
4769
|
+
return maybeString != null && maybeString !== "" ? start + maybeString + end : "";
|
|
4770
|
+
}
|
|
4771
|
+
function indent(str) {
|
|
4772
|
+
return wrap(" ", str.replace(/\n/g, "\n "));
|
|
4773
|
+
}
|
|
4774
|
+
function hasMultilineItems(maybeArray) {
|
|
4775
|
+
var _maybeArray$some;
|
|
4776
|
+
/* c8 ignore next */
|
|
4777
|
+
return (_maybeArray$some = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.some((str) => str.includes("\n"))) !== null && _maybeArray$some !== void 0 ? _maybeArray$some : false;
|
|
4778
|
+
}
|
|
4779
|
+
}));
|
|
4780
|
+
//#endregion
|
|
4781
|
+
//#region src/ir/order.ts
|
|
4782
|
+
var import_kinds = require_kinds();
|
|
4783
|
+
var import_parser = require_parser();
|
|
4784
|
+
var import_printer = require_printer();
|
|
4785
|
+
/**
|
|
4786
|
+
* Code-unit order, which is code-point order for the characters an `apiId`
|
|
4787
|
+
* may contain. Not `localeCompare`, whose result depends on the machine.
|
|
4788
|
+
*
|
|
4789
|
+
* Both sides of the diff sort their unordered collections with this, so the
|
|
4790
|
+
* same set of entities hashes the same wherever it was read from.
|
|
4791
|
+
*/
|
|
4792
|
+
function byApiId(a, b) {
|
|
4793
|
+
if (a.apiId === b.apiId) return 0;
|
|
4794
|
+
return a.apiId < b.apiId ? -1 : 1;
|
|
4795
|
+
}
|
|
4796
|
+
/** `byApiId` for remote sources, which are named by their prefix. */
|
|
4797
|
+
function byPrefix(a, b) {
|
|
4798
|
+
return byApiId({ apiId: a.prefix }, { apiId: b.prefix });
|
|
4799
|
+
}
|
|
4800
|
+
//#endregion
|
|
4801
|
+
//#region src/ir/sdl.ts
|
|
4802
|
+
/**
|
|
4803
|
+
* A remote source's SDL as one entry per type, sorted by name, each printed
|
|
4804
|
+
* by `graphql` so the config's and live's spelling of the same type match.
|
|
4805
|
+
* Throws when the SDL does not parse; the config's is validated first.
|
|
4806
|
+
*/
|
|
4807
|
+
function splitTypeDefinitions(sdl) {
|
|
4808
|
+
return (0, import_parser.parse)(sdl).definitions.flatMap((definition) => {
|
|
4809
|
+
const name = typeDefinitionName(definition);
|
|
4810
|
+
return name === null ? [] : [{
|
|
4811
|
+
apiId: name,
|
|
4812
|
+
sdl: (0, import_printer.print)(definition)
|
|
4813
|
+
}];
|
|
4814
|
+
}).toSorted(byApiId);
|
|
4815
|
+
}
|
|
4816
|
+
/** The name a type definition declares, `null` for anything else. */
|
|
4817
|
+
function typeDefinitionName(definition) {
|
|
4818
|
+
switch (definition.kind) {
|
|
4819
|
+
case import_kinds.Kind.OBJECT_TYPE_DEFINITION:
|
|
4820
|
+
case import_kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
4821
|
+
case import_kinds.Kind.ENUM_TYPE_DEFINITION:
|
|
4822
|
+
case import_kinds.Kind.INTERFACE_TYPE_DEFINITION:
|
|
4823
|
+
case import_kinds.Kind.SCALAR_TYPE_DEFINITION:
|
|
4824
|
+
case import_kinds.Kind.UNION_TYPE_DEFINITION: return definition.name.value;
|
|
4825
|
+
default: return null;
|
|
4826
|
+
}
|
|
4827
|
+
}
|
|
4828
|
+
//#endregion
|
|
4829
|
+
//#region src/define/resources/remoteSource.ts
|
|
4830
|
+
/** The attributes the two builders share, defaults filled in. */
|
|
4831
|
+
function remoteSourceAttributes(input) {
|
|
4832
|
+
return {
|
|
4833
|
+
prefix: input.prefix,
|
|
4834
|
+
displayName: input.displayName,
|
|
4835
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
4836
|
+
url: input.url,
|
|
4837
|
+
headers: { ...input.headers },
|
|
4838
|
+
debugEnabled: input.debugEnabled ?? false,
|
|
4839
|
+
kind: input.kind ?? "Custom",
|
|
4840
|
+
oAuth: input.oAuth === void 0 ? null : {
|
|
4841
|
+
clientId: input.oAuth.clientId,
|
|
4842
|
+
clientSecret: isEmpty(input.oAuth.clientSecret) ? null : input.oAuth.clientSecret,
|
|
4843
|
+
scopes: [...input.oAuth.scopes ?? []],
|
|
4844
|
+
authorizationUrl: input.oAuth.authorizationUrl
|
|
4845
|
+
},
|
|
4846
|
+
remoteTypeDefinitions: isEmpty(input.remoteTypeDefinitions) ? null : input.remoteTypeDefinitions
|
|
4847
|
+
};
|
|
4848
|
+
}
|
|
4849
|
+
/**
|
|
4850
|
+
* Header values become lists, as Hygraph stores them, names sort, and no
|
|
4851
|
+
* headers is `null`. The SDL becomes one entry per type. Runs on a config
|
|
4852
|
+
* that passed validation, so the SDL parses. The OAuth secret stays out:
|
|
4853
|
+
* live never returns one to compare it with.
|
|
4854
|
+
*/
|
|
4855
|
+
function convertRemoteSourceToIR(source) {
|
|
4856
|
+
const attributes = {
|
|
4857
|
+
prefix: source.prefix,
|
|
4858
|
+
displayName: source.displayName,
|
|
4859
|
+
description: source.description,
|
|
4860
|
+
url: source.url,
|
|
4861
|
+
headers: convertHeadersToIR(source.headers),
|
|
4862
|
+
debugEnabled: source.debugEnabled,
|
|
4863
|
+
kind: source.kind,
|
|
4864
|
+
oAuth: source.oAuth === null ? null : convertOAuthToIR(source.oAuth),
|
|
4865
|
+
typeDefinitions: convertTypeDefinitionsToIR(source.remoteTypeDefinitions)
|
|
4866
|
+
};
|
|
4867
|
+
if (source.__typename === "RESTRemoteSource") return {
|
|
4868
|
+
...attributes,
|
|
4869
|
+
type: "REST"
|
|
4870
|
+
};
|
|
4871
|
+
return {
|
|
4872
|
+
...attributes,
|
|
4873
|
+
type: "GRAPHQL",
|
|
4874
|
+
introspectionMethod: source.introspectionMethod,
|
|
4875
|
+
introspectionUrl: source.introspectionUrl,
|
|
4876
|
+
introspectionHeaders: convertHeadersToIR(source.introspectionHeaders)
|
|
4877
|
+
};
|
|
4878
|
+
}
|
|
4879
|
+
/** Scopes sort: Hygraph keeps no order for them. */
|
|
4880
|
+
function convertOAuthToIR(oAuth) {
|
|
4881
|
+
return {
|
|
4882
|
+
clientId: oAuth.clientId,
|
|
4883
|
+
scopes: oAuth.scopes.toSorted(),
|
|
4884
|
+
authorizationUrl: oAuth.authorizationUrl
|
|
4885
|
+
};
|
|
4886
|
+
}
|
|
4887
|
+
/** Runs on headers that passed validation, so every one has a value. */
|
|
4888
|
+
function convertHeadersToIR(headers) {
|
|
4889
|
+
const names = Object.keys(headers).toSorted();
|
|
4890
|
+
if (names.length === 0) return null;
|
|
4891
|
+
return Object.fromEntries(names.map((name) => {
|
|
4892
|
+
const value = headers[name] ?? [];
|
|
4893
|
+
return [name, typeof value === "string" ? [value] : value.filter((each) => each !== void 0)];
|
|
4894
|
+
}));
|
|
4895
|
+
}
|
|
4896
|
+
function convertTypeDefinitionsToIR(sdl) {
|
|
4897
|
+
return sdl === null ? [] : splitTypeDefinitions(sdl);
|
|
4898
|
+
}
|
|
4899
|
+
//#endregion
|
|
4900
|
+
//#region src/define/fields/remote.ts
|
|
4901
|
+
/** What `define.field.remote` fills in when the config leaves it out. */
|
|
4902
|
+
const REMOTE_DEFAULTS = {
|
|
4903
|
+
list: false,
|
|
4904
|
+
required: false,
|
|
4905
|
+
visibility: "READ_ONLY",
|
|
4906
|
+
forwardClientHeaders: false,
|
|
4907
|
+
cacheTTLSeconds: 900
|
|
4908
|
+
};
|
|
4909
|
+
/**
|
|
4910
|
+
* Data a remote source returns when the field is queried. List the source
|
|
4911
|
+
* in the environment's `remoteSources` too.
|
|
4912
|
+
*
|
|
4913
|
+
* Nothing here is validated; the checks run at plan time with the model's
|
|
4914
|
+
* own, the placeholders included.
|
|
4915
|
+
*/
|
|
4916
|
+
function remote(input) {
|
|
4917
|
+
return {
|
|
4918
|
+
__typename: "RemoteField",
|
|
4919
|
+
apiId: input.apiId,
|
|
4920
|
+
displayName: input.displayName,
|
|
4921
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
4922
|
+
source: input.source,
|
|
4923
|
+
returnType: input.returnType,
|
|
4924
|
+
method: input.method,
|
|
4925
|
+
query: isEmpty(input.query) ? null : input.query,
|
|
4926
|
+
path: isEmpty(input.path) ? null : input.path,
|
|
4927
|
+
args: (input.args ?? []).map((arg) => ({
|
|
4928
|
+
apiId: arg.apiId,
|
|
4929
|
+
type: arg.type,
|
|
4930
|
+
required: arg.required ?? false,
|
|
4931
|
+
list: arg.list ?? false
|
|
4932
|
+
})),
|
|
4933
|
+
headers: { ...input.headers },
|
|
4934
|
+
forwardClientHeaders: input.forwardClientHeaders ?? REMOTE_DEFAULTS.forwardClientHeaders,
|
|
4935
|
+
cacheTTLSeconds: input.cacheTTLSeconds ?? REMOTE_DEFAULTS.cacheTTLSeconds,
|
|
4936
|
+
list: input.list ?? REMOTE_DEFAULTS.list,
|
|
4937
|
+
required: input.required ?? REMOTE_DEFAULTS.required,
|
|
4938
|
+
visibility: input.visibility ?? REMOTE_DEFAULTS.visibility,
|
|
4939
|
+
visibilityCondition: null,
|
|
4940
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
4941
|
+
};
|
|
4942
|
+
}
|
|
4943
|
+
/**
|
|
4944
|
+
* The IR names the source by its prefix and takes its type from it.
|
|
4945
|
+
* Arguments sort by apiId: Hygraph keeps no order for them. `renamedFrom`
|
|
4946
|
+
* is intent, not schema, and stays out.
|
|
4947
|
+
*/
|
|
4948
|
+
function convertRemoteFieldToIR(field, position) {
|
|
4949
|
+
return {
|
|
4950
|
+
kind: "remote",
|
|
4951
|
+
apiId: field.apiId,
|
|
4952
|
+
displayName: field.displayName,
|
|
4953
|
+
description: field.description,
|
|
4954
|
+
position,
|
|
4955
|
+
list: field.list,
|
|
4956
|
+
required: field.required,
|
|
4957
|
+
visibility: field.visibility,
|
|
4958
|
+
visibilityCondition: null,
|
|
4959
|
+
source: field.source.prefix,
|
|
4960
|
+
type: field.source.__typename === "GraphQLRemoteSource" ? "GRAPHQL" : "REST",
|
|
4961
|
+
returnType: field.returnType,
|
|
4962
|
+
method: field.method,
|
|
4963
|
+
query: field.query,
|
|
4964
|
+
path: field.path,
|
|
4965
|
+
headers: convertHeadersToIR(field.headers),
|
|
4966
|
+
forwardClientHeaders: field.forwardClientHeaders,
|
|
4967
|
+
cacheTTLSeconds: field.cacheTTLSeconds,
|
|
4968
|
+
args: field.args.toSorted(byApiId)
|
|
4969
|
+
};
|
|
4970
|
+
}
|
|
4971
|
+
//#endregion
|
|
606
4972
|
//#region src/define/fields/richText.ts
|
|
607
4973
|
/** Every toolbar action, in the order Studio's form lists them. */
|
|
608
4974
|
const RICH_TEXT_ACTIONS = [
|
|
@@ -939,7 +5305,11 @@ function convertTypeToIR(field, position) {
|
|
|
939
5305
|
case "ComponentUnionField": return convertComponentUnionFieldToIR(field, position);
|
|
940
5306
|
case "ReferenceOneWayField": return convertReferenceOneWayFieldToIR(field, position);
|
|
941
5307
|
case "ReferenceTwoWayField": return convertReferenceTwoWayFieldToIR(field, position);
|
|
5308
|
+
case "ReferenceUnionField": return convertReferenceUnionFieldToIR(field, position);
|
|
5309
|
+
case "RemoteField": return convertRemoteFieldToIR(field, position);
|
|
5310
|
+
case "ReferenceUnionMemberField": return convertReferenceUnionMemberFieldToIR(field, position);
|
|
942
5311
|
case "AssetField": return convertAssetFieldToIR(field, position);
|
|
5312
|
+
case "AssetReverseField": return convertAssetReverseFieldToIR(field, position);
|
|
943
5313
|
case "SingleLineField":
|
|
944
5314
|
case "MultilineField":
|
|
945
5315
|
case "MarkdownField":
|
|
@@ -948,17 +5318,17 @@ function convertTypeToIR(field, position) {
|
|
|
948
5318
|
}
|
|
949
5319
|
}
|
|
950
5320
|
//#endregion
|
|
951
|
-
//#region src/
|
|
5321
|
+
//#region src/define/system/model.ts
|
|
952
5322
|
/**
|
|
953
|
-
*
|
|
954
|
-
*
|
|
955
|
-
*
|
|
956
|
-
* Both sides of the diff sort their unordered collections with this, so the
|
|
957
|
-
* same set of entities hashes the same wherever it was read from.
|
|
5323
|
+
* A model Hygraph provides, as `system.asset` or `system.query` hands it
|
|
5324
|
+
* back. Fields are keyed by apiId, and a field's index becomes its
|
|
5325
|
+
* position.
|
|
958
5326
|
*/
|
|
959
|
-
function
|
|
960
|
-
|
|
961
|
-
|
|
5327
|
+
function convertSystemModelToIR(model) {
|
|
5328
|
+
return {
|
|
5329
|
+
apiId: model.apiId,
|
|
5330
|
+
fields: Object.fromEntries(model.fields.map((field, position) => [field.apiId, convertFieldToIR(field, position)]))
|
|
5331
|
+
};
|
|
962
5332
|
}
|
|
963
5333
|
//#endregion
|
|
964
5334
|
//#region src/define/resources/component.ts
|
|
@@ -1177,6 +5547,8 @@ function flatten(node, parent) {
|
|
|
1177
5547
|
}
|
|
1178
5548
|
//#endregion
|
|
1179
5549
|
//#region src/define/resources/environment.ts
|
|
5550
|
+
/** The models Hygraph provides that a config can list. */
|
|
5551
|
+
const SYSTEM_MODELS = ["SystemAsset", "SystemQuery"];
|
|
1180
5552
|
/**
|
|
1181
5553
|
* One environment: typed arrays per resource kind. The what.
|
|
1182
5554
|
*
|
|
@@ -1190,19 +5562,26 @@ function environment(input) {
|
|
|
1190
5562
|
stages: [...input.stages],
|
|
1191
5563
|
enumerations: [...input.enumerations ?? []],
|
|
1192
5564
|
taxonomies: [...input.taxonomies ?? []],
|
|
5565
|
+
remoteSources: [...input.remoteSources ?? []],
|
|
1193
5566
|
components: [...input.components ?? []],
|
|
1194
|
-
models:
|
|
5567
|
+
models: input.models.filter((model) => !SYSTEM_MODELS.includes(model.__typename)),
|
|
5568
|
+
systemModels: input.models.filter((model) => SYSTEM_MODELS.includes(model.__typename))
|
|
1195
5569
|
};
|
|
1196
5570
|
}
|
|
1197
5571
|
/** Converts every resource it holds on the way. */
|
|
1198
5572
|
function convertEnvironmentToIR(environment) {
|
|
5573
|
+
const asset = environment.systemModels.find((model) => model.__typename === "SystemAsset");
|
|
5574
|
+
const query = environment.systemModels.find((model) => model.__typename === "SystemQuery");
|
|
1199
5575
|
return {
|
|
1200
5576
|
locales: environment.locales.map((locale) => convertLocaleToIR(locale)).toSorted(byApiId),
|
|
1201
5577
|
stages: environment.stages.map((stage, index) => convertStageToIR(stage, index)).toSorted(byApiId),
|
|
1202
5578
|
enumerations: environment.enumerations.map((enumeration) => convertEnumerationToIR(enumeration)).toSorted(byApiId),
|
|
1203
5579
|
taxonomies: environment.taxonomies.map((taxonomy) => convertTaxonomyToIR(taxonomy)).toSorted(byApiId),
|
|
5580
|
+
remoteSources: environment.remoteSources.map((source) => convertRemoteSourceToIR(source)).toSorted(byPrefix),
|
|
1204
5581
|
components: environment.components.map((component) => convertComponentToIR(component)).toSorted(byApiId),
|
|
1205
|
-
models: environment.models.map((model) => convertModelToIR(model)).toSorted(byApiId)
|
|
5582
|
+
models: environment.models.map((model) => convertModelToIR(model)).toSorted(byApiId),
|
|
5583
|
+
...asset && { asset: convertSystemModelToIR(asset) },
|
|
5584
|
+
...query && { query: convertSystemModelToIR(query) }
|
|
1206
5585
|
};
|
|
1207
5586
|
}
|
|
1208
5587
|
/**
|
|
@@ -1247,7 +5626,11 @@ function collectIntents(environment) {
|
|
|
1247
5626
|
apiId: component.apiId,
|
|
1248
5627
|
renamedFrom: component.renamedFrom
|
|
1249
5628
|
}]);
|
|
1250
|
-
const parents = [
|
|
5629
|
+
const parents = [
|
|
5630
|
+
...environment.models,
|
|
5631
|
+
...environment.systemModels,
|
|
5632
|
+
...environment.components
|
|
5633
|
+
].toSorted(byApiId);
|
|
1251
5634
|
const fieldRenames = parents.flatMap((parent) => parent.fields.toSorted(byApiId).flatMap((field) => field.__typename === "UnsupportedField" || field.renamedFrom === null ? [] : [{
|
|
1252
5635
|
parent: parent.apiId,
|
|
1253
5636
|
apiId: field.apiId,
|
|
@@ -1332,18 +5715,6 @@ function multiline(input) {
|
|
|
1332
5715
|
};
|
|
1333
5716
|
}
|
|
1334
5717
|
//#endregion
|
|
1335
|
-
//#region src/define/fields/referenceUnion.ts
|
|
1336
|
-
/** A reference to several models. On models every member declares `unionMember`. */
|
|
1337
|
-
function referenceUnion(_options) {
|
|
1338
|
-
return notImplemented("define.field.referenceUnion");
|
|
1339
|
-
}
|
|
1340
|
-
//#endregion
|
|
1341
|
-
//#region src/define/fields/remote.ts
|
|
1342
|
-
/** A field resolved from a remote source. `visibility` defaults to READ_ONLY. */
|
|
1343
|
-
function remote(_options) {
|
|
1344
|
-
return notImplemented("define.field.remote");
|
|
1345
|
-
}
|
|
1346
|
-
//#endregion
|
|
1347
5718
|
//#region src/define/fields/singleLine.ts
|
|
1348
5719
|
/**
|
|
1349
5720
|
* One line of text, such as a heading or a title. Studio's single line
|
|
@@ -1381,12 +5752,6 @@ function slug(input) {
|
|
|
1381
5752
|
};
|
|
1382
5753
|
}
|
|
1383
5754
|
//#endregion
|
|
1384
|
-
//#region src/define/fields/unionMember.ts
|
|
1385
|
-
/** The slot a union's member model declares. All members share one `apiId`. Models only. */
|
|
1386
|
-
function unionMember(_options) {
|
|
1387
|
-
return notImplemented("define.field.unionMember");
|
|
1388
|
-
}
|
|
1389
|
-
//#endregion
|
|
1390
5755
|
//#region src/define/fields/vector.ts
|
|
1391
5756
|
/** An embedding. `dimension` is required (1 to 3072); `index` is refused above 2000. */
|
|
1392
5757
|
function vector(_options) {
|
|
@@ -1396,6 +5761,7 @@ function vector(_options) {
|
|
|
1396
5761
|
//#region src/define/fields/index.ts
|
|
1397
5762
|
var fields_exports = /* @__PURE__ */ __exportAll({
|
|
1398
5763
|
asset: () => asset$1,
|
|
5764
|
+
assetReverseField: () => assetReverseField,
|
|
1399
5765
|
boolean: () => boolean,
|
|
1400
5766
|
color: () => color,
|
|
1401
5767
|
component: () => component$1,
|
|
@@ -1412,25 +5778,48 @@ var fields_exports = /* @__PURE__ */ __exportAll({
|
|
|
1412
5778
|
referenceOneWay: () => referenceOneWay,
|
|
1413
5779
|
referenceTwoWay: () => referenceTwoWay,
|
|
1414
5780
|
referenceUnion: () => referenceUnion,
|
|
5781
|
+
referenceUnionMember: () => referenceUnionMember,
|
|
1415
5782
|
remote: () => remote,
|
|
1416
5783
|
richText: () => richText,
|
|
1417
5784
|
singleLine: () => singleLine,
|
|
1418
5785
|
slug: () => slug,
|
|
1419
5786
|
string: () => string,
|
|
1420
5787
|
taxonomy: () => taxonomy$1,
|
|
1421
|
-
unionMember: () => unionMember,
|
|
1422
5788
|
unsupported: () => unsupported,
|
|
1423
5789
|
vector: () => vector
|
|
1424
5790
|
});
|
|
1425
5791
|
//#endregion
|
|
1426
5792
|
//#region src/define/resources/graphqlRemoteSource.ts
|
|
1427
|
-
|
|
1428
|
-
|
|
5793
|
+
/**
|
|
5794
|
+
* A GraphQL API remote fields can query. List it in the environment's
|
|
5795
|
+
* `remoteSources`.
|
|
5796
|
+
*
|
|
5797
|
+
* Nothing here is validated. Format rules and uniqueness are plan-time
|
|
5798
|
+
* checks, reported together with the rest of the config's.
|
|
5799
|
+
*/
|
|
5800
|
+
function graphqlRemoteSource(input) {
|
|
5801
|
+
return {
|
|
5802
|
+
__typename: "GraphQLRemoteSource",
|
|
5803
|
+
...remoteSourceAttributes(input),
|
|
5804
|
+
introspectionMethod: input.introspectionMethod,
|
|
5805
|
+
introspectionUrl: isEmpty(input.introspectionUrl) ? null : input.introspectionUrl,
|
|
5806
|
+
introspectionHeaders: { ...input.introspectionHeaders }
|
|
5807
|
+
};
|
|
1429
5808
|
}
|
|
1430
5809
|
//#endregion
|
|
1431
5810
|
//#region src/define/resources/restRemoteSource.ts
|
|
1432
|
-
|
|
1433
|
-
|
|
5811
|
+
/**
|
|
5812
|
+
* A REST API remote fields can call. List it in the environment's
|
|
5813
|
+
* `remoteSources`.
|
|
5814
|
+
*
|
|
5815
|
+
* Nothing here is validated. Format rules and uniqueness are plan-time
|
|
5816
|
+
* checks, reported together with the rest of the config's.
|
|
5817
|
+
*/
|
|
5818
|
+
function restRemoteSource(input) {
|
|
5819
|
+
return {
|
|
5820
|
+
__typename: "RESTRemoteSource",
|
|
5821
|
+
...remoteSourceAttributes(input)
|
|
5822
|
+
};
|
|
1434
5823
|
}
|
|
1435
5824
|
//#endregion
|
|
1436
5825
|
//#region src/define/resources/target.ts
|
|
@@ -1466,13 +5855,37 @@ var define_exports = /* @__PURE__ */ __exportAll({
|
|
|
1466
5855
|
});
|
|
1467
5856
|
//#endregion
|
|
1468
5857
|
//#region src/define/system/asset.ts
|
|
1469
|
-
|
|
1470
|
-
|
|
5858
|
+
/**
|
|
5859
|
+
* Hygraph's Asset model, with your fields on it. Put it in
|
|
5860
|
+
* `define.environment`'s `models` to manage those fields; leave it out and
|
|
5861
|
+
* the plan does not touch Asset at all. The plan never creates or deletes
|
|
5862
|
+
* Asset or one of Hygraph's own fields on it.
|
|
5863
|
+
*
|
|
5864
|
+
* Nothing here is validated: the checks run at plan time with the models'.
|
|
5865
|
+
*/
|
|
5866
|
+
function asset(input = {}) {
|
|
5867
|
+
return {
|
|
5868
|
+
__typename: "SystemAsset",
|
|
5869
|
+
apiId: "Asset",
|
|
5870
|
+
fields: [...input.fields ?? []]
|
|
5871
|
+
};
|
|
1471
5872
|
}
|
|
1472
5873
|
//#endregion
|
|
1473
5874
|
//#region src/define/system/query.ts
|
|
1474
|
-
|
|
1475
|
-
|
|
5875
|
+
/**
|
|
5876
|
+
* Hygraph's Query model, which Studio shows as Query, with your remote
|
|
5877
|
+
* fields on it. Put it in `define.environment`'s `models` to manage those
|
|
5878
|
+
* fields; leave it out and the plan does not touch Query at all. The plan
|
|
5879
|
+
* never creates or deletes Query.
|
|
5880
|
+
*
|
|
5881
|
+
* Nothing here is validated: the checks run at plan time with the models'.
|
|
5882
|
+
*/
|
|
5883
|
+
function query(input = {}) {
|
|
5884
|
+
return {
|
|
5885
|
+
__typename: "SystemQuery",
|
|
5886
|
+
apiId: "QueryModel",
|
|
5887
|
+
fields: [...input.fields ?? []]
|
|
5888
|
+
};
|
|
1476
5889
|
}
|
|
1477
5890
|
//#endregion
|
|
1478
5891
|
//#region src/define/system/segment.ts
|
|
@@ -1506,4 +5919,4 @@ var system_exports = /* @__PURE__ */ __exportAll({
|
|
|
1506
5919
|
stage: () => stage
|
|
1507
5920
|
});
|
|
1508
5921
|
//#endregion
|
|
1509
|
-
export { SLUG_DEFAULTS as a, environment as c,
|
|
5922
|
+
export { assetReverseApiId as C, require_kinds as S, typeDefinitionName as _, SLUG_DEFAULTS as a, require_parser as b, environment as c, isEmptyRichText as d, richTextActions as f, splitTypeDefinitions as g, convertOAuthToIR as h, target as i, FIELD_DEFAULTS as l, convertHeadersToIR as m, stage as n, collectIntents as o, REMOTE_DEFAULTS as p, define_exports as r, convertEnvironmentToIR as s, system_exports as t, RICH_TEXT_ACTIONS as u, byApiId as v, isEmpty as w, require_GraphQLError as x, byPrefix as y };
|