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
|
@@ -24851,7 +24851,7 @@ var require_path_visitor = __commonJS({
|
|
|
24851
24851
|
}
|
|
24852
24852
|
return target;
|
|
24853
24853
|
}
|
|
24854
|
-
PathVisitor.visit = function
|
|
24854
|
+
PathVisitor.visit = function visit19(node, methods) {
|
|
24855
24855
|
return PathVisitor.fromMethodsObject(methods).visit(node);
|
|
24856
24856
|
};
|
|
24857
24857
|
var PVp = PathVisitor.prototype;
|
|
@@ -25042,7 +25042,7 @@ var require_path_visitor = __commonJS({
|
|
|
25042
25042
|
this.needToCallTraverse = false;
|
|
25043
25043
|
return visitChildren(path2, PathVisitor.fromMethodsObject(newVisitor || this.visitor));
|
|
25044
25044
|
};
|
|
25045
|
-
sharedContextProtoMethods.visit = function
|
|
25045
|
+
sharedContextProtoMethods.visit = function visit19(path2, newVisitor) {
|
|
25046
25046
|
if (!(this instanceof this.Context)) {
|
|
25047
25047
|
throw new Error("");
|
|
25048
25048
|
}
|
|
@@ -26435,7 +26435,7 @@ var require_main = __commonJS({
|
|
|
26435
26435
|
var someField = _a.someField;
|
|
26436
26436
|
var Type = _a.Type;
|
|
26437
26437
|
var use = _a.use;
|
|
26438
|
-
var
|
|
26438
|
+
var visit19 = _a.visit;
|
|
26439
26439
|
exports.astNodesAreEquivalent = astNodesAreEquivalent;
|
|
26440
26440
|
exports.builders = builders;
|
|
26441
26441
|
exports.builtInTypes = builtInTypes;
|
|
@@ -26452,7 +26452,7 @@ var require_main = __commonJS({
|
|
|
26452
26452
|
exports.someField = someField;
|
|
26453
26453
|
exports.Type = Type;
|
|
26454
26454
|
exports.use = use;
|
|
26455
|
-
exports.visit =
|
|
26455
|
+
exports.visit = visit19;
|
|
26456
26456
|
Object.assign(namedTypes_1.namedTypes, n);
|
|
26457
26457
|
}
|
|
26458
26458
|
});
|
|
@@ -53824,7 +53824,7 @@ var require_lib6 = __commonJS({
|
|
|
53824
53824
|
});
|
|
53825
53825
|
|
|
53826
53826
|
// src/codegen/index.ts
|
|
53827
|
-
import * as
|
|
53827
|
+
import * as graphql33 from "graphql";
|
|
53828
53828
|
|
|
53829
53829
|
// src/lib/pipeline.ts
|
|
53830
53830
|
async function runPipeline(config, pipeline, target) {
|
|
@@ -56696,8 +56696,22 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
56696
56696
|
let lastVariables = null;
|
|
56697
56697
|
return {
|
|
56698
56698
|
start(ctx, { next }) {
|
|
56699
|
+
const runtimeScalarPayload = {
|
|
56700
|
+
session: ctx.session
|
|
56701
|
+
};
|
|
56699
56702
|
ctx.variables = {
|
|
56700
56703
|
...lastVariables,
|
|
56704
|
+
...Object.fromEntries(
|
|
56705
|
+
Object.entries(ctx.artifact.input?.runtimeScalars ?? {}).map(
|
|
56706
|
+
([field, type]) => {
|
|
56707
|
+
const runtimeScalar = ctx.config.features?.runtimeScalars?.[type];
|
|
56708
|
+
if (!runtimeScalar) {
|
|
56709
|
+
return [field, type];
|
|
56710
|
+
}
|
|
56711
|
+
return [field, runtimeScalar.resolve(runtimeScalarPayload)];
|
|
56712
|
+
}
|
|
56713
|
+
)
|
|
56714
|
+
),
|
|
56701
56715
|
...ctx.variables
|
|
56702
56716
|
};
|
|
56703
56717
|
next(ctx);
|
|
@@ -56976,7 +56990,7 @@ function unwrapType(config, type, wrappers = []) {
|
|
|
56976
56990
|
}
|
|
56977
56991
|
const namedType = config.schema.getType(type.name.value || type.name);
|
|
56978
56992
|
if (!namedType) {
|
|
56979
|
-
throw new Error("
|
|
56993
|
+
throw new Error("Unknown type: " + type.name.value || type.name);
|
|
56980
56994
|
}
|
|
56981
56995
|
return { type: namedType, wrappers };
|
|
56982
56996
|
}
|
|
@@ -58399,7 +58413,7 @@ ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
|
58399
58413
|
|
|
58400
58414
|
// src/codegen/generators/artifacts/inputs.ts
|
|
58401
58415
|
import * as graphql8 from "graphql";
|
|
58402
|
-
function inputObject(config, inputs) {
|
|
58416
|
+
function inputObject(config, inputs, runtimeScalars) {
|
|
58403
58417
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
58404
58418
|
const inputObj = {
|
|
58405
58419
|
fields: inputs.reduce((fields, input) => {
|
|
@@ -58415,7 +58429,8 @@ function inputObject(config, inputs) {
|
|
|
58415
58429
|
...fields,
|
|
58416
58430
|
[input.variable.name.value]: input.defaultValue ? variableValue(input.defaultValue, {}) : void 0
|
|
58417
58431
|
};
|
|
58418
|
-
}, {})
|
|
58432
|
+
}, {}),
|
|
58433
|
+
runtimeScalars
|
|
58419
58434
|
};
|
|
58420
58435
|
for (const input of inputs) {
|
|
58421
58436
|
walkInputs(config, visitedTypes, inputObj, input.type);
|
|
@@ -60258,7 +60273,21 @@ function artifactGenerator(stats) {
|
|
|
60258
60273
|
artifact.pluginData[plugin2.name] = plugin2.artifactData({ config, document: doc }) ?? {};
|
|
60259
60274
|
}
|
|
60260
60275
|
if (inputs && inputs.length > 0) {
|
|
60261
|
-
|
|
60276
|
+
const runtimeScalars = inputs.reduce((prev, input) => {
|
|
60277
|
+
const runtimeScalarDirective = input.directives?.find(
|
|
60278
|
+
(directive2) => directive2.name.value === config.runtimeScalarDirective
|
|
60279
|
+
);
|
|
60280
|
+
if (!runtimeScalarDirective) {
|
|
60281
|
+
return prev;
|
|
60282
|
+
}
|
|
60283
|
+
return {
|
|
60284
|
+
...prev,
|
|
60285
|
+
[input.variable.name.value]: runtimeScalarDirective.arguments?.find(
|
|
60286
|
+
(arg) => arg.name.value === "type"
|
|
60287
|
+
)?.value?.value
|
|
60288
|
+
};
|
|
60289
|
+
}, {});
|
|
60290
|
+
artifact.input = inputObject(config, inputs, runtimeScalars);
|
|
60262
60291
|
}
|
|
60263
60292
|
if (artifact.kind === "HoudiniQuery") {
|
|
60264
60293
|
const cacheDirective = operations[0].directives?.find(
|
|
@@ -61350,17 +61379,20 @@ export * from "${module}"
|
|
|
61350
61379
|
}
|
|
61351
61380
|
}
|
|
61352
61381
|
await fs_exports.writeFile(config.typeIndexPath, indexContent);
|
|
61353
|
-
|
|
61354
|
-
|
|
61355
|
-
|
|
61356
|
-
|
|
61382
|
+
const missingScalarNames = [...missingScalars].filter(
|
|
61383
|
+
(scalar) => !config.configFile.features?.runtimeScalars?.[scalar]
|
|
61384
|
+
);
|
|
61385
|
+
if (missingScalarNames.length > 0) {
|
|
61386
|
+
console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[
|
|
61387
|
+
...missingScalarNames
|
|
61388
|
+
].join(", ")}
|
|
61357
61389
|
Generated types will contain an any type in place of these values. To fix this, provide an equivalent
|
|
61358
61390
|
type in your config file:
|
|
61359
61391
|
|
|
61360
61392
|
{
|
|
61361
61393
|
scalars: {
|
|
61362
61394
|
${cyan2(`/* in your case, something like */`)}
|
|
61363
|
-
${[...
|
|
61395
|
+
${[...missingScalarNames].map(
|
|
61364
61396
|
(c) => ` ${c}: { ${green2(`// <- The GraphQL Scalar`)}
|
|
61365
61397
|
type: "${cyan2(`YourType_${c}`)}" ${green2(`// <- The TypeScript type`)}
|
|
61366
61398
|
}`
|
|
@@ -63942,7 +63974,7 @@ ${config.configFile.features?.componentFields ? `
|
|
|
63942
63974
|
"""
|
|
63943
63975
|
@${config.componentFieldDirective} marks an inline fragment as the selection for a component field
|
|
63944
63976
|
"""
|
|
63945
|
-
directive @${config.componentFieldDirective}(field: String!, prop: String, export: String, raw: String) on FRAGMENT_DEFINITION | INLINE_FRAGMENT
|
|
63977
|
+
directive @${config.componentFieldDirective}(field: String!, prop: String, export: String, raw: String) on FRAGMENT_DEFINITION | INLINE_FRAGMENT | FIELD_DEFINITION
|
|
63946
63978
|
|
|
63947
63979
|
` : ""}
|
|
63948
63980
|
|
|
@@ -63953,7 +63985,7 @@ directive @${config.componentFieldDirective}(field: String!, prop: String, expor
|
|
|
63953
63985
|
}
|
|
63954
63986
|
internalSchema += plugin2.schema({ config });
|
|
63955
63987
|
}
|
|
63956
|
-
|
|
63988
|
+
let extensions = Object.entries(config.componentFields).map(([parent2, fields]) => {
|
|
63957
63989
|
return `
|
|
63958
63990
|
extend type ${parent2} {
|
|
63959
63991
|
${Object.entries(fields).map(([fieldName, field]) => {
|
|
@@ -63965,11 +63997,12 @@ directive @${config.componentFieldDirective}(field: String!, prop: String, expor
|
|
|
63965
63997
|
return `${arg.name}:${typeName}${arg.required ? "!" : ""}`;
|
|
63966
63998
|
}).join("\n") + ")";
|
|
63967
63999
|
}
|
|
63968
|
-
return `${fieldName}${argString}: ${config.componentScalar}
|
|
64000
|
+
return `${fieldName}${argString}: ${config.componentScalar}! @componentField(field: "${fieldName}")`;
|
|
63969
64001
|
}).join("\n")}
|
|
63970
64002
|
}
|
|
63971
64003
|
`;
|
|
63972
64004
|
}).join("\n");
|
|
64005
|
+
extensions += `${Object.keys(config.configFile.features?.runtimeScalars ?? {}).map((scalar) => `scalar ${scalar}`).join("\n")}`;
|
|
63973
64006
|
config.newSchema = graphql25.print(mergeTypeDefs([internalSchema, config.newSchema]));
|
|
63974
64007
|
config.schemaString += extensions;
|
|
63975
64008
|
config.schema = graphql25.buildSchema(
|
|
@@ -64164,8 +64197,50 @@ async function componentFields(config, documents) {
|
|
|
64164
64197
|
}
|
|
64165
64198
|
}
|
|
64166
64199
|
|
|
64167
|
-
// src/codegen/
|
|
64200
|
+
// src/codegen/transforms/runtimeScalars.ts
|
|
64168
64201
|
import * as graphql29 from "graphql";
|
|
64202
|
+
async function addTypename2(config, documents) {
|
|
64203
|
+
for (const doc of documents) {
|
|
64204
|
+
doc.document = graphql29.visit(doc.document, {
|
|
64205
|
+
VariableDefinition(node) {
|
|
64206
|
+
const { type, wrappers } = unwrapType(config, node.type);
|
|
64207
|
+
const runtimeScalar = config.configFile.features?.runtimeScalars?.[type.name];
|
|
64208
|
+
if (runtimeScalar) {
|
|
64209
|
+
return {
|
|
64210
|
+
...node,
|
|
64211
|
+
type: wrapType({
|
|
64212
|
+
type: config.schema.getType(runtimeScalar.type),
|
|
64213
|
+
wrappers
|
|
64214
|
+
}),
|
|
64215
|
+
directives: [
|
|
64216
|
+
...node.directives ?? [],
|
|
64217
|
+
{
|
|
64218
|
+
kind: "Directive",
|
|
64219
|
+
name: {
|
|
64220
|
+
kind: "Name",
|
|
64221
|
+
value: config.runtimeScalarDirective
|
|
64222
|
+
},
|
|
64223
|
+
arguments: [
|
|
64224
|
+
{
|
|
64225
|
+
kind: "Argument",
|
|
64226
|
+
name: { kind: "Name", value: "type" },
|
|
64227
|
+
value: {
|
|
64228
|
+
kind: "StringValue",
|
|
64229
|
+
value: type.name
|
|
64230
|
+
}
|
|
64231
|
+
}
|
|
64232
|
+
]
|
|
64233
|
+
}
|
|
64234
|
+
]
|
|
64235
|
+
};
|
|
64236
|
+
}
|
|
64237
|
+
}
|
|
64238
|
+
});
|
|
64239
|
+
}
|
|
64240
|
+
}
|
|
64241
|
+
|
|
64242
|
+
// src/codegen/validators/typeCheck.ts
|
|
64243
|
+
import * as graphql30 from "graphql";
|
|
64169
64244
|
async function typeCheck(config, docs) {
|
|
64170
64245
|
const errors = [];
|
|
64171
64246
|
const freeLists = [];
|
|
@@ -64173,7 +64248,7 @@ async function typeCheck(config, docs) {
|
|
|
64173
64248
|
const listTypes = [];
|
|
64174
64249
|
const fragments = {};
|
|
64175
64250
|
for (const { document: parsed, originalString, filename } of docs) {
|
|
64176
|
-
|
|
64251
|
+
graphql30.visit(parsed, {
|
|
64177
64252
|
FragmentDefinition(definition) {
|
|
64178
64253
|
fragments[definition.name.value] = definition;
|
|
64179
64254
|
},
|
|
@@ -64218,14 +64293,14 @@ async function typeCheck(config, docs) {
|
|
|
64218
64293
|
);
|
|
64219
64294
|
return;
|
|
64220
64295
|
}
|
|
64221
|
-
if (
|
|
64296
|
+
if (graphql30.isListType(rootType) || graphql30.isNonNullType(rootType) && graphql30.isListType(rootType.ofType)) {
|
|
64222
64297
|
needsParent = true;
|
|
64223
64298
|
break;
|
|
64224
64299
|
}
|
|
64225
|
-
if (
|
|
64300
|
+
if (graphql30.isNonNullType(rootType) && "ofType" in rootType) {
|
|
64226
64301
|
rootType = rootType.ofType;
|
|
64227
64302
|
}
|
|
64228
|
-
if (
|
|
64303
|
+
if (graphql30.isScalarType(rootType)) {
|
|
64229
64304
|
break;
|
|
64230
64305
|
}
|
|
64231
64306
|
rootType = rootType?.getFields()[parent3.name.value]?.type;
|
|
@@ -64301,9 +64376,9 @@ async function typeCheck(config, docs) {
|
|
|
64301
64376
|
);
|
|
64302
64377
|
}
|
|
64303
64378
|
let targetTypes = [type];
|
|
64304
|
-
if (
|
|
64379
|
+
if (graphql30.isUnionType(type)) {
|
|
64305
64380
|
targetTypes = config.schema.getPossibleTypes(type);
|
|
64306
|
-
} else if (
|
|
64381
|
+
} else if (graphql30.isInterfaceType(type)) {
|
|
64307
64382
|
try {
|
|
64308
64383
|
for (const key of config.keyFieldsForType(type.name)) {
|
|
64309
64384
|
if (!type.getFields()[key]) {
|
|
@@ -64339,13 +64414,13 @@ async function typeCheck(config, docs) {
|
|
|
64339
64414
|
if (errors.length > 0) {
|
|
64340
64415
|
throw errors;
|
|
64341
64416
|
}
|
|
64342
|
-
const rules = (filepath) => [...
|
|
64417
|
+
const rules = (filepath) => [...graphql30.specifiedRules].filter(
|
|
64343
64418
|
(rule) => ![
|
|
64344
|
-
|
|
64345
|
-
|
|
64346
|
-
|
|
64347
|
-
|
|
64348
|
-
|
|
64419
|
+
graphql30.NoUnusedFragmentsRule,
|
|
64420
|
+
graphql30.KnownFragmentNamesRule,
|
|
64421
|
+
graphql30.ExecutableDefinitionsRule,
|
|
64422
|
+
graphql30.KnownDirectivesRule,
|
|
64423
|
+
graphql30.KnownArgumentNamesRule
|
|
64349
64424
|
].includes(rule)
|
|
64350
64425
|
).concat(
|
|
64351
64426
|
validateLists({
|
|
@@ -64366,7 +64441,7 @@ async function typeCheck(config, docs) {
|
|
|
64366
64441
|
validateLoadingDirective(config)
|
|
64367
64442
|
);
|
|
64368
64443
|
for (const { filename, document: parsed, originalString } of docs) {
|
|
64369
|
-
for (const error of
|
|
64444
|
+
for (const error of graphql30.validate(config.schema, parsed, rules(filename))) {
|
|
64370
64445
|
errors.push(
|
|
64371
64446
|
new HoudiniError({
|
|
64372
64447
|
filepath: filename,
|
|
@@ -64395,20 +64470,20 @@ function validateRequiredDirective(config, filepath) {
|
|
|
64395
64470
|
if (!node.directives?.some(({ name }) => name.value === config.requiredDirective))
|
|
64396
64471
|
return;
|
|
64397
64472
|
const parentType = parentTypeFromAncestors(config.schema, filepath, ancestors);
|
|
64398
|
-
if (!
|
|
64473
|
+
if (!graphql30.isObjectType(parentType)) {
|
|
64399
64474
|
ctx.reportError(
|
|
64400
|
-
new
|
|
64475
|
+
new graphql30.GraphQLError(
|
|
64401
64476
|
`@${config.requiredDirective} may only be used on objects, not arguments`
|
|
64402
64477
|
)
|
|
64403
64478
|
);
|
|
64404
64479
|
return;
|
|
64405
64480
|
}
|
|
64406
64481
|
const type = parentType.getFields()[node.name.value].type;
|
|
64407
|
-
const isServerNullable = !
|
|
64482
|
+
const isServerNullable = !graphql30.isNonNullType(type);
|
|
64408
64483
|
const isAlreadyClientNullable = isClientNullable(node, true);
|
|
64409
64484
|
if (!isServerNullable && !isAlreadyClientNullable) {
|
|
64410
64485
|
ctx.reportError(
|
|
64411
|
-
new
|
|
64486
|
+
new graphql30.GraphQLError(
|
|
64412
64487
|
`@${config.requiredDirective} may only be used on nullable fields`
|
|
64413
64488
|
)
|
|
64414
64489
|
);
|
|
@@ -64430,7 +64505,7 @@ var validateLists = ({
|
|
|
64430
64505
|
if (!config.isListFragment(node.name.value)) {
|
|
64431
64506
|
if (!fragments[node.name.value]) {
|
|
64432
64507
|
ctx.reportError(
|
|
64433
|
-
new
|
|
64508
|
+
new graphql30.GraphQLError(
|
|
64434
64509
|
"Encountered unknown fragment: " + node.name.value
|
|
64435
64510
|
)
|
|
64436
64511
|
);
|
|
@@ -64440,7 +64515,7 @@ var validateLists = ({
|
|
|
64440
64515
|
const listName = config.listNameFromFragment(node.name.value);
|
|
64441
64516
|
if (!lists.includes(listName)) {
|
|
64442
64517
|
ctx.reportError(
|
|
64443
|
-
new
|
|
64518
|
+
new graphql30.GraphQLError(
|
|
64444
64519
|
"Encountered fragment referencing unknown list: " + listName
|
|
64445
64520
|
)
|
|
64446
64521
|
);
|
|
@@ -64465,7 +64540,7 @@ var validateLists = ({
|
|
|
64465
64540
|
);
|
|
64466
64541
|
if (parentArg) {
|
|
64467
64542
|
ctx.reportError(
|
|
64468
|
-
new
|
|
64543
|
+
new graphql30.GraphQLError(
|
|
64469
64544
|
`@${config.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
|
|
64470
64545
|
)
|
|
64471
64546
|
);
|
|
@@ -64481,7 +64556,7 @@ var validateLists = ({
|
|
|
64481
64556
|
return;
|
|
64482
64557
|
}
|
|
64483
64558
|
ctx.reportError(
|
|
64484
|
-
new
|
|
64559
|
+
new graphql30.GraphQLError(
|
|
64485
64560
|
`For this list fragment, you need to add or @${config.listParentDirective} or @${config.listAllListsDirective} directive to specify the behavior`
|
|
64486
64561
|
)
|
|
64487
64562
|
);
|
|
@@ -64491,7 +64566,7 @@ var validateLists = ({
|
|
|
64491
64566
|
const directiveName = node.name.value;
|
|
64492
64567
|
if (directiveName === "connection") {
|
|
64493
64568
|
ctx.reportError(
|
|
64494
|
-
new
|
|
64569
|
+
new graphql30.GraphQLError(
|
|
64495
64570
|
"@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."
|
|
64496
64571
|
)
|
|
64497
64572
|
);
|
|
@@ -64500,7 +64575,7 @@ var validateLists = ({
|
|
|
64500
64575
|
if (!config.isInternalDirective(node.name.value)) {
|
|
64501
64576
|
if (!config.schema.getDirective(directiveName)) {
|
|
64502
64577
|
ctx.reportError(
|
|
64503
|
-
new
|
|
64578
|
+
new graphql30.GraphQLError(
|
|
64504
64579
|
"Encountered unknown directive: " + directiveName
|
|
64505
64580
|
)
|
|
64506
64581
|
);
|
|
@@ -64509,7 +64584,7 @@ var validateLists = ({
|
|
|
64509
64584
|
}
|
|
64510
64585
|
if (config.isListOperationDirective(directiveName) && !listTypes.includes(config.listNameFromDirective(directiveName))) {
|
|
64511
64586
|
ctx.reportError(
|
|
64512
|
-
new
|
|
64587
|
+
new graphql30.GraphQLError(
|
|
64513
64588
|
"Encountered directive referencing unknown list: " + directiveName
|
|
64514
64589
|
)
|
|
64515
64590
|
);
|
|
@@ -64520,7 +64595,7 @@ var validateLists = ({
|
|
|
64520
64595
|
};
|
|
64521
64596
|
function knownArguments(config) {
|
|
64522
64597
|
return function(ctx) {
|
|
64523
|
-
const nativeValidator =
|
|
64598
|
+
const nativeValidator = graphql30.KnownArgumentNamesRule(ctx);
|
|
64524
64599
|
return {
|
|
64525
64600
|
...nativeValidator,
|
|
64526
64601
|
Directive(directiveNode) {
|
|
@@ -64555,7 +64630,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64555
64630
|
for (const arg of node.arguments || []) {
|
|
64556
64631
|
if (arg.value.kind !== "ObjectValue") {
|
|
64557
64632
|
ctx.reportError(
|
|
64558
|
-
new
|
|
64633
|
+
new graphql30.GraphQLError("values in @arguments must be an object")
|
|
64559
64634
|
);
|
|
64560
64635
|
return;
|
|
64561
64636
|
}
|
|
@@ -64565,13 +64640,13 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64565
64640
|
);
|
|
64566
64641
|
if (!typeArg) {
|
|
64567
64642
|
ctx.reportError(
|
|
64568
|
-
new
|
|
64643
|
+
new graphql30.GraphQLError("missing type field for @arguments directive")
|
|
64569
64644
|
);
|
|
64570
64645
|
return;
|
|
64571
64646
|
}
|
|
64572
|
-
if (typeArg.value.kind !==
|
|
64647
|
+
if (typeArg.value.kind !== graphql30.Kind.STRING) {
|
|
64573
64648
|
ctx.reportError(
|
|
64574
|
-
new
|
|
64649
|
+
new graphql30.GraphQLError("type field to @arguments must be a string")
|
|
64575
64650
|
);
|
|
64576
64651
|
return;
|
|
64577
64652
|
}
|
|
@@ -64584,7 +64659,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64584
64659
|
);
|
|
64585
64660
|
if (typeArg.value.value !== defaultValueType) {
|
|
64586
64661
|
ctx.reportError(
|
|
64587
|
-
new
|
|
64662
|
+
new graphql30.GraphQLError(
|
|
64588
64663
|
`Invalid default value provided for ${arg.name.value}. Expected ${typeArg.value.value}, found ${defaultValueType}`
|
|
64589
64664
|
)
|
|
64590
64665
|
);
|
|
@@ -64602,7 +64677,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64602
64677
|
try {
|
|
64603
64678
|
args = fragmentArguments(config, filepath, fragments[fragmentName]);
|
|
64604
64679
|
} catch (e) {
|
|
64605
|
-
ctx.reportError(new
|
|
64680
|
+
ctx.reportError(new graphql30.GraphQLError(e.message));
|
|
64606
64681
|
return;
|
|
64607
64682
|
}
|
|
64608
64683
|
fragmentArguments2[fragmentName] = args;
|
|
@@ -64625,7 +64700,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64625
64700
|
);
|
|
64626
64701
|
if (missing.length > 0) {
|
|
64627
64702
|
ctx.reportError(
|
|
64628
|
-
new
|
|
64703
|
+
new graphql30.GraphQLError(
|
|
64629
64704
|
`The following arguments are missing from the "${fragmentName}" fragment: ` + JSON.stringify(missing)
|
|
64630
64705
|
)
|
|
64631
64706
|
);
|
|
@@ -64636,7 +64711,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64636
64711
|
);
|
|
64637
64712
|
if (unknown.length > 0) {
|
|
64638
64713
|
ctx.reportError(
|
|
64639
|
-
new
|
|
64714
|
+
new graphql30.GraphQLError(
|
|
64640
64715
|
"Encountered unknown arguments: " + JSON.stringify(unknown)
|
|
64641
64716
|
)
|
|
64642
64717
|
);
|
|
@@ -64648,7 +64723,7 @@ function validateFragmentArguments(config, filepath, fragments) {
|
|
|
64648
64723
|
for (const [applied, target] of zipped) {
|
|
64649
64724
|
if (!valueIsType(config, applied.value, target)) {
|
|
64650
64725
|
ctx.reportError(
|
|
64651
|
-
new
|
|
64726
|
+
new graphql30.GraphQLError(
|
|
64652
64727
|
`Invalid argument type. Expected ${target}, found ${applied.value.kind}`
|
|
64653
64728
|
)
|
|
64654
64729
|
);
|
|
@@ -64690,7 +64765,7 @@ function valueIsType(config, value, targetType) {
|
|
|
64690
64765
|
}
|
|
64691
64766
|
if (value.kind === "EnumValue" && targetType.kind === "NamedType") {
|
|
64692
64767
|
const enumType = config.schema.getType(targetType.name.value);
|
|
64693
|
-
if (!
|
|
64768
|
+
if (!graphql30.isEnumType(enumType)) {
|
|
64694
64769
|
return false;
|
|
64695
64770
|
}
|
|
64696
64771
|
return enumType.getValues().some((enumValue) => enumValue.value === value.value);
|
|
@@ -64710,7 +64785,7 @@ function paginateArgs(config, filepath) {
|
|
|
64710
64785
|
}
|
|
64711
64786
|
if (alreadyPaginated) {
|
|
64712
64787
|
ctx.reportError(
|
|
64713
|
-
new
|
|
64788
|
+
new graphql30.GraphQLError(
|
|
64714
64789
|
`@${config.paginateDirective} can only appear in a document once.`
|
|
64715
64790
|
)
|
|
64716
64791
|
);
|
|
@@ -64742,7 +64817,7 @@ function paginateArgs(config, filepath) {
|
|
|
64742
64817
|
const backwards = appliedArgs.has("last");
|
|
64743
64818
|
if (!forward && !backwards) {
|
|
64744
64819
|
ctx.reportError(
|
|
64745
|
-
new
|
|
64820
|
+
new graphql30.GraphQLError(
|
|
64746
64821
|
"A field with cursor-based pagination must have a first or last argument"
|
|
64747
64822
|
)
|
|
64748
64823
|
);
|
|
@@ -64756,7 +64831,7 @@ function paginateArgs(config, filepath) {
|
|
|
64756
64831
|
}
|
|
64757
64832
|
if (forward && backwards && paginateMode === "Infinite") {
|
|
64758
64833
|
ctx.reportError(
|
|
64759
|
-
new
|
|
64834
|
+
new graphql30.GraphQLError(
|
|
64760
64835
|
`A field with cursor pagination cannot go forwards an backwards simultaneously`
|
|
64761
64836
|
)
|
|
64762
64837
|
);
|
|
@@ -64770,7 +64845,7 @@ function paginateArgs(config, filepath) {
|
|
|
64770
64845
|
);
|
|
64771
64846
|
if (!appliedLimitArg) {
|
|
64772
64847
|
ctx.reportError(
|
|
64773
|
-
new
|
|
64848
|
+
new graphql30.GraphQLError(
|
|
64774
64849
|
"A field with offset-based pagination must have a limit argument"
|
|
64775
64850
|
)
|
|
64776
64851
|
);
|
|
@@ -64786,20 +64861,20 @@ function noUnusedFragmentArguments(config) {
|
|
|
64786
64861
|
const args = /* @__PURE__ */ new Set();
|
|
64787
64862
|
return {
|
|
64788
64863
|
enter(node) {
|
|
64789
|
-
if (node.kind ===
|
|
64864
|
+
if (node.kind === graphql30.Kind.FRAGMENT_DEFINITION) {
|
|
64790
64865
|
const definitionArguments = node.directives?.filter((directive) => directive.name.value === config.argumentsDirective).flatMap((directive) => directive.arguments);
|
|
64791
64866
|
for (const arg of definitionArguments?.map((arg2) => arg2?.name.value) || []) {
|
|
64792
64867
|
args.add(arg);
|
|
64793
64868
|
}
|
|
64794
|
-
} else if (node.kind ===
|
|
64869
|
+
} else if (node.kind === graphql30.Kind.VARIABLE) {
|
|
64795
64870
|
args.delete(node.name.value);
|
|
64796
64871
|
}
|
|
64797
64872
|
},
|
|
64798
64873
|
leave(node) {
|
|
64799
|
-
if (node.kind ===
|
|
64874
|
+
if (node.kind === graphql30.Kind.FRAGMENT_DEFINITION) {
|
|
64800
64875
|
if (args.size > 0) {
|
|
64801
64876
|
ctx.reportError(
|
|
64802
|
-
new
|
|
64877
|
+
new graphql30.GraphQLError(
|
|
64803
64878
|
"Encountered unused fragment arguments: " + [...args].join(",")
|
|
64804
64879
|
)
|
|
64805
64880
|
);
|
|
@@ -64835,7 +64910,7 @@ function nodeDirectives(config, directives) {
|
|
|
64835
64910
|
if (definition.kind === "OperationDefinition") {
|
|
64836
64911
|
if (definition.operation !== "query") {
|
|
64837
64912
|
ctx.reportError(
|
|
64838
|
-
new
|
|
64913
|
+
new graphql30.GraphQLError(
|
|
64839
64914
|
`@${node.name.value} must fall on a fragment or query document`
|
|
64840
64915
|
)
|
|
64841
64916
|
);
|
|
@@ -64847,7 +64922,7 @@ function nodeDirectives(config, directives) {
|
|
|
64847
64922
|
}
|
|
64848
64923
|
if (!possibleNodes.includes(definitionType)) {
|
|
64849
64924
|
ctx.reportError(
|
|
64850
|
-
new
|
|
64925
|
+
new graphql30.GraphQLError(paginateOnNonNodeMessage(node.name.value))
|
|
64851
64926
|
);
|
|
64852
64927
|
}
|
|
64853
64928
|
}
|
|
@@ -64866,7 +64941,7 @@ function checkMutationOperation(config) {
|
|
|
64866
64941
|
);
|
|
64867
64942
|
if (append && prepend) {
|
|
64868
64943
|
ctx.reportError(
|
|
64869
|
-
new
|
|
64944
|
+
new graphql30.GraphQLError(
|
|
64870
64945
|
`You can't apply both @${config.listPrependDirective} and @${config.listAppendDirective} at the same time`
|
|
64871
64946
|
)
|
|
64872
64947
|
);
|
|
@@ -64880,7 +64955,7 @@ function checkMutationOperation(config) {
|
|
|
64880
64955
|
);
|
|
64881
64956
|
if (parentId && allLists) {
|
|
64882
64957
|
ctx.reportError(
|
|
64883
|
-
new
|
|
64958
|
+
new graphql30.GraphQLError(
|
|
64884
64959
|
`You can't apply both @${config.listParentDirective} and @${config.listAllListsDirective} at the same time`
|
|
64885
64960
|
)
|
|
64886
64961
|
);
|
|
@@ -64902,7 +64977,7 @@ function checkMaskDirectives(config) {
|
|
|
64902
64977
|
);
|
|
64903
64978
|
if (maskEnableDirective && maskDisableDirective) {
|
|
64904
64979
|
ctx.reportError(
|
|
64905
|
-
new
|
|
64980
|
+
new graphql30.GraphQLError(
|
|
64906
64981
|
`You can't apply both @${config.maskEnableDirective} and @${config.maskDisableDirective} at the same time`
|
|
64907
64982
|
)
|
|
64908
64983
|
);
|
|
@@ -64944,7 +65019,7 @@ function validateLoadingDirective(config) {
|
|
|
64944
65019
|
);
|
|
64945
65020
|
if (!parentLoading && !global2) {
|
|
64946
65021
|
ctx.reportError(
|
|
64947
|
-
new
|
|
65022
|
+
new graphql30.GraphQLError(
|
|
64948
65023
|
`@${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}`
|
|
64949
65024
|
)
|
|
64950
65025
|
);
|
|
@@ -64966,7 +65041,7 @@ function validateLoadingDirective(config) {
|
|
|
64966
65041
|
);
|
|
64967
65042
|
if (!parentLoading && !global2) {
|
|
64968
65043
|
ctx.reportError(
|
|
64969
|
-
new
|
|
65044
|
+
new graphql30.GraphQLError(
|
|
64970
65045
|
`@${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}`
|
|
64971
65046
|
)
|
|
64972
65047
|
);
|
|
@@ -64981,7 +65056,7 @@ function getAndVerifyNodeInterface(config) {
|
|
|
64981
65056
|
if (!nodeInterface) {
|
|
64982
65057
|
return null;
|
|
64983
65058
|
}
|
|
64984
|
-
if (!
|
|
65059
|
+
if (!graphql30.isInterfaceType(nodeInterface)) {
|
|
64985
65060
|
displayInvalidNodeFieldMessage(config);
|
|
64986
65061
|
return null;
|
|
64987
65062
|
}
|
|
@@ -65076,11 +65151,11 @@ async function uniqueDocumentNames(config, docs) {
|
|
|
65076
65151
|
}
|
|
65077
65152
|
|
|
65078
65153
|
// src/codegen/validators/noIDAlias.ts
|
|
65079
|
-
import * as
|
|
65154
|
+
import * as graphql31 from "graphql";
|
|
65080
65155
|
async function noIDAlias(config, docs) {
|
|
65081
65156
|
const errors = [];
|
|
65082
65157
|
for (const { filename, document } of docs) {
|
|
65083
|
-
|
|
65158
|
+
graphql31.visit(document, {
|
|
65084
65159
|
Field(node, _, __, ___, ancestors) {
|
|
65085
65160
|
const fieldType = parentTypeFromAncestors(config.schema, filename, ancestors).name;
|
|
65086
65161
|
if (config.keyFieldsForType(fieldType).includes(node.alias?.value || "")) {
|
|
@@ -65119,11 +65194,11 @@ async function validatePlugins(config, documents) {
|
|
|
65119
65194
|
}
|
|
65120
65195
|
|
|
65121
65196
|
// src/codegen/validators/componentFields.ts
|
|
65122
|
-
import * as
|
|
65197
|
+
import * as graphql32 from "graphql";
|
|
65123
65198
|
async function componentFields2(config, docs) {
|
|
65124
65199
|
const errors = [];
|
|
65125
65200
|
for (const { filename: filepath, document } of docs) {
|
|
65126
|
-
|
|
65201
|
+
graphql32.visit(document, {
|
|
65127
65202
|
FragmentDefinition(node, _, __, ___, ancestors) {
|
|
65128
65203
|
const componentFieldDirective = node.directives?.find(
|
|
65129
65204
|
(dir) => dir.name.value === config.componentFieldDirective
|
|
@@ -65165,14 +65240,26 @@ async function componentFields2(config, docs) {
|
|
|
65165
65240
|
}
|
|
65166
65241
|
const fieldValue = fieldArg.value?.kind === "StringValue" ? fieldArg.value.value : void 0;
|
|
65167
65242
|
const propValue = propArg.value?.kind === "StringValue" ? propArg.value.value : void 0;
|
|
65243
|
+
const existingField = fieldValue && config.componentFields[parent2]?.[fieldValue];
|
|
65168
65244
|
const parentType = config.schema.getType(parent2);
|
|
65169
|
-
|
|
65245
|
+
let conflict = false;
|
|
65246
|
+
if (existingField && existingField.filepath !== filepath) {
|
|
65247
|
+
conflict = true;
|
|
65248
|
+
} else if (parentType && fieldValue) {
|
|
65249
|
+
const fieldDef = graphql32.isObjectType(parentType) && parentType.getFields()[fieldValue];
|
|
65250
|
+
if (fieldDef && !fieldDef.astNode?.directives?.find(
|
|
65251
|
+
(dir) => dir.name.value === config.componentFieldDirective
|
|
65252
|
+
)) {
|
|
65253
|
+
conflict = true;
|
|
65254
|
+
}
|
|
65255
|
+
}
|
|
65256
|
+
if (conflict) {
|
|
65170
65257
|
errors.push({
|
|
65171
|
-
message: `Duplicate component field definition for ${parent2}.${fieldValue}
|
|
65258
|
+
message: `Duplicate component field definition for ${parent2}.${fieldValue}.` + (existingField ? "The conflicting component field was defined in " + existingField.filepath : ""),
|
|
65172
65259
|
filepath
|
|
65173
65260
|
});
|
|
65174
65261
|
}
|
|
65175
|
-
if (parentType &&
|
|
65262
|
+
if (parentType && graphql32.isAbstractType(parentType)) {
|
|
65176
65263
|
errors.push({
|
|
65177
65264
|
message: `Cannot add component field ${parent2}.${fieldValue} because ${parent2} is an abstract type`,
|
|
65178
65265
|
filepath
|
|
@@ -65238,6 +65325,7 @@ async function runPipeline2(config, docs) {
|
|
|
65238
65325
|
[
|
|
65239
65326
|
componentFields2,
|
|
65240
65327
|
graphqlExtensions,
|
|
65328
|
+
addTypename2,
|
|
65241
65329
|
...wrapHook(beforeValidate),
|
|
65242
65330
|
typeCheck,
|
|
65243
65331
|
uniqueDocumentNames,
|
|
@@ -65392,12 +65480,12 @@ async function processJSFile(config, contents) {
|
|
|
65392
65480
|
return documents;
|
|
65393
65481
|
}
|
|
65394
65482
|
async function processGraphQLDocument(config, filepath, document) {
|
|
65395
|
-
const parsedDoc =
|
|
65483
|
+
const parsedDoc = graphql33.parse(document);
|
|
65396
65484
|
const operations = parsedDoc.definitions.filter(
|
|
65397
|
-
({ kind: kind2 }) => kind2 ===
|
|
65485
|
+
({ kind: kind2 }) => kind2 === graphql33.Kind.OPERATION_DEFINITION
|
|
65398
65486
|
);
|
|
65399
65487
|
const fragments = parsedDoc.definitions.filter(
|
|
65400
|
-
({ kind: kind2 }) => kind2 ===
|
|
65488
|
+
({ kind: kind2 }) => kind2 === graphql33.Kind.FRAGMENT_DEFINITION
|
|
65401
65489
|
);
|
|
65402
65490
|
if (operations.length > 1) {
|
|
65403
65491
|
throw new HoudiniError({
|
package/build/lib/config.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ export declare class Config {
|
|
|
114
114
|
get toggleFragmentSuffix(): string;
|
|
115
115
|
get deleteDirectiveSuffix(): string;
|
|
116
116
|
get loadingDirective(): string;
|
|
117
|
+
get runtimeScalarDirective(): string;
|
|
117
118
|
get whenDirective(): string;
|
|
118
119
|
get whenNotDirective(): string;
|
|
119
120
|
get liveDirective(): string;
|