houdini 1.0.0 → 1.0.2
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 +89 -48
- package/build/cmd-esm/index.js +89 -48
- package/build/codegen/transforms/fragmentVariables.d.ts +2 -1
- package/build/codegen/validators/typeCheck.d.ts +1 -0
- package/build/codegen-cjs/index.js +87 -46
- package/build/codegen-esm/index.js +87 -46
- package/build/test/index.d.ts +1 -1
- package/build/test-cjs/index.js +92 -49
- package/build/test-esm/index.js +92 -49
- package/build/vite-cjs/index.js +87 -46
- package/build/vite-esm/index.js +87 -46
- package/package.json +1 -1
package/build/test-cjs/index.js
CHANGED
|
@@ -3347,7 +3347,7 @@ var require_definition = __commonJS({
|
|
|
3347
3347
|
exports.assertInterfaceType = assertInterfaceType;
|
|
3348
3348
|
exports.isUnionType = isUnionType7;
|
|
3349
3349
|
exports.assertUnionType = assertUnionType;
|
|
3350
|
-
exports.isEnumType =
|
|
3350
|
+
exports.isEnumType = isEnumType7;
|
|
3351
3351
|
exports.assertEnumType = assertEnumType;
|
|
3352
3352
|
exports.isInputObjectType = isInputObjectType2;
|
|
3353
3353
|
exports.assertInputObjectType = assertInputObjectType;
|
|
@@ -3418,7 +3418,7 @@ var require_definition = __commonJS({
|
|
|
3418
3418
|
return Constructor;
|
|
3419
3419
|
}
|
|
3420
3420
|
function isType(type) {
|
|
3421
|
-
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) ||
|
|
3421
|
+
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType7(type) || isInputObjectType2(type) || isListType3(type) || isNonNullType6(type);
|
|
3422
3422
|
}
|
|
3423
3423
|
function assertType(type) {
|
|
3424
3424
|
if (!isType(type)) {
|
|
@@ -3462,11 +3462,11 @@ var require_definition = __commonJS({
|
|
|
3462
3462
|
}
|
|
3463
3463
|
return type;
|
|
3464
3464
|
}
|
|
3465
|
-
function
|
|
3465
|
+
function isEnumType7(type) {
|
|
3466
3466
|
return (0, _instanceOf.default)(type, GraphQLEnumType);
|
|
3467
3467
|
}
|
|
3468
3468
|
function assertEnumType(type) {
|
|
3469
|
-
if (!
|
|
3469
|
+
if (!isEnumType7(type)) {
|
|
3470
3470
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Enum type."));
|
|
3471
3471
|
}
|
|
3472
3472
|
return type;
|
|
@@ -3499,7 +3499,7 @@ var require_definition = __commonJS({
|
|
|
3499
3499
|
return type;
|
|
3500
3500
|
}
|
|
3501
3501
|
function isInputType(type) {
|
|
3502
|
-
return isScalarType7(type) ||
|
|
3502
|
+
return isScalarType7(type) || isEnumType7(type) || isInputObjectType2(type) || isWrappingType(type) && isInputType(type.ofType);
|
|
3503
3503
|
}
|
|
3504
3504
|
function assertInputType(type) {
|
|
3505
3505
|
if (!isInputType(type)) {
|
|
@@ -3508,7 +3508,7 @@ var require_definition = __commonJS({
|
|
|
3508
3508
|
return type;
|
|
3509
3509
|
}
|
|
3510
3510
|
function isOutputType(type) {
|
|
3511
|
-
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) ||
|
|
3511
|
+
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType7(type) || isWrappingType(type) && isOutputType(type.ofType);
|
|
3512
3512
|
}
|
|
3513
3513
|
function assertOutputType(type) {
|
|
3514
3514
|
if (!isOutputType(type)) {
|
|
@@ -3517,7 +3517,7 @@ var require_definition = __commonJS({
|
|
|
3517
3517
|
return type;
|
|
3518
3518
|
}
|
|
3519
3519
|
function isLeafType(type) {
|
|
3520
|
-
return isScalarType7(type) ||
|
|
3520
|
+
return isScalarType7(type) || isEnumType7(type);
|
|
3521
3521
|
}
|
|
3522
3522
|
function assertLeafType(type) {
|
|
3523
3523
|
if (!isLeafType(type)) {
|
|
@@ -3605,7 +3605,7 @@ var require_definition = __commonJS({
|
|
|
3605
3605
|
}
|
|
3606
3606
|
}
|
|
3607
3607
|
function isNamedType(type) {
|
|
3608
|
-
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) ||
|
|
3608
|
+
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType7(type) || isInputObjectType2(type);
|
|
3609
3609
|
}
|
|
3610
3610
|
function assertNamedType(type) {
|
|
3611
3611
|
if (!isNamedType(type)) {
|
|
@@ -57807,26 +57807,45 @@ function fragmentArguments(config2, filepath, definition) {
|
|
|
57807
57807
|
if (!typeArg || typeArg.kind !== "StringValue") {
|
|
57808
57808
|
return [];
|
|
57809
57809
|
}
|
|
57810
|
-
let type = typeArg.value;
|
|
57811
|
-
let name = arg.name.value;
|
|
57812
|
-
let required = false;
|
|
57810
|
+
let type = parseArgumentTypeString(typeArg.value);
|
|
57813
57811
|
let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
|
|
57814
|
-
if (type[type.length - 1] === "!") {
|
|
57815
|
-
type = type.slice(0, -1);
|
|
57816
|
-
required = true;
|
|
57817
|
-
defaultValue = null;
|
|
57818
|
-
}
|
|
57819
57812
|
return [
|
|
57820
57813
|
{
|
|
57821
|
-
name,
|
|
57814
|
+
name: arg.name.value,
|
|
57822
57815
|
type,
|
|
57823
|
-
required,
|
|
57816
|
+
required: type.kind === "NonNullType",
|
|
57824
57817
|
defaultValue
|
|
57825
57818
|
}
|
|
57826
57819
|
];
|
|
57827
57820
|
}) || []
|
|
57828
57821
|
);
|
|
57829
57822
|
}
|
|
57823
|
+
function parseArgumentTypeString(input) {
|
|
57824
|
+
if (input[input.length - 1] === "!") {
|
|
57825
|
+
const inner = parseArgumentTypeString(input.substring(0, input.length - 1));
|
|
57826
|
+
if (inner.kind === "NonNullType") {
|
|
57827
|
+
throw new Error("invalid type" + input);
|
|
57828
|
+
}
|
|
57829
|
+
return {
|
|
57830
|
+
kind: "NonNullType",
|
|
57831
|
+
type: inner
|
|
57832
|
+
};
|
|
57833
|
+
}
|
|
57834
|
+
if (input[input.length - 1] === "]") {
|
|
57835
|
+
const inner = parseArgumentTypeString(input.substring(1, input.length - 1));
|
|
57836
|
+
return {
|
|
57837
|
+
kind: "ListType",
|
|
57838
|
+
type: inner
|
|
57839
|
+
};
|
|
57840
|
+
}
|
|
57841
|
+
return {
|
|
57842
|
+
kind: "NamedType",
|
|
57843
|
+
name: {
|
|
57844
|
+
kind: "Name",
|
|
57845
|
+
value: input
|
|
57846
|
+
}
|
|
57847
|
+
};
|
|
57848
|
+
}
|
|
57830
57849
|
function collectDefaultArgumentValues(config2, filepath, definition) {
|
|
57831
57850
|
let result = {};
|
|
57832
57851
|
for (const { name, required, defaultValue } of fragmentArguments(
|
|
@@ -57889,19 +57908,9 @@ function fragmentArgumentsDefinitions(config2, filepath, definition) {
|
|
|
57889
57908
|
return [];
|
|
57890
57909
|
}
|
|
57891
57910
|
return args.map((arg) => {
|
|
57892
|
-
const innerType = {
|
|
57893
|
-
kind: "NamedType",
|
|
57894
|
-
name: {
|
|
57895
|
-
kind: "Name",
|
|
57896
|
-
value: arg.type
|
|
57897
|
-
}
|
|
57898
|
-
};
|
|
57899
57911
|
return {
|
|
57900
57912
|
kind: "VariableDefinition",
|
|
57901
|
-
type: arg.
|
|
57902
|
-
kind: "NonNullType",
|
|
57903
|
-
type: innerType
|
|
57904
|
-
},
|
|
57913
|
+
type: arg.type,
|
|
57905
57914
|
variable: {
|
|
57906
57915
|
kind: "Variable",
|
|
57907
57916
|
name: {
|
|
@@ -61238,7 +61247,7 @@ async function typeCheck(config2, docs) {
|
|
|
61238
61247
|
const lists = [];
|
|
61239
61248
|
const listTypes = [];
|
|
61240
61249
|
const fragments = {};
|
|
61241
|
-
for (const { document: parsed, filename } of docs) {
|
|
61250
|
+
for (const { document: parsed, originalString, filename } of docs) {
|
|
61242
61251
|
graphql23.visit(parsed, {
|
|
61243
61252
|
[graphql23.Kind.FRAGMENT_DEFINITION](definition) {
|
|
61244
61253
|
fragments[definition.name.value] = definition;
|
|
@@ -61436,7 +61445,7 @@ async function typeCheck(config2, docs) {
|
|
|
61436
61445
|
paginateArgs(config2, filepath),
|
|
61437
61446
|
noUnusedFragmentArguments(config2)
|
|
61438
61447
|
);
|
|
61439
|
-
for (const { filename, document: parsed } of docs) {
|
|
61448
|
+
for (const { filename, document: parsed, originalString } of docs) {
|
|
61440
61449
|
for (const error of graphql23.validate(config2.schema, parsed, rules(filename))) {
|
|
61441
61450
|
errors.push(
|
|
61442
61451
|
new HoudiniError({
|
|
@@ -61672,24 +61681,15 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
61672
61681
|
)
|
|
61673
61682
|
);
|
|
61674
61683
|
} else {
|
|
61675
|
-
const zipped = appliedArgumentNames.map(
|
|
61676
|
-
|
|
61677
|
-
|
|
61678
|
-
|
|
61679
|
-
]
|
|
61680
|
-
);
|
|
61684
|
+
const zipped = appliedArgumentNames.map((name) => [
|
|
61685
|
+
appliedArguments[name],
|
|
61686
|
+
fragmentArguments2[fragmentName].find((arg) => arg.name === name).type
|
|
61687
|
+
]);
|
|
61681
61688
|
for (const [applied, target] of zipped) {
|
|
61682
|
-
if (
|
|
61683
|
-
continue;
|
|
61684
|
-
}
|
|
61685
|
-
const appliedType = applied.value.kind.substring(
|
|
61686
|
-
0,
|
|
61687
|
-
applied.value.kind.length - "Value".length
|
|
61688
|
-
);
|
|
61689
|
-
if (appliedType !== target) {
|
|
61689
|
+
if (!valueIsType(config2, applied.value, target)) {
|
|
61690
61690
|
ctx.reportError(
|
|
61691
61691
|
new graphql23.GraphQLError(
|
|
61692
|
-
`Invalid argument type. Expected ${target}, found ${
|
|
61692
|
+
`Invalid argument type. Expected ${target}, found ${applied.value.kind}`
|
|
61693
61693
|
)
|
|
61694
61694
|
);
|
|
61695
61695
|
}
|
|
@@ -61699,6 +61699,47 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
61699
61699
|
};
|
|
61700
61700
|
};
|
|
61701
61701
|
}
|
|
61702
|
+
function valueIsType(config2, value, targetType) {
|
|
61703
|
+
if (value.kind === "NullValue") {
|
|
61704
|
+
return targetType.kind !== "NonNullType";
|
|
61705
|
+
}
|
|
61706
|
+
if (targetType.kind === "NonNullType") {
|
|
61707
|
+
targetType = targetType.type;
|
|
61708
|
+
}
|
|
61709
|
+
if (value.kind === "ListValue") {
|
|
61710
|
+
if (targetType.kind !== "ListType") {
|
|
61711
|
+
return false;
|
|
61712
|
+
}
|
|
61713
|
+
const listType = targetType.type;
|
|
61714
|
+
return value.values.every((value2) => valueIsType(config2, value2, listType));
|
|
61715
|
+
}
|
|
61716
|
+
if (value.kind === "BooleanValue") {
|
|
61717
|
+
return targetType.kind === "NamedType" && targetType.name.value === "Boolean";
|
|
61718
|
+
}
|
|
61719
|
+
if (value.kind === "StringValue") {
|
|
61720
|
+
return targetType.kind === "NamedType" && targetType.name.value === "String";
|
|
61721
|
+
}
|
|
61722
|
+
if (value.kind === "IntValue") {
|
|
61723
|
+
return targetType.kind === "NamedType" && targetType.name.value === "Int";
|
|
61724
|
+
}
|
|
61725
|
+
if (value.kind === "FloatValue") {
|
|
61726
|
+
return targetType.kind === "NamedType" && targetType.name.value === "Float";
|
|
61727
|
+
}
|
|
61728
|
+
if (value.kind === "ObjectValue" && targetType.kind === "NamedType") {
|
|
61729
|
+
return true;
|
|
61730
|
+
}
|
|
61731
|
+
if (value.kind === "EnumValue" && targetType.kind === "NamedType") {
|
|
61732
|
+
const enumType = config2.schema.getType(targetType.name.value);
|
|
61733
|
+
if (!graphql23.isEnumType(enumType)) {
|
|
61734
|
+
return false;
|
|
61735
|
+
}
|
|
61736
|
+
return enumType.getValues().some((enumValue) => enumValue.value === value.value);
|
|
61737
|
+
}
|
|
61738
|
+
if (value.kind === "Variable") {
|
|
61739
|
+
return true;
|
|
61740
|
+
}
|
|
61741
|
+
return false;
|
|
61742
|
+
}
|
|
61702
61743
|
function paginateArgs(config2, filepath) {
|
|
61703
61744
|
return function(ctx) {
|
|
61704
61745
|
let alreadyPaginated = false;
|
|
@@ -62269,6 +62310,7 @@ function testConfigFile({ plugins, ...config2 } = {}) {
|
|
|
62269
62310
|
entitiesByCursor(first: Int, after: String, last: Int, before: String): EntityConnection!
|
|
62270
62311
|
node(id: ID!): Node
|
|
62271
62312
|
customIdList: [CustomIdType]!
|
|
62313
|
+
nodes(ids: [ID!]!): [Node!]!
|
|
62272
62314
|
}
|
|
62273
62315
|
|
|
62274
62316
|
type PageInfo {
|
|
@@ -62453,7 +62495,7 @@ function testConfig(config2 = {}) {
|
|
|
62453
62495
|
}
|
|
62454
62496
|
function pipelineTest(config2, documents, shouldPass, testBody) {
|
|
62455
62497
|
return async () => {
|
|
62456
|
-
const docs = documents.map(mockCollectedDoc);
|
|
62498
|
+
const docs = documents.map((doc) => mockCollectedDoc(doc));
|
|
62457
62499
|
let error = [];
|
|
62458
62500
|
try {
|
|
62459
62501
|
await runPipeline2(config2, docs);
|
|
@@ -62472,7 +62514,7 @@ function pipelineTest(config2, documents, shouldPass, testBody) {
|
|
|
62472
62514
|
}
|
|
62473
62515
|
};
|
|
62474
62516
|
}
|
|
62475
|
-
function mockCollectedDoc(query2) {
|
|
62517
|
+
function mockCollectedDoc(query2, data) {
|
|
62476
62518
|
const parsed = graphql25.parse(query2);
|
|
62477
62519
|
const name = parsed.definitions[0].name.value;
|
|
62478
62520
|
const operations = parsed.definitions;
|
|
@@ -62495,7 +62537,8 @@ function mockCollectedDoc(query2) {
|
|
|
62495
62537
|
generateArtifact: true,
|
|
62496
62538
|
generateStore: true,
|
|
62497
62539
|
originalString: query2,
|
|
62498
|
-
artifact: null
|
|
62540
|
+
artifact: null,
|
|
62541
|
+
...data
|
|
62499
62542
|
};
|
|
62500
62543
|
}
|
|
62501
62544
|
function clearMock() {
|
package/build/test-esm/index.js
CHANGED
|
@@ -3352,7 +3352,7 @@ var require_definition = __commonJS({
|
|
|
3352
3352
|
exports.assertInterfaceType = assertInterfaceType;
|
|
3353
3353
|
exports.isUnionType = isUnionType7;
|
|
3354
3354
|
exports.assertUnionType = assertUnionType;
|
|
3355
|
-
exports.isEnumType =
|
|
3355
|
+
exports.isEnumType = isEnumType7;
|
|
3356
3356
|
exports.assertEnumType = assertEnumType;
|
|
3357
3357
|
exports.isInputObjectType = isInputObjectType2;
|
|
3358
3358
|
exports.assertInputObjectType = assertInputObjectType;
|
|
@@ -3423,7 +3423,7 @@ var require_definition = __commonJS({
|
|
|
3423
3423
|
return Constructor;
|
|
3424
3424
|
}
|
|
3425
3425
|
function isType(type) {
|
|
3426
|
-
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) ||
|
|
3426
|
+
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType7(type) || isInputObjectType2(type) || isListType3(type) || isNonNullType6(type);
|
|
3427
3427
|
}
|
|
3428
3428
|
function assertType(type) {
|
|
3429
3429
|
if (!isType(type)) {
|
|
@@ -3467,11 +3467,11 @@ var require_definition = __commonJS({
|
|
|
3467
3467
|
}
|
|
3468
3468
|
return type;
|
|
3469
3469
|
}
|
|
3470
|
-
function
|
|
3470
|
+
function isEnumType7(type) {
|
|
3471
3471
|
return (0, _instanceOf.default)(type, GraphQLEnumType);
|
|
3472
3472
|
}
|
|
3473
3473
|
function assertEnumType(type) {
|
|
3474
|
-
if (!
|
|
3474
|
+
if (!isEnumType7(type)) {
|
|
3475
3475
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Enum type."));
|
|
3476
3476
|
}
|
|
3477
3477
|
return type;
|
|
@@ -3504,7 +3504,7 @@ var require_definition = __commonJS({
|
|
|
3504
3504
|
return type;
|
|
3505
3505
|
}
|
|
3506
3506
|
function isInputType(type) {
|
|
3507
|
-
return isScalarType7(type) ||
|
|
3507
|
+
return isScalarType7(type) || isEnumType7(type) || isInputObjectType2(type) || isWrappingType(type) && isInputType(type.ofType);
|
|
3508
3508
|
}
|
|
3509
3509
|
function assertInputType(type) {
|
|
3510
3510
|
if (!isInputType(type)) {
|
|
@@ -3513,7 +3513,7 @@ var require_definition = __commonJS({
|
|
|
3513
3513
|
return type;
|
|
3514
3514
|
}
|
|
3515
3515
|
function isOutputType(type) {
|
|
3516
|
-
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) ||
|
|
3516
|
+
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType7(type) || isWrappingType(type) && isOutputType(type.ofType);
|
|
3517
3517
|
}
|
|
3518
3518
|
function assertOutputType(type) {
|
|
3519
3519
|
if (!isOutputType(type)) {
|
|
@@ -3522,7 +3522,7 @@ var require_definition = __commonJS({
|
|
|
3522
3522
|
return type;
|
|
3523
3523
|
}
|
|
3524
3524
|
function isLeafType(type) {
|
|
3525
|
-
return isScalarType7(type) ||
|
|
3525
|
+
return isScalarType7(type) || isEnumType7(type);
|
|
3526
3526
|
}
|
|
3527
3527
|
function assertLeafType(type) {
|
|
3528
3528
|
if (!isLeafType(type)) {
|
|
@@ -3610,7 +3610,7 @@ var require_definition = __commonJS({
|
|
|
3610
3610
|
}
|
|
3611
3611
|
}
|
|
3612
3612
|
function isNamedType(type) {
|
|
3613
|
-
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) ||
|
|
3613
|
+
return isScalarType7(type) || isObjectType3(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType7(type) || isInputObjectType2(type);
|
|
3614
3614
|
}
|
|
3615
3615
|
function assertNamedType(type) {
|
|
3616
3616
|
if (!isNamedType(type)) {
|
|
@@ -57802,26 +57802,45 @@ function fragmentArguments(config2, filepath, definition) {
|
|
|
57802
57802
|
if (!typeArg || typeArg.kind !== "StringValue") {
|
|
57803
57803
|
return [];
|
|
57804
57804
|
}
|
|
57805
|
-
let type = typeArg.value;
|
|
57806
|
-
let name = arg.name.value;
|
|
57807
|
-
let required = false;
|
|
57805
|
+
let type = parseArgumentTypeString(typeArg.value);
|
|
57808
57806
|
let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
|
|
57809
|
-
if (type[type.length - 1] === "!") {
|
|
57810
|
-
type = type.slice(0, -1);
|
|
57811
|
-
required = true;
|
|
57812
|
-
defaultValue = null;
|
|
57813
|
-
}
|
|
57814
57807
|
return [
|
|
57815
57808
|
{
|
|
57816
|
-
name,
|
|
57809
|
+
name: arg.name.value,
|
|
57817
57810
|
type,
|
|
57818
|
-
required,
|
|
57811
|
+
required: type.kind === "NonNullType",
|
|
57819
57812
|
defaultValue
|
|
57820
57813
|
}
|
|
57821
57814
|
];
|
|
57822
57815
|
}) || []
|
|
57823
57816
|
);
|
|
57824
57817
|
}
|
|
57818
|
+
function parseArgumentTypeString(input) {
|
|
57819
|
+
if (input[input.length - 1] === "!") {
|
|
57820
|
+
const inner = parseArgumentTypeString(input.substring(0, input.length - 1));
|
|
57821
|
+
if (inner.kind === "NonNullType") {
|
|
57822
|
+
throw new Error("invalid type" + input);
|
|
57823
|
+
}
|
|
57824
|
+
return {
|
|
57825
|
+
kind: "NonNullType",
|
|
57826
|
+
type: inner
|
|
57827
|
+
};
|
|
57828
|
+
}
|
|
57829
|
+
if (input[input.length - 1] === "]") {
|
|
57830
|
+
const inner = parseArgumentTypeString(input.substring(1, input.length - 1));
|
|
57831
|
+
return {
|
|
57832
|
+
kind: "ListType",
|
|
57833
|
+
type: inner
|
|
57834
|
+
};
|
|
57835
|
+
}
|
|
57836
|
+
return {
|
|
57837
|
+
kind: "NamedType",
|
|
57838
|
+
name: {
|
|
57839
|
+
kind: "Name",
|
|
57840
|
+
value: input
|
|
57841
|
+
}
|
|
57842
|
+
};
|
|
57843
|
+
}
|
|
57825
57844
|
function collectDefaultArgumentValues(config2, filepath, definition) {
|
|
57826
57845
|
let result = {};
|
|
57827
57846
|
for (const { name, required, defaultValue } of fragmentArguments(
|
|
@@ -57884,19 +57903,9 @@ function fragmentArgumentsDefinitions(config2, filepath, definition) {
|
|
|
57884
57903
|
return [];
|
|
57885
57904
|
}
|
|
57886
57905
|
return args.map((arg) => {
|
|
57887
|
-
const innerType = {
|
|
57888
|
-
kind: "NamedType",
|
|
57889
|
-
name: {
|
|
57890
|
-
kind: "Name",
|
|
57891
|
-
value: arg.type
|
|
57892
|
-
}
|
|
57893
|
-
};
|
|
57894
57906
|
return {
|
|
57895
57907
|
kind: "VariableDefinition",
|
|
57896
|
-
type: arg.
|
|
57897
|
-
kind: "NonNullType",
|
|
57898
|
-
type: innerType
|
|
57899
|
-
},
|
|
57908
|
+
type: arg.type,
|
|
57900
57909
|
variable: {
|
|
57901
57910
|
kind: "Variable",
|
|
57902
57911
|
name: {
|
|
@@ -61233,7 +61242,7 @@ async function typeCheck(config2, docs) {
|
|
|
61233
61242
|
const lists = [];
|
|
61234
61243
|
const listTypes = [];
|
|
61235
61244
|
const fragments = {};
|
|
61236
|
-
for (const { document: parsed, filename } of docs) {
|
|
61245
|
+
for (const { document: parsed, originalString, filename } of docs) {
|
|
61237
61246
|
graphql23.visit(parsed, {
|
|
61238
61247
|
[graphql23.Kind.FRAGMENT_DEFINITION](definition) {
|
|
61239
61248
|
fragments[definition.name.value] = definition;
|
|
@@ -61431,7 +61440,7 @@ async function typeCheck(config2, docs) {
|
|
|
61431
61440
|
paginateArgs(config2, filepath),
|
|
61432
61441
|
noUnusedFragmentArguments(config2)
|
|
61433
61442
|
);
|
|
61434
|
-
for (const { filename, document: parsed } of docs) {
|
|
61443
|
+
for (const { filename, document: parsed, originalString } of docs) {
|
|
61435
61444
|
for (const error of graphql23.validate(config2.schema, parsed, rules(filename))) {
|
|
61436
61445
|
errors.push(
|
|
61437
61446
|
new HoudiniError({
|
|
@@ -61667,24 +61676,15 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
61667
61676
|
)
|
|
61668
61677
|
);
|
|
61669
61678
|
} else {
|
|
61670
|
-
const zipped = appliedArgumentNames.map(
|
|
61671
|
-
|
|
61672
|
-
|
|
61673
|
-
|
|
61674
|
-
]
|
|
61675
|
-
);
|
|
61679
|
+
const zipped = appliedArgumentNames.map((name) => [
|
|
61680
|
+
appliedArguments[name],
|
|
61681
|
+
fragmentArguments2[fragmentName].find((arg) => arg.name === name).type
|
|
61682
|
+
]);
|
|
61676
61683
|
for (const [applied, target] of zipped) {
|
|
61677
|
-
if (
|
|
61678
|
-
continue;
|
|
61679
|
-
}
|
|
61680
|
-
const appliedType = applied.value.kind.substring(
|
|
61681
|
-
0,
|
|
61682
|
-
applied.value.kind.length - "Value".length
|
|
61683
|
-
);
|
|
61684
|
-
if (appliedType !== target) {
|
|
61684
|
+
if (!valueIsType(config2, applied.value, target)) {
|
|
61685
61685
|
ctx.reportError(
|
|
61686
61686
|
new graphql23.GraphQLError(
|
|
61687
|
-
`Invalid argument type. Expected ${target}, found ${
|
|
61687
|
+
`Invalid argument type. Expected ${target}, found ${applied.value.kind}`
|
|
61688
61688
|
)
|
|
61689
61689
|
);
|
|
61690
61690
|
}
|
|
@@ -61694,6 +61694,47 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
61694
61694
|
};
|
|
61695
61695
|
};
|
|
61696
61696
|
}
|
|
61697
|
+
function valueIsType(config2, value, targetType) {
|
|
61698
|
+
if (value.kind === "NullValue") {
|
|
61699
|
+
return targetType.kind !== "NonNullType";
|
|
61700
|
+
}
|
|
61701
|
+
if (targetType.kind === "NonNullType") {
|
|
61702
|
+
targetType = targetType.type;
|
|
61703
|
+
}
|
|
61704
|
+
if (value.kind === "ListValue") {
|
|
61705
|
+
if (targetType.kind !== "ListType") {
|
|
61706
|
+
return false;
|
|
61707
|
+
}
|
|
61708
|
+
const listType = targetType.type;
|
|
61709
|
+
return value.values.every((value2) => valueIsType(config2, value2, listType));
|
|
61710
|
+
}
|
|
61711
|
+
if (value.kind === "BooleanValue") {
|
|
61712
|
+
return targetType.kind === "NamedType" && targetType.name.value === "Boolean";
|
|
61713
|
+
}
|
|
61714
|
+
if (value.kind === "StringValue") {
|
|
61715
|
+
return targetType.kind === "NamedType" && targetType.name.value === "String";
|
|
61716
|
+
}
|
|
61717
|
+
if (value.kind === "IntValue") {
|
|
61718
|
+
return targetType.kind === "NamedType" && targetType.name.value === "Int";
|
|
61719
|
+
}
|
|
61720
|
+
if (value.kind === "FloatValue") {
|
|
61721
|
+
return targetType.kind === "NamedType" && targetType.name.value === "Float";
|
|
61722
|
+
}
|
|
61723
|
+
if (value.kind === "ObjectValue" && targetType.kind === "NamedType") {
|
|
61724
|
+
return true;
|
|
61725
|
+
}
|
|
61726
|
+
if (value.kind === "EnumValue" && targetType.kind === "NamedType") {
|
|
61727
|
+
const enumType = config2.schema.getType(targetType.name.value);
|
|
61728
|
+
if (!graphql23.isEnumType(enumType)) {
|
|
61729
|
+
return false;
|
|
61730
|
+
}
|
|
61731
|
+
return enumType.getValues().some((enumValue) => enumValue.value === value.value);
|
|
61732
|
+
}
|
|
61733
|
+
if (value.kind === "Variable") {
|
|
61734
|
+
return true;
|
|
61735
|
+
}
|
|
61736
|
+
return false;
|
|
61737
|
+
}
|
|
61697
61738
|
function paginateArgs(config2, filepath) {
|
|
61698
61739
|
return function(ctx) {
|
|
61699
61740
|
let alreadyPaginated = false;
|
|
@@ -62264,6 +62305,7 @@ function testConfigFile({ plugins, ...config2 } = {}) {
|
|
|
62264
62305
|
entitiesByCursor(first: Int, after: String, last: Int, before: String): EntityConnection!
|
|
62265
62306
|
node(id: ID!): Node
|
|
62266
62307
|
customIdList: [CustomIdType]!
|
|
62308
|
+
nodes(ids: [ID!]!): [Node!]!
|
|
62267
62309
|
}
|
|
62268
62310
|
|
|
62269
62311
|
type PageInfo {
|
|
@@ -62448,7 +62490,7 @@ function testConfig(config2 = {}) {
|
|
|
62448
62490
|
}
|
|
62449
62491
|
function pipelineTest(config2, documents, shouldPass, testBody) {
|
|
62450
62492
|
return async () => {
|
|
62451
|
-
const docs = documents.map(mockCollectedDoc);
|
|
62493
|
+
const docs = documents.map((doc) => mockCollectedDoc(doc));
|
|
62452
62494
|
let error = [];
|
|
62453
62495
|
try {
|
|
62454
62496
|
await runPipeline2(config2, docs);
|
|
@@ -62467,7 +62509,7 @@ function pipelineTest(config2, documents, shouldPass, testBody) {
|
|
|
62467
62509
|
}
|
|
62468
62510
|
};
|
|
62469
62511
|
}
|
|
62470
|
-
function mockCollectedDoc(query2) {
|
|
62512
|
+
function mockCollectedDoc(query2, data) {
|
|
62471
62513
|
const parsed = graphql25.parse(query2);
|
|
62472
62514
|
const name = parsed.definitions[0].name.value;
|
|
62473
62515
|
const operations = parsed.definitions;
|
|
@@ -62490,7 +62532,8 @@ function mockCollectedDoc(query2) {
|
|
|
62490
62532
|
generateArtifact: true,
|
|
62491
62533
|
generateStore: true,
|
|
62492
62534
|
originalString: query2,
|
|
62493
|
-
artifact: null
|
|
62535
|
+
artifact: null,
|
|
62536
|
+
...data
|
|
62494
62537
|
};
|
|
62495
62538
|
}
|
|
62496
62539
|
function clearMock() {
|