houdini 1.2.43 → 1.2.44
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/build/cmd-cjs/index.js +174 -83
- package/build/cmd-esm/index.js +174 -83
- package/build/codegen/generators/artifacts/inputs.d.ts +1 -1
- package/build/codegen/transforms/index.d.ts +1 -0
- package/build/codegen/transforms/runtimeScalars.d.ts +2 -0
- package/build/codegen-cjs/index.js +167 -79
- package/build/codegen-esm/index.js +167 -79
- package/build/lib/config.d.ts +1 -0
- package/build/lib-cjs/index.js +44 -13
- package/build/lib-esm/index.js +44 -13
- package/build/runtime/lib/config.d.ts +12 -2
- package/build/runtime/lib/types.d.ts +4 -0
- package/build/runtime/router/session.d.ts +1 -2
- package/build/runtime-cjs/client/plugins/query.js +14 -0
- package/build/runtime-cjs/lib/config.d.ts +12 -2
- package/build/runtime-cjs/lib/types.d.ts +4 -0
- package/build/runtime-cjs/router/server.js +2 -3
- package/build/runtime-cjs/router/session.d.ts +1 -2
- package/build/runtime-cjs/router/session.js +25 -11
- package/build/runtime-esm/client/plugins/query.js +14 -0
- package/build/runtime-esm/lib/config.d.ts +12 -2
- package/build/runtime-esm/lib/types.d.ts +4 -0
- package/build/runtime-esm/router/server.js +2 -3
- package/build/runtime-esm/router/session.d.ts +1 -2
- package/build/runtime-esm/router/session.js +25 -11
- package/build/test-cjs/index.js +179 -82
- package/build/test-esm/index.js +179 -82
- package/build/vite-cjs/index.js +171 -80
- package/build/vite-esm/index.js +171 -80
- package/package.json +1 -1
package/build/test-cjs/index.js
CHANGED
|
@@ -24845,7 +24845,7 @@ var require_path_visitor = __commonJS({
|
|
|
24845
24845
|
}
|
|
24846
24846
|
return target;
|
|
24847
24847
|
}
|
|
24848
|
-
PathVisitor.visit = function
|
|
24848
|
+
PathVisitor.visit = function visit19(node, methods) {
|
|
24849
24849
|
return PathVisitor.fromMethodsObject(methods).visit(node);
|
|
24850
24850
|
};
|
|
24851
24851
|
var PVp = PathVisitor.prototype;
|
|
@@ -25036,7 +25036,7 @@ var require_path_visitor = __commonJS({
|
|
|
25036
25036
|
this.needToCallTraverse = false;
|
|
25037
25037
|
return visitChildren(path2, PathVisitor.fromMethodsObject(newVisitor || this.visitor));
|
|
25038
25038
|
};
|
|
25039
|
-
sharedContextProtoMethods.visit = function
|
|
25039
|
+
sharedContextProtoMethods.visit = function visit19(path2, newVisitor) {
|
|
25040
25040
|
if (!(this instanceof this.Context)) {
|
|
25041
25041
|
throw new Error("");
|
|
25042
25042
|
}
|
|
@@ -26429,7 +26429,7 @@ var require_main = __commonJS({
|
|
|
26429
26429
|
var someField = _a.someField;
|
|
26430
26430
|
var Type = _a.Type;
|
|
26431
26431
|
var use = _a.use;
|
|
26432
|
-
var
|
|
26432
|
+
var visit19 = _a.visit;
|
|
26433
26433
|
exports.astNodesAreEquivalent = astNodesAreEquivalent;
|
|
26434
26434
|
exports.builders = builders;
|
|
26435
26435
|
exports.builtInTypes = builtInTypes;
|
|
@@ -26446,7 +26446,7 @@ var require_main = __commonJS({
|
|
|
26446
26446
|
exports.someField = someField;
|
|
26447
26447
|
exports.Type = Type;
|
|
26448
26448
|
exports.use = use;
|
|
26449
|
-
exports.visit =
|
|
26449
|
+
exports.visit = visit19;
|
|
26450
26450
|
Object.assign(namedTypes_1.namedTypes, n);
|
|
26451
26451
|
}
|
|
26452
26452
|
});
|
|
@@ -53827,11 +53827,11 @@ __export(test_exports, {
|
|
|
53827
53827
|
testConfigFile: () => testConfigFile
|
|
53828
53828
|
});
|
|
53829
53829
|
module.exports = __toCommonJS(test_exports);
|
|
53830
|
-
var
|
|
53830
|
+
var graphql34 = __toESM(require("graphql"), 1);
|
|
53831
53831
|
var import_memfs2 = __toESM(require_lib(), 1);
|
|
53832
53832
|
|
|
53833
53833
|
// src/codegen/index.ts
|
|
53834
|
-
var
|
|
53834
|
+
var graphql33 = __toESM(require("graphql"), 1);
|
|
53835
53835
|
|
|
53836
53836
|
// src/lib/pipeline.ts
|
|
53837
53837
|
async function runPipeline(config, pipeline, target) {
|
|
@@ -56706,8 +56706,22 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
56706
56706
|
let lastVariables = null;
|
|
56707
56707
|
return {
|
|
56708
56708
|
start(ctx, { next }) {
|
|
56709
|
+
const runtimeScalarPayload = {
|
|
56710
|
+
session: ctx.session
|
|
56711
|
+
};
|
|
56709
56712
|
ctx.variables = {
|
|
56710
56713
|
...lastVariables,
|
|
56714
|
+
...Object.fromEntries(
|
|
56715
|
+
Object.entries(ctx.artifact.input?.runtimeScalars ?? {}).map(
|
|
56716
|
+
([field, type]) => {
|
|
56717
|
+
const runtimeScalar = ctx.config.features?.runtimeScalars?.[type];
|
|
56718
|
+
if (!runtimeScalar) {
|
|
56719
|
+
return [field, type];
|
|
56720
|
+
}
|
|
56721
|
+
return [field, runtimeScalar.resolve(runtimeScalarPayload)];
|
|
56722
|
+
}
|
|
56723
|
+
)
|
|
56724
|
+
),
|
|
56711
56725
|
...ctx.variables
|
|
56712
56726
|
};
|
|
56713
56727
|
next(ctx);
|
|
@@ -57288,6 +57302,9 @@ var Config = class {
|
|
|
57288
57302
|
get loadingDirective() {
|
|
57289
57303
|
return `loading`;
|
|
57290
57304
|
}
|
|
57305
|
+
get runtimeScalarDirective() {
|
|
57306
|
+
return "__houdini__runtimeScalar";
|
|
57307
|
+
}
|
|
57291
57308
|
get whenDirective() {
|
|
57292
57309
|
return "when";
|
|
57293
57310
|
}
|
|
@@ -57358,7 +57375,7 @@ var Config = class {
|
|
|
57358
57375
|
const internalDirectives = this.#newSchemaInstance?.getDirectives().reduce((list, directive) => {
|
|
57359
57376
|
return list.concat(directive.name);
|
|
57360
57377
|
}, []) ?? [];
|
|
57361
|
-
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
|
|
57378
|
+
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name) || name === this.runtimeScalarDirective);
|
|
57362
57379
|
}
|
|
57363
57380
|
get componentFieldDirective() {
|
|
57364
57381
|
return "componentField";
|
|
@@ -57641,7 +57658,7 @@ function unwrapType(config, type, wrappers = []) {
|
|
|
57641
57658
|
}
|
|
57642
57659
|
const namedType = config.schema.getType(type.name.value || type.name);
|
|
57643
57660
|
if (!namedType) {
|
|
57644
|
-
throw new Error("
|
|
57661
|
+
throw new Error("Unknown type: " + type.name.value || type.name);
|
|
57645
57662
|
}
|
|
57646
57663
|
return { type: namedType, wrappers };
|
|
57647
57664
|
}
|
|
@@ -58754,7 +58771,7 @@ ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
|
58754
58771
|
|
|
58755
58772
|
// src/codegen/generators/artifacts/inputs.ts
|
|
58756
58773
|
var graphql8 = __toESM(require("graphql"), 1);
|
|
58757
|
-
function inputObject(config, inputs) {
|
|
58774
|
+
function inputObject(config, inputs, runtimeScalars) {
|
|
58758
58775
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
58759
58776
|
const inputObj = {
|
|
58760
58777
|
fields: inputs.reduce((fields, input) => {
|
|
@@ -58770,7 +58787,8 @@ function inputObject(config, inputs) {
|
|
|
58770
58787
|
...fields,
|
|
58771
58788
|
[input.variable.name.value]: input.defaultValue ? variableValue(input.defaultValue, {}) : void 0
|
|
58772
58789
|
};
|
|
58773
|
-
}, {})
|
|
58790
|
+
}, {}),
|
|
58791
|
+
runtimeScalars
|
|
58774
58792
|
};
|
|
58775
58793
|
for (const input of inputs) {
|
|
58776
58794
|
walkInputs(config, visitedTypes, inputObj, input.type);
|
|
@@ -60613,7 +60631,21 @@ function artifactGenerator(stats) {
|
|
|
60613
60631
|
artifact.pluginData[plugin2.name] = plugin2.artifactData({ config, document: doc }) ?? {};
|
|
60614
60632
|
}
|
|
60615
60633
|
if (inputs && inputs.length > 0) {
|
|
60616
|
-
|
|
60634
|
+
const runtimeScalars = inputs.reduce((prev, input) => {
|
|
60635
|
+
const runtimeScalarDirective = input.directives?.find(
|
|
60636
|
+
(directive2) => directive2.name.value === config.runtimeScalarDirective
|
|
60637
|
+
);
|
|
60638
|
+
if (!runtimeScalarDirective) {
|
|
60639
|
+
return prev;
|
|
60640
|
+
}
|
|
60641
|
+
return {
|
|
60642
|
+
...prev,
|
|
60643
|
+
[input.variable.name.value]: runtimeScalarDirective.arguments?.find(
|
|
60644
|
+
(arg) => arg.name.value === "type"
|
|
60645
|
+
)?.value?.value
|
|
60646
|
+
};
|
|
60647
|
+
}, {});
|
|
60648
|
+
artifact.input = inputObject(config, inputs, runtimeScalars);
|
|
60617
60649
|
}
|
|
60618
60650
|
if (artifact.kind === "HoudiniQuery") {
|
|
60619
60651
|
const cacheDirective = operations[0].directives?.find(
|
|
@@ -61705,17 +61737,20 @@ export * from "${module2}"
|
|
|
61705
61737
|
}
|
|
61706
61738
|
}
|
|
61707
61739
|
await fs_exports.writeFile(config.typeIndexPath, indexContent);
|
|
61708
|
-
|
|
61709
|
-
|
|
61710
|
-
|
|
61711
|
-
|
|
61740
|
+
const missingScalarNames = [...missingScalars].filter(
|
|
61741
|
+
(scalar) => !config.configFile.features?.runtimeScalars?.[scalar]
|
|
61742
|
+
);
|
|
61743
|
+
if (missingScalarNames.length > 0) {
|
|
61744
|
+
console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[
|
|
61745
|
+
...missingScalarNames
|
|
61746
|
+
].join(", ")}
|
|
61712
61747
|
Generated types will contain an any type in place of these values. To fix this, provide an equivalent
|
|
61713
61748
|
type in your config file:
|
|
61714
61749
|
|
|
61715
61750
|
{
|
|
61716
61751
|
scalars: {
|
|
61717
61752
|
${cyan2(`/* in your case, something like */`)}
|
|
61718
|
-
${[...
|
|
61753
|
+
${[...missingScalarNames].map(
|
|
61719
61754
|
(c) => ` ${c}: { ${green2(`// <- The GraphQL Scalar`)}
|
|
61720
61755
|
type: "${cyan2(`YourType_${c}`)}" ${green2(`// <- The TypeScript type`)}
|
|
61721
61756
|
}`
|
|
@@ -64297,7 +64332,7 @@ ${config.configFile.features?.componentFields ? `
|
|
|
64297
64332
|
"""
|
|
64298
64333
|
@${config.componentFieldDirective} marks an inline fragment as the selection for a component field
|
|
64299
64334
|
"""
|
|
64300
|
-
directive @${config.componentFieldDirective}(field: String!, prop: String, export: String, raw: String) on FRAGMENT_DEFINITION | INLINE_FRAGMENT
|
|
64335
|
+
directive @${config.componentFieldDirective}(field: String!, prop: String, export: String, raw: String) on FRAGMENT_DEFINITION | INLINE_FRAGMENT | FIELD_DEFINITION
|
|
64301
64336
|
|
|
64302
64337
|
` : ""}
|
|
64303
64338
|
|
|
@@ -64308,7 +64343,7 @@ directive @${config.componentFieldDirective}(field: String!, prop: String, expor
|
|
|
64308
64343
|
}
|
|
64309
64344
|
internalSchema += plugin2.schema({ config });
|
|
64310
64345
|
}
|
|
64311
|
-
|
|
64346
|
+
let extensions = Object.entries(config.componentFields).map(([parent2, fields]) => {
|
|
64312
64347
|
return `
|
|
64313
64348
|
extend type ${parent2} {
|
|
64314
64349
|
${Object.entries(fields).map(([fieldName, field]) => {
|
|
@@ -64320,11 +64355,12 @@ directive @${config.componentFieldDirective}(field: String!, prop: String, expor
|
|
|
64320
64355
|
return `${arg.name}:${typeName}${arg.required ? "!" : ""}`;
|
|
64321
64356
|
}).join("\n") + ")";
|
|
64322
64357
|
}
|
|
64323
|
-
return `${fieldName}${argString}: ${config.componentScalar}
|
|
64358
|
+
return `${fieldName}${argString}: ${config.componentScalar}! @componentField(field: "${fieldName}")`;
|
|
64324
64359
|
}).join("\n")}
|
|
64325
64360
|
}
|
|
64326
64361
|
`;
|
|
64327
64362
|
}).join("\n");
|
|
64363
|
+
extensions += `${Object.keys(config.configFile.features?.runtimeScalars ?? {}).map((scalar) => `scalar ${scalar}`).join("\n")}`;
|
|
64328
64364
|
config.newSchema = graphql25.print(mergeTypeDefs([internalSchema, config.newSchema]));
|
|
64329
64365
|
config.schemaString += extensions;
|
|
64330
64366
|
config.schema = graphql25.buildSchema(
|
|
@@ -64519,8 +64555,50 @@ async function componentFields(config, documents) {
|
|
|
64519
64555
|
}
|
|
64520
64556
|
}
|
|
64521
64557
|
|
|
64522
|
-
// src/codegen/
|
|
64558
|
+
// src/codegen/transforms/runtimeScalars.ts
|
|
64523
64559
|
var graphql29 = __toESM(require("graphql"), 1);
|
|
64560
|
+
async function addTypename2(config, documents) {
|
|
64561
|
+
for (const doc of documents) {
|
|
64562
|
+
doc.document = graphql29.visit(doc.document, {
|
|
64563
|
+
VariableDefinition(node) {
|
|
64564
|
+
const { type, wrappers } = unwrapType(config, node.type);
|
|
64565
|
+
const runtimeScalar = config.configFile.features?.runtimeScalars?.[type.name];
|
|
64566
|
+
if (runtimeScalar) {
|
|
64567
|
+
return {
|
|
64568
|
+
...node,
|
|
64569
|
+
type: wrapType({
|
|
64570
|
+
type: config.schema.getType(runtimeScalar.type),
|
|
64571
|
+
wrappers
|
|
64572
|
+
}),
|
|
64573
|
+
directives: [
|
|
64574
|
+
...node.directives ?? [],
|
|
64575
|
+
{
|
|
64576
|
+
kind: "Directive",
|
|
64577
|
+
name: {
|
|
64578
|
+
kind: "Name",
|
|
64579
|
+
value: config.runtimeScalarDirective
|
|
64580
|
+
},
|
|
64581
|
+
arguments: [
|
|
64582
|
+
{
|
|
64583
|
+
kind: "Argument",
|
|
64584
|
+
name: { kind: "Name", value: "type" },
|
|
64585
|
+
value: {
|
|
64586
|
+
kind: "StringValue",
|
|
64587
|
+
value: type.name
|
|
64588
|
+
}
|
|
64589
|
+
}
|
|
64590
|
+
]
|
|
64591
|
+
}
|
|
64592
|
+
]
|
|
64593
|
+
};
|
|
64594
|
+
}
|
|
64595
|
+
}
|
|
64596
|
+
});
|
|
64597
|
+
}
|
|
64598
|
+
}
|
|
64599
|
+
|
|
64600
|
+
// src/codegen/validators/typeCheck.ts
|
|
64601
|
+
var graphql30 = __toESM(require("graphql"), 1);
|
|
64524
64602
|
async function typeCheck(config, docs) {
|
|
64525
64603
|
const errors = [];
|
|
64526
64604
|
const freeLists = [];
|
|
@@ -64528,7 +64606,7 @@ async function typeCheck(config, docs) {
|
|
|
64528
64606
|
const listTypes = [];
|
|
64529
64607
|
const fragments = {};
|
|
64530
64608
|
for (const { document: parsed, originalString, filename } of docs) {
|
|
64531
|
-
|
|
64609
|
+
graphql30.visit(parsed, {
|
|
64532
64610
|
FragmentDefinition(definition) {
|
|
64533
64611
|
fragments[definition.name.value] = definition;
|
|
64534
64612
|
},
|
|
@@ -64573,14 +64651,14 @@ async function typeCheck(config, docs) {
|
|
|
64573
64651
|
);
|
|
64574
64652
|
return;
|
|
64575
64653
|
}
|
|
64576
|
-
if (
|
|
64654
|
+
if (graphql30.isListType(rootType) || graphql30.isNonNullType(rootType) && graphql30.isListType(rootType.ofType)) {
|
|
64577
64655
|
needsParent = true;
|
|
64578
64656
|
break;
|
|
64579
64657
|
}
|
|
64580
|
-
if (
|
|
64658
|
+
if (graphql30.isNonNullType(rootType) && "ofType" in rootType) {
|
|
64581
64659
|
rootType = rootType.ofType;
|
|
64582
64660
|
}
|
|
64583
|
-
if (
|
|
64661
|
+
if (graphql30.isScalarType(rootType)) {
|
|
64584
64662
|
break;
|
|
64585
64663
|
}
|
|
64586
64664
|
rootType = rootType?.getFields()[parent3.name.value]?.type;
|
|
@@ -64656,9 +64734,9 @@ async function typeCheck(config, docs) {
|
|
|
64656
64734
|
);
|
|
64657
64735
|
}
|
|
64658
64736
|
let targetTypes = [type];
|
|
64659
|
-
if (
|
|
64737
|
+
if (graphql30.isUnionType(type)) {
|
|
64660
64738
|
targetTypes = config.schema.getPossibleTypes(type);
|
|
64661
|
-
} else if (
|
|
64739
|
+
} else if (graphql30.isInterfaceType(type)) {
|
|
64662
64740
|
try {
|
|
64663
64741
|
for (const key of config.keyFieldsForType(type.name)) {
|
|
64664
64742
|
if (!type.getFields()[key]) {
|
|
@@ -64694,13 +64772,13 @@ async function typeCheck(config, docs) {
|
|
|
64694
64772
|
if (errors.length > 0) {
|
|
64695
64773
|
throw errors;
|
|
64696
64774
|
}
|
|
64697
|
-
const rules = (filepath) => [...
|
|
64775
|
+
const rules = (filepath) => [...graphql30.specifiedRules].filter(
|
|
64698
64776
|
(rule) => ![
|
|
64699
|
-
|
|
64700
|
-
|
|
64701
|
-
|
|
64702
|
-
|
|
64703
|
-
|
|
64777
|
+
graphql30.NoUnusedFragmentsRule,
|
|
64778
|
+
graphql30.KnownFragmentNamesRule,
|
|
64779
|
+
graphql30.ExecutableDefinitionsRule,
|
|
64780
|
+
graphql30.KnownDirectivesRule,
|
|
64781
|
+
graphql30.KnownArgumentNamesRule
|
|
64704
64782
|
].includes(rule)
|
|
64705
64783
|
).concat(
|
|
64706
64784
|
validateLists({
|
|
@@ -64721,7 +64799,7 @@ async function typeCheck(config, docs) {
|
|
|
64721
64799
|
validateLoadingDirective(config)
|
|
64722
64800
|
);
|
|
64723
64801
|
for (const { filename, document: parsed, originalString } of docs) {
|
|
64724
|
-
for (const error of
|
|
64802
|
+
for (const error of graphql30.validate(config.schema, parsed, rules(filename))) {
|
|
64725
64803
|
errors.push(
|
|
64726
64804
|
new HoudiniError({
|
|
64727
64805
|
filepath: filename,
|
|
@@ -64750,20 +64828,20 @@ function validateRequiredDirective(config, filepath) {
|
|
|
64750
64828
|
if (!node.directives?.some(({ name }) => name.value === config.requiredDirective))
|
|
64751
64829
|
return;
|
|
64752
64830
|
const parentType = parentTypeFromAncestors(config.schema, filepath, ancestors);
|
|
64753
|
-
if (!
|
|
64831
|
+
if (!graphql30.isObjectType(parentType)) {
|
|
64754
64832
|
ctx.reportError(
|
|
64755
|
-
new
|
|
64833
|
+
new graphql30.GraphQLError(
|
|
64756
64834
|
`@${config.requiredDirective} may only be used on objects, not arguments`
|
|
64757
64835
|
)
|
|
64758
64836
|
);
|
|
64759
64837
|
return;
|
|
64760
64838
|
}
|
|
64761
64839
|
const type = parentType.getFields()[node.name.value].type;
|
|
64762
|
-
const isServerNullable = !
|
|
64840
|
+
const isServerNullable = !graphql30.isNonNullType(type);
|
|
64763
64841
|
const isAlreadyClientNullable = isClientNullable(node, true);
|
|
64764
64842
|
if (!isServerNullable && !isAlreadyClientNullable) {
|
|
64765
64843
|
ctx.reportError(
|
|
64766
|
-
new
|
|
64844
|
+
new graphql30.GraphQLError(
|
|
64767
64845
|
`@${config.requiredDirective} may only be used on nullable fields`
|
|
64768
64846
|
)
|
|
64769
64847
|
);
|
|
@@ -64785,7 +64863,7 @@ var validateLists = ({
|
|
|
64785
64863
|
if (!config.isListFragment(node.name.value)) {
|
|
64786
64864
|
if (!fragments[node.name.value]) {
|
|
64787
64865
|
ctx.reportError(
|
|
64788
|
-
new
|
|
64866
|
+
new graphql30.GraphQLError(
|
|
64789
64867
|
"Encountered unknown fragment: " + node.name.value
|
|
64790
64868
|
)
|
|
64791
64869
|
);
|
|
@@ -64795,7 +64873,7 @@ var validateLists = ({
|
|
|
64795
64873
|
const listName = config.listNameFromFragment(node.name.value);
|
|
64796
64874
|
if (!lists.includes(listName)) {
|
|
64797
64875
|
ctx.reportError(
|
|
64798
|
-
new
|
|
64876
|
+
new graphql30.GraphQLError(
|
|
64799
64877
|
"Encountered fragment referencing unknown list: " + listName
|
|
64800
64878
|
)
|
|
64801
64879
|
);
|
|
@@ -64820,7 +64898,7 @@ var validateLists = ({
|
|
|
64820
64898
|
);
|
|
64821
64899
|
if (parentArg) {
|
|
64822
64900
|
ctx.reportError(
|
|
64823
|
-
new
|
|
64901
|
+
new graphql30.GraphQLError(
|
|
64824
64902
|
`@${config.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
|
|
64825
64903
|
)
|
|
64826
64904
|
);
|
|
@@ -64836,7 +64914,7 @@ var validateLists = ({
|
|
|
64836
64914
|
return;
|
|
64837
64915
|
}
|
|
64838
64916
|
ctx.reportError(
|
|
64839
|
-
new
|
|
64917
|
+
new graphql30.GraphQLError(
|
|
64840
64918
|
`For this list fragment, you need to add or @${config.listParentDirective} or @${config.listAllListsDirective} directive to specify the behavior`
|
|
64841
64919
|
)
|
|
64842
64920
|
);
|
|
@@ -64846,7 +64924,7 @@ var validateLists = ({
|
|
|
64846
64924
|
const directiveName = node.name.value;
|
|
64847
64925
|
if (directiveName === "connection") {
|
|
64848
64926
|
ctx.reportError(
|
|
64849
|
-
new
|
|
64927
|
+
new graphql30.GraphQLError(
|
|
64850
64928
|
"@connection was renamed to @list. Please change your components. If you were using `cache.connection` in your components, you will need to update that to `cache.list` too."
|
|
64851
64929
|
)
|
|
64852
64930
|
);
|
|
@@ -64855,7 +64933,7 @@ var validateLists = ({
|
|
|
64855
64933
|
if (!config.isInternalDirective(node.name.value)) {
|
|
64856
64934
|
if (!config.schema.getDirective(directiveName)) {
|
|
64857
64935
|
ctx.reportError(
|
|
64858
|
-
new
|
|
64936
|
+
new graphql30.GraphQLError(
|
|
64859
64937
|
"Encountered unknown directive: " + directiveName
|
|
64860
64938
|
)
|
|
64861
64939
|
);
|
|
@@ -64864,7 +64942,7 @@ var validateLists = ({
|
|
|
64864
64942
|
}
|
|
64865
64943
|
if (config.isListOperationDirective(directiveName) && !listTypes.includes(config.listNameFromDirective(directiveName))) {
|
|
64866
64944
|
ctx.reportError(
|
|
64867
|
-
new
|
|
64945
|
+
new graphql30.GraphQLError(
|
|
64868
64946
|
"Encountered directive referencing unknown list: " + directiveName
|
|
64869
64947
|
)
|
|
64870
64948
|
);
|
|
@@ -64875,7 +64953,7 @@ var validateLists = ({
|
|
|
64875
64953
|
};
|
|
64876
64954
|
function knownArguments(config) {
|
|
64877
64955
|
return function(ctx) {
|
|
64878
|
-
const nativeValidator =
|
|
64956
|
+
const nativeValidator = graphql30.KnownArgumentNamesRule(ctx);
|
|
64879
64957
|
return {
|
|
64880
64958
|
...nativeValidator,
|
|
64881
64959
|
Directive(directiveNode) {
|
|
@@ -64910,7 +64988,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64910
64988
|
for (const arg of node.arguments || []) {
|
|
64911
64989
|
if (arg.value.kind !== "ObjectValue") {
|
|
64912
64990
|
ctx.reportError(
|
|
64913
|
-
new
|
|
64991
|
+
new graphql30.GraphQLError("values in @arguments must be an object")
|
|
64914
64992
|
);
|
|
64915
64993
|
return;
|
|
64916
64994
|
}
|
|
@@ -64920,13 +64998,13 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64920
64998
|
);
|
|
64921
64999
|
if (!typeArg) {
|
|
64922
65000
|
ctx.reportError(
|
|
64923
|
-
new
|
|
65001
|
+
new graphql30.GraphQLError("missing type field for @arguments directive")
|
|
64924
65002
|
);
|
|
64925
65003
|
return;
|
|
64926
65004
|
}
|
|
64927
|
-
if (typeArg.value.kind !==
|
|
65005
|
+
if (typeArg.value.kind !== graphql30.Kind.STRING) {
|
|
64928
65006
|
ctx.reportError(
|
|
64929
|
-
new
|
|
65007
|
+
new graphql30.GraphQLError("type field to @arguments must be a string")
|
|
64930
65008
|
);
|
|
64931
65009
|
return;
|
|
64932
65010
|
}
|
|
@@ -64939,7 +65017,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64939
65017
|
);
|
|
64940
65018
|
if (typeArg.value.value !== defaultValueType) {
|
|
64941
65019
|
ctx.reportError(
|
|
64942
|
-
new
|
|
65020
|
+
new graphql30.GraphQLError(
|
|
64943
65021
|
`Invalid default value provided for ${arg.name.value}. Expected ${typeArg.value.value}, found ${defaultValueType}`
|
|
64944
65022
|
)
|
|
64945
65023
|
);
|
|
@@ -64957,7 +65035,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64957
65035
|
try {
|
|
64958
65036
|
args = fragmentArguments(config, filepath, fragments[fragmentName]);
|
|
64959
65037
|
} catch (e) {
|
|
64960
|
-
ctx.reportError(new
|
|
65038
|
+
ctx.reportError(new graphql30.GraphQLError(e.message));
|
|
64961
65039
|
return;
|
|
64962
65040
|
}
|
|
64963
65041
|
fragmentArguments2[fragmentName] = args;
|
|
@@ -64980,7 +65058,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64980
65058
|
);
|
|
64981
65059
|
if (missing.length > 0) {
|
|
64982
65060
|
ctx.reportError(
|
|
64983
|
-
new
|
|
65061
|
+
new graphql30.GraphQLError(
|
|
64984
65062
|
`The following arguments are missing from the "${fragmentName}" fragment: ` + JSON.stringify(missing)
|
|
64985
65063
|
)
|
|
64986
65064
|
);
|
|
@@ -64991,7 +65069,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64991
65069
|
);
|
|
64992
65070
|
if (unknown.length > 0) {
|
|
64993
65071
|
ctx.reportError(
|
|
64994
|
-
new
|
|
65072
|
+
new graphql30.GraphQLError(
|
|
64995
65073
|
"Encountered unknown arguments: " + JSON.stringify(unknown)
|
|
64996
65074
|
)
|
|
64997
65075
|
);
|
|
@@ -65003,7 +65081,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
65003
65081
|
for (const [applied, target] of zipped) {
|
|
65004
65082
|
if (!valueIsType(config, applied.value, target)) {
|
|
65005
65083
|
ctx.reportError(
|
|
65006
|
-
new
|
|
65084
|
+
new graphql30.GraphQLError(
|
|
65007
65085
|
`Invalid argument type. Expected ${target}, found ${applied.value.kind}`
|
|
65008
65086
|
)
|
|
65009
65087
|
);
|
|
@@ -65045,7 +65123,7 @@ function valueIsType(config, value, targetType) {
|
|
|
65045
65123
|
}
|
|
65046
65124
|
if (value.kind === "EnumValue" && targetType.kind === "NamedType") {
|
|
65047
65125
|
const enumType = config.schema.getType(targetType.name.value);
|
|
65048
|
-
if (!
|
|
65126
|
+
if (!graphql30.isEnumType(enumType)) {
|
|
65049
65127
|
return false;
|
|
65050
65128
|
}
|
|
65051
65129
|
return enumType.getValues().some((enumValue) => enumValue.value === value.value);
|
|
@@ -65065,7 +65143,7 @@ function paginateArgs(config, filepath) {
|
|
|
65065
65143
|
}
|
|
65066
65144
|
if (alreadyPaginated) {
|
|
65067
65145
|
ctx.reportError(
|
|
65068
|
-
new
|
|
65146
|
+
new graphql30.GraphQLError(
|
|
65069
65147
|
`@${config.paginateDirective} can only appear in a document once.`
|
|
65070
65148
|
)
|
|
65071
65149
|
);
|
|
@@ -65097,7 +65175,7 @@ function paginateArgs(config, filepath) {
|
|
|
65097
65175
|
const backwards = appliedArgs.has("last");
|
|
65098
65176
|
if (!forward && !backwards) {
|
|
65099
65177
|
ctx.reportError(
|
|
65100
|
-
new
|
|
65178
|
+
new graphql30.GraphQLError(
|
|
65101
65179
|
"A field with cursor-based pagination must have a first or last argument"
|
|
65102
65180
|
)
|
|
65103
65181
|
);
|
|
@@ -65111,7 +65189,7 @@ function paginateArgs(config, filepath) {
|
|
|
65111
65189
|
}
|
|
65112
65190
|
if (forward && backwards && paginateMode === "Infinite") {
|
|
65113
65191
|
ctx.reportError(
|
|
65114
|
-
new
|
|
65192
|
+
new graphql30.GraphQLError(
|
|
65115
65193
|
`A field with cursor pagination cannot go forwards an backwards simultaneously`
|
|
65116
65194
|
)
|
|
65117
65195
|
);
|
|
@@ -65125,7 +65203,7 @@ function paginateArgs(config, filepath) {
|
|
|
65125
65203
|
);
|
|
65126
65204
|
if (!appliedLimitArg) {
|
|
65127
65205
|
ctx.reportError(
|
|
65128
|
-
new
|
|
65206
|
+
new graphql30.GraphQLError(
|
|
65129
65207
|
"A field with offset-based pagination must have a limit argument"
|
|
65130
65208
|
)
|
|
65131
65209
|
);
|
|
@@ -65141,20 +65219,20 @@ function noUnusedFragmentArguments(config) {
|
|
|
65141
65219
|
const args = /* @__PURE__ */ new Set();
|
|
65142
65220
|
return {
|
|
65143
65221
|
enter(node) {
|
|
65144
|
-
if (node.kind ===
|
|
65222
|
+
if (node.kind === graphql30.Kind.FRAGMENT_DEFINITION) {
|
|
65145
65223
|
const definitionArguments = node.directives?.filter((directive) => directive.name.value === config.argumentsDirective).flatMap((directive) => directive.arguments);
|
|
65146
65224
|
for (const arg of definitionArguments?.map((arg2) => arg2?.name.value) || []) {
|
|
65147
65225
|
args.add(arg);
|
|
65148
65226
|
}
|
|
65149
|
-
} else if (node.kind ===
|
|
65227
|
+
} else if (node.kind === graphql30.Kind.VARIABLE) {
|
|
65150
65228
|
args.delete(node.name.value);
|
|
65151
65229
|
}
|
|
65152
65230
|
},
|
|
65153
65231
|
leave(node) {
|
|
65154
|
-
if (node.kind ===
|
|
65232
|
+
if (node.kind === graphql30.Kind.FRAGMENT_DEFINITION) {
|
|
65155
65233
|
if (args.size > 0) {
|
|
65156
65234
|
ctx.reportError(
|
|
65157
|
-
new
|
|
65235
|
+
new graphql30.GraphQLError(
|
|
65158
65236
|
"Encountered unused fragment arguments: " + [...args].join(",")
|
|
65159
65237
|
)
|
|
65160
65238
|
);
|
|
@@ -65190,7 +65268,7 @@ function nodeDirectives(config, directives) {
|
|
|
65190
65268
|
if (definition.kind === "OperationDefinition") {
|
|
65191
65269
|
if (definition.operation !== "query") {
|
|
65192
65270
|
ctx.reportError(
|
|
65193
|
-
new
|
|
65271
|
+
new graphql30.GraphQLError(
|
|
65194
65272
|
`@${node.name.value} must fall on a fragment or query document`
|
|
65195
65273
|
)
|
|
65196
65274
|
);
|
|
@@ -65202,7 +65280,7 @@ function nodeDirectives(config, directives) {
|
|
|
65202
65280
|
}
|
|
65203
65281
|
if (!possibleNodes.includes(definitionType)) {
|
|
65204
65282
|
ctx.reportError(
|
|
65205
|
-
new
|
|
65283
|
+
new graphql30.GraphQLError(paginateOnNonNodeMessage(node.name.value))
|
|
65206
65284
|
);
|
|
65207
65285
|
}
|
|
65208
65286
|
}
|
|
@@ -65221,7 +65299,7 @@ function checkMutationOperation(config) {
|
|
|
65221
65299
|
);
|
|
65222
65300
|
if (append && prepend) {
|
|
65223
65301
|
ctx.reportError(
|
|
65224
|
-
new
|
|
65302
|
+
new graphql30.GraphQLError(
|
|
65225
65303
|
`You can't apply both @${config.listPrependDirective} and @${config.listAppendDirective} at the same time`
|
|
65226
65304
|
)
|
|
65227
65305
|
);
|
|
@@ -65235,7 +65313,7 @@ function checkMutationOperation(config) {
|
|
|
65235
65313
|
);
|
|
65236
65314
|
if (parentId && allLists) {
|
|
65237
65315
|
ctx.reportError(
|
|
65238
|
-
new
|
|
65316
|
+
new graphql30.GraphQLError(
|
|
65239
65317
|
`You can't apply both @${config.listParentDirective} and @${config.listAllListsDirective} at the same time`
|
|
65240
65318
|
)
|
|
65241
65319
|
);
|
|
@@ -65257,7 +65335,7 @@ function checkMaskDirectives(config) {
|
|
|
65257
65335
|
);
|
|
65258
65336
|
if (maskEnableDirective && maskDisableDirective) {
|
|
65259
65337
|
ctx.reportError(
|
|
65260
|
-
new
|
|
65338
|
+
new graphql30.GraphQLError(
|
|
65261
65339
|
`You can't apply both @${config.maskEnableDirective} and @${config.maskDisableDirective} at the same time`
|
|
65262
65340
|
)
|
|
65263
65341
|
);
|
|
@@ -65299,7 +65377,7 @@ function validateLoadingDirective(config) {
|
|
|
65299
65377
|
);
|
|
65300
65378
|
if (!parentLoading && !global2) {
|
|
65301
65379
|
ctx.reportError(
|
|
65302
|
-
new
|
|
65380
|
+
new graphql30.GraphQLError(
|
|
65303
65381
|
`@${config.loadingDirective} can only be applied on a field or fragment spread at the root of a document or on one whose parent also has @${config.loadingDirective}`
|
|
65304
65382
|
)
|
|
65305
65383
|
);
|
|
@@ -65321,7 +65399,7 @@ function validateLoadingDirective(config) {
|
|
|
65321
65399
|
);
|
|
65322
65400
|
if (!parentLoading && !global2) {
|
|
65323
65401
|
ctx.reportError(
|
|
65324
|
-
new
|
|
65402
|
+
new graphql30.GraphQLError(
|
|
65325
65403
|
`@${config.loadingDirective} can only be applied on a field or fragment spread at the root of a document or on one whose parent also has @${config.loadingDirective}`
|
|
65326
65404
|
)
|
|
65327
65405
|
);
|
|
@@ -65336,7 +65414,7 @@ function getAndVerifyNodeInterface(config) {
|
|
|
65336
65414
|
if (!nodeInterface) {
|
|
65337
65415
|
return null;
|
|
65338
65416
|
}
|
|
65339
|
-
if (!
|
|
65417
|
+
if (!graphql30.isInterfaceType(nodeInterface)) {
|
|
65340
65418
|
displayInvalidNodeFieldMessage(config);
|
|
65341
65419
|
return null;
|
|
65342
65420
|
}
|
|
@@ -65431,11 +65509,11 @@ async function uniqueDocumentNames(config, docs) {
|
|
|
65431
65509
|
}
|
|
65432
65510
|
|
|
65433
65511
|
// src/codegen/validators/noIDAlias.ts
|
|
65434
|
-
var
|
|
65512
|
+
var graphql31 = __toESM(require("graphql"), 1);
|
|
65435
65513
|
async function noIDAlias(config, docs) {
|
|
65436
65514
|
const errors = [];
|
|
65437
65515
|
for (const { filename, document } of docs) {
|
|
65438
|
-
|
|
65516
|
+
graphql31.visit(document, {
|
|
65439
65517
|
Field(node, _, __, ___, ancestors) {
|
|
65440
65518
|
const fieldType = parentTypeFromAncestors(config.schema, filename, ancestors).name;
|
|
65441
65519
|
if (config.keyFieldsForType(fieldType).includes(node.alias?.value || "")) {
|
|
@@ -65474,11 +65552,11 @@ async function validatePlugins(config, documents) {
|
|
|
65474
65552
|
}
|
|
65475
65553
|
|
|
65476
65554
|
// src/codegen/validators/componentFields.ts
|
|
65477
|
-
var
|
|
65555
|
+
var graphql32 = __toESM(require("graphql"), 1);
|
|
65478
65556
|
async function componentFields2(config, docs) {
|
|
65479
65557
|
const errors = [];
|
|
65480
65558
|
for (const { filename: filepath, document } of docs) {
|
|
65481
|
-
|
|
65559
|
+
graphql32.visit(document, {
|
|
65482
65560
|
FragmentDefinition(node, _, __, ___, ancestors) {
|
|
65483
65561
|
const componentFieldDirective = node.directives?.find(
|
|
65484
65562
|
(dir) => dir.name.value === config.componentFieldDirective
|
|
@@ -65520,14 +65598,26 @@ async function componentFields2(config, docs) {
|
|
|
65520
65598
|
}
|
|
65521
65599
|
const fieldValue = fieldArg.value?.kind === "StringValue" ? fieldArg.value.value : void 0;
|
|
65522
65600
|
const propValue = propArg.value?.kind === "StringValue" ? propArg.value.value : void 0;
|
|
65601
|
+
const existingField = fieldValue && config.componentFields[parent2]?.[fieldValue];
|
|
65523
65602
|
const parentType = config.schema.getType(parent2);
|
|
65524
|
-
|
|
65603
|
+
let conflict = false;
|
|
65604
|
+
if (existingField && existingField.filepath !== filepath) {
|
|
65605
|
+
conflict = true;
|
|
65606
|
+
} else if (parentType && fieldValue) {
|
|
65607
|
+
const fieldDef = graphql32.isObjectType(parentType) && parentType.getFields()[fieldValue];
|
|
65608
|
+
if (fieldDef && !fieldDef.astNode?.directives?.find(
|
|
65609
|
+
(dir) => dir.name.value === config.componentFieldDirective
|
|
65610
|
+
)) {
|
|
65611
|
+
conflict = true;
|
|
65612
|
+
}
|
|
65613
|
+
}
|
|
65614
|
+
if (conflict) {
|
|
65525
65615
|
errors.push({
|
|
65526
|
-
message: `Duplicate component field definition for ${parent2}.${fieldValue}
|
|
65616
|
+
message: `Duplicate component field definition for ${parent2}.${fieldValue}.` + (existingField ? "The conflicting component field was defined in " + existingField.filepath : ""),
|
|
65527
65617
|
filepath
|
|
65528
65618
|
});
|
|
65529
65619
|
}
|
|
65530
|
-
if (parentType &&
|
|
65620
|
+
if (parentType && graphql32.isAbstractType(parentType)) {
|
|
65531
65621
|
errors.push({
|
|
65532
65622
|
message: `Cannot add component field ${parent2}.${fieldValue} because ${parent2} is an abstract type`,
|
|
65533
65623
|
filepath
|
|
@@ -65589,6 +65679,7 @@ async function runPipeline2(config, docs) {
|
|
|
65589
65679
|
[
|
|
65590
65680
|
componentFields2,
|
|
65591
65681
|
graphqlExtensions,
|
|
65682
|
+
addTypename2,
|
|
65592
65683
|
...wrapHook(beforeValidate),
|
|
65593
65684
|
typeCheck,
|
|
65594
65685
|
uniqueDocumentNames,
|
|
@@ -65990,9 +66081,15 @@ function testConfigFile({ plugins, ...config } = {}) {
|
|
|
65990
66081
|
...plugins
|
|
65991
66082
|
},
|
|
65992
66083
|
features: {
|
|
65993
|
-
componentFields: true
|
|
66084
|
+
componentFields: true,
|
|
66085
|
+
imperativeCache: true,
|
|
66086
|
+
runtimeScalars: {
|
|
66087
|
+
ViewerIDFromSession: {
|
|
66088
|
+
type: "ID",
|
|
66089
|
+
resolve: ({ session }) => session.token
|
|
66090
|
+
}
|
|
66091
|
+
}
|
|
65994
66092
|
},
|
|
65995
|
-
acceptImperativeInstability: true,
|
|
65996
66093
|
...config
|
|
65997
66094
|
};
|
|
65998
66095
|
}
|
|
@@ -66010,7 +66107,7 @@ function pipelineTest(config, documents, shouldPass, testBody) {
|
|
|
66010
66107
|
await runPipeline2(config, docs);
|
|
66011
66108
|
} catch (e) {
|
|
66012
66109
|
if (shouldPass) {
|
|
66013
|
-
throw "pipeline failed when it should have passed. " + e;
|
|
66110
|
+
throw new Error("pipeline failed when it should have passed. " + e);
|
|
66014
66111
|
}
|
|
66015
66112
|
error = e;
|
|
66016
66113
|
}
|
|
@@ -66023,7 +66120,7 @@ function pipelineTest(config, documents, shouldPass, testBody) {
|
|
|
66023
66120
|
};
|
|
66024
66121
|
}
|
|
66025
66122
|
function mockCollectedDoc(query2, data) {
|
|
66026
|
-
const parsed =
|
|
66123
|
+
const parsed = graphql34.parse(query2);
|
|
66027
66124
|
const name = parsed.definitions[0].name.value;
|
|
66028
66125
|
const operations = parsed.definitions;
|
|
66029
66126
|
let kind = ArtifactKind.Fragment;
|