houdini 1.0.0 → 1.0.1
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-cjs/index.js +88 -46
- package/build/test-esm/index.js +88 -46
- package/build/vite-cjs/index.js +87 -46
- package/build/vite-esm/index.js +87 -46
- package/package.json +1 -1
package/build/cmd-cjs/index.js
CHANGED
|
@@ -5100,7 +5100,7 @@ var require_definition = __commonJS({
|
|
|
5100
5100
|
exports.assertInterfaceType = assertInterfaceType;
|
|
5101
5101
|
exports.isUnionType = isUnionType13;
|
|
5102
5102
|
exports.assertUnionType = assertUnionType;
|
|
5103
|
-
exports.isEnumType =
|
|
5103
|
+
exports.isEnumType = isEnumType12;
|
|
5104
5104
|
exports.assertEnumType = assertEnumType;
|
|
5105
5105
|
exports.isInputObjectType = isInputObjectType8;
|
|
5106
5106
|
exports.assertInputObjectType = assertInputObjectType;
|
|
@@ -5171,7 +5171,7 @@ var require_definition = __commonJS({
|
|
|
5171
5171
|
return Constructor;
|
|
5172
5172
|
}
|
|
5173
5173
|
function isType(type) {
|
|
5174
|
-
return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) ||
|
|
5174
|
+
return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType12(type) || isInputObjectType8(type) || isListType8(type) || isNonNullType10(type);
|
|
5175
5175
|
}
|
|
5176
5176
|
function assertType(type) {
|
|
5177
5177
|
if (!isType(type)) {
|
|
@@ -5215,11 +5215,11 @@ var require_definition = __commonJS({
|
|
|
5215
5215
|
}
|
|
5216
5216
|
return type;
|
|
5217
5217
|
}
|
|
5218
|
-
function
|
|
5218
|
+
function isEnumType12(type) {
|
|
5219
5219
|
return (0, _instanceOf.default)(type, GraphQLEnumType4);
|
|
5220
5220
|
}
|
|
5221
5221
|
function assertEnumType(type) {
|
|
5222
|
-
if (!
|
|
5222
|
+
if (!isEnumType12(type)) {
|
|
5223
5223
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Enum type."));
|
|
5224
5224
|
}
|
|
5225
5225
|
return type;
|
|
@@ -5252,7 +5252,7 @@ var require_definition = __commonJS({
|
|
|
5252
5252
|
return type;
|
|
5253
5253
|
}
|
|
5254
5254
|
function isInputType(type) {
|
|
5255
|
-
return isScalarType13(type) ||
|
|
5255
|
+
return isScalarType13(type) || isEnumType12(type) || isInputObjectType8(type) || isWrappingType(type) && isInputType(type.ofType);
|
|
5256
5256
|
}
|
|
5257
5257
|
function assertInputType(type) {
|
|
5258
5258
|
if (!isInputType(type)) {
|
|
@@ -5261,7 +5261,7 @@ var require_definition = __commonJS({
|
|
|
5261
5261
|
return type;
|
|
5262
5262
|
}
|
|
5263
5263
|
function isOutputType(type) {
|
|
5264
|
-
return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) ||
|
|
5264
|
+
return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType12(type) || isWrappingType(type) && isOutputType(type.ofType);
|
|
5265
5265
|
}
|
|
5266
5266
|
function assertOutputType(type) {
|
|
5267
5267
|
if (!isOutputType(type)) {
|
|
@@ -5270,7 +5270,7 @@ var require_definition = __commonJS({
|
|
|
5270
5270
|
return type;
|
|
5271
5271
|
}
|
|
5272
5272
|
function isLeafType4(type) {
|
|
5273
|
-
return isScalarType13(type) ||
|
|
5273
|
+
return isScalarType13(type) || isEnumType12(type);
|
|
5274
5274
|
}
|
|
5275
5275
|
function assertLeafType(type) {
|
|
5276
5276
|
if (!isLeafType4(type)) {
|
|
@@ -5358,7 +5358,7 @@ var require_definition = __commonJS({
|
|
|
5358
5358
|
}
|
|
5359
5359
|
}
|
|
5360
5360
|
function isNamedType4(type) {
|
|
5361
|
-
return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) ||
|
|
5361
|
+
return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType12(type) || isInputObjectType8(type);
|
|
5362
5362
|
}
|
|
5363
5363
|
function assertNamedType(type) {
|
|
5364
5364
|
if (!isNamedType4(type)) {
|
|
@@ -73732,26 +73732,45 @@ function fragmentArguments(config2, filepath, definition) {
|
|
|
73732
73732
|
if (!typeArg || typeArg.kind !== "StringValue") {
|
|
73733
73733
|
return [];
|
|
73734
73734
|
}
|
|
73735
|
-
let type = typeArg.value;
|
|
73736
|
-
let name = arg.name.value;
|
|
73737
|
-
let required = false;
|
|
73735
|
+
let type = parseArgumentTypeString(typeArg.value);
|
|
73738
73736
|
let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
|
|
73739
|
-
if (type[type.length - 1] === "!") {
|
|
73740
|
-
type = type.slice(0, -1);
|
|
73741
|
-
required = true;
|
|
73742
|
-
defaultValue = null;
|
|
73743
|
-
}
|
|
73744
73737
|
return [
|
|
73745
73738
|
{
|
|
73746
|
-
name,
|
|
73739
|
+
name: arg.name.value,
|
|
73747
73740
|
type,
|
|
73748
|
-
required,
|
|
73741
|
+
required: type.kind === "NonNullType",
|
|
73749
73742
|
defaultValue
|
|
73750
73743
|
}
|
|
73751
73744
|
];
|
|
73752
73745
|
}) || []
|
|
73753
73746
|
);
|
|
73754
73747
|
}
|
|
73748
|
+
function parseArgumentTypeString(input) {
|
|
73749
|
+
if (input[input.length - 1] === "!") {
|
|
73750
|
+
const inner = parseArgumentTypeString(input.substring(0, input.length - 1));
|
|
73751
|
+
if (inner.kind === "NonNullType") {
|
|
73752
|
+
throw new Error("invalid type" + input);
|
|
73753
|
+
}
|
|
73754
|
+
return {
|
|
73755
|
+
kind: "NonNullType",
|
|
73756
|
+
type: inner
|
|
73757
|
+
};
|
|
73758
|
+
}
|
|
73759
|
+
if (input[input.length - 1] === "]") {
|
|
73760
|
+
const inner = parseArgumentTypeString(input.substring(1, input.length - 1));
|
|
73761
|
+
return {
|
|
73762
|
+
kind: "ListType",
|
|
73763
|
+
type: inner
|
|
73764
|
+
};
|
|
73765
|
+
}
|
|
73766
|
+
return {
|
|
73767
|
+
kind: "NamedType",
|
|
73768
|
+
name: {
|
|
73769
|
+
kind: "Name",
|
|
73770
|
+
value: input
|
|
73771
|
+
}
|
|
73772
|
+
};
|
|
73773
|
+
}
|
|
73755
73774
|
function collectDefaultArgumentValues(config2, filepath, definition) {
|
|
73756
73775
|
let result = {};
|
|
73757
73776
|
for (const { name, required, defaultValue } of fragmentArguments(
|
|
@@ -73814,19 +73833,9 @@ function fragmentArgumentsDefinitions(config2, filepath, definition) {
|
|
|
73814
73833
|
return [];
|
|
73815
73834
|
}
|
|
73816
73835
|
return args.map((arg) => {
|
|
73817
|
-
const innerType = {
|
|
73818
|
-
kind: "NamedType",
|
|
73819
|
-
name: {
|
|
73820
|
-
kind: "Name",
|
|
73821
|
-
value: arg.type
|
|
73822
|
-
}
|
|
73823
|
-
};
|
|
73824
73836
|
return {
|
|
73825
73837
|
kind: "VariableDefinition",
|
|
73826
|
-
type: arg.
|
|
73827
|
-
kind: "NonNullType",
|
|
73828
|
-
type: innerType
|
|
73829
|
-
},
|
|
73838
|
+
type: arg.type,
|
|
73830
73839
|
variable: {
|
|
73831
73840
|
kind: "Variable",
|
|
73832
73841
|
name: {
|
|
@@ -77163,7 +77172,7 @@ async function typeCheck(config2, docs) {
|
|
|
77163
77172
|
const lists = [];
|
|
77164
77173
|
const listTypes = [];
|
|
77165
77174
|
const fragments = {};
|
|
77166
|
-
for (const { document: parsed, filename } of docs) {
|
|
77175
|
+
for (const { document: parsed, originalString, filename } of docs) {
|
|
77167
77176
|
graphql25.visit(parsed, {
|
|
77168
77177
|
[graphql25.Kind.FRAGMENT_DEFINITION](definition) {
|
|
77169
77178
|
fragments[definition.name.value] = definition;
|
|
@@ -77361,7 +77370,7 @@ async function typeCheck(config2, docs) {
|
|
|
77361
77370
|
paginateArgs(config2, filepath),
|
|
77362
77371
|
noUnusedFragmentArguments(config2)
|
|
77363
77372
|
);
|
|
77364
|
-
for (const { filename, document: parsed } of docs) {
|
|
77373
|
+
for (const { filename, document: parsed, originalString } of docs) {
|
|
77365
77374
|
for (const error of graphql25.validate(config2.schema, parsed, rules(filename))) {
|
|
77366
77375
|
errors.push(
|
|
77367
77376
|
new HoudiniError({
|
|
@@ -77597,24 +77606,15 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77597
77606
|
)
|
|
77598
77607
|
);
|
|
77599
77608
|
} else {
|
|
77600
|
-
const zipped = appliedArgumentNames.map(
|
|
77601
|
-
|
|
77602
|
-
|
|
77603
|
-
|
|
77604
|
-
]
|
|
77605
|
-
);
|
|
77609
|
+
const zipped = appliedArgumentNames.map((name) => [
|
|
77610
|
+
appliedArguments[name],
|
|
77611
|
+
fragmentArguments2[fragmentName].find((arg) => arg.name === name).type
|
|
77612
|
+
]);
|
|
77606
77613
|
for (const [applied, target] of zipped) {
|
|
77607
|
-
if (
|
|
77608
|
-
continue;
|
|
77609
|
-
}
|
|
77610
|
-
const appliedType = applied.value.kind.substring(
|
|
77611
|
-
0,
|
|
77612
|
-
applied.value.kind.length - "Value".length
|
|
77613
|
-
);
|
|
77614
|
-
if (appliedType !== target) {
|
|
77614
|
+
if (!valueIsType(config2, applied.value, target)) {
|
|
77615
77615
|
ctx.reportError(
|
|
77616
77616
|
new graphql25.GraphQLError(
|
|
77617
|
-
`Invalid argument type. Expected ${target}, found ${
|
|
77617
|
+
`Invalid argument type. Expected ${target}, found ${applied.value.kind}`
|
|
77618
77618
|
)
|
|
77619
77619
|
);
|
|
77620
77620
|
}
|
|
@@ -77624,6 +77624,47 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77624
77624
|
};
|
|
77625
77625
|
};
|
|
77626
77626
|
}
|
|
77627
|
+
function valueIsType(config2, value, targetType) {
|
|
77628
|
+
if (value.kind === "NullValue") {
|
|
77629
|
+
return targetType.kind !== "NonNullType";
|
|
77630
|
+
}
|
|
77631
|
+
if (targetType.kind === "NonNullType") {
|
|
77632
|
+
targetType = targetType.type;
|
|
77633
|
+
}
|
|
77634
|
+
if (value.kind === "ListValue") {
|
|
77635
|
+
if (targetType.kind !== "ListType") {
|
|
77636
|
+
return false;
|
|
77637
|
+
}
|
|
77638
|
+
const listType = targetType.type;
|
|
77639
|
+
return value.values.every((value2) => valueIsType(config2, value2, listType));
|
|
77640
|
+
}
|
|
77641
|
+
if (value.kind === "BooleanValue") {
|
|
77642
|
+
return targetType.kind === "NamedType" && targetType.name.value === "Boolean";
|
|
77643
|
+
}
|
|
77644
|
+
if (value.kind === "StringValue") {
|
|
77645
|
+
return targetType.kind === "NamedType" && targetType.name.value === "String";
|
|
77646
|
+
}
|
|
77647
|
+
if (value.kind === "IntValue") {
|
|
77648
|
+
return targetType.kind === "NamedType" && targetType.name.value === "Int";
|
|
77649
|
+
}
|
|
77650
|
+
if (value.kind === "FloatValue") {
|
|
77651
|
+
return targetType.kind === "NamedType" && targetType.name.value === "Float";
|
|
77652
|
+
}
|
|
77653
|
+
if (value.kind === "ObjectValue" && targetType.kind === "NamedType") {
|
|
77654
|
+
return true;
|
|
77655
|
+
}
|
|
77656
|
+
if (value.kind === "EnumValue" && targetType.kind === "NamedType") {
|
|
77657
|
+
const enumType = config2.schema.getType(targetType.name.value);
|
|
77658
|
+
if (!graphql25.isEnumType(enumType)) {
|
|
77659
|
+
return false;
|
|
77660
|
+
}
|
|
77661
|
+
return enumType.getValues().some((enumValue) => enumValue.value === value.value);
|
|
77662
|
+
}
|
|
77663
|
+
if (value.kind === "Variable") {
|
|
77664
|
+
return true;
|
|
77665
|
+
}
|
|
77666
|
+
return false;
|
|
77667
|
+
}
|
|
77627
77668
|
function paginateArgs(config2, filepath) {
|
|
77628
77669
|
return function(ctx) {
|
|
77629
77670
|
let alreadyPaginated = false;
|
|
@@ -78683,8 +78724,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
78683
78724
|
}
|
|
78684
78725
|
packageJSON.devDependencies = {
|
|
78685
78726
|
...packageJSON.devDependencies,
|
|
78686
|
-
houdini: "^1.0.
|
|
78687
|
-
"houdini-svelte": "^1.0.
|
|
78727
|
+
houdini: "^1.0.1",
|
|
78728
|
+
"houdini-svelte": "^1.0.1"
|
|
78688
78729
|
};
|
|
78689
78730
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
78690
78731
|
}
|
package/build/cmd-esm/index.js
CHANGED
|
@@ -5106,7 +5106,7 @@ var require_definition = __commonJS({
|
|
|
5106
5106
|
exports.assertInterfaceType = assertInterfaceType;
|
|
5107
5107
|
exports.isUnionType = isUnionType13;
|
|
5108
5108
|
exports.assertUnionType = assertUnionType;
|
|
5109
|
-
exports.isEnumType =
|
|
5109
|
+
exports.isEnumType = isEnumType12;
|
|
5110
5110
|
exports.assertEnumType = assertEnumType;
|
|
5111
5111
|
exports.isInputObjectType = isInputObjectType8;
|
|
5112
5112
|
exports.assertInputObjectType = assertInputObjectType;
|
|
@@ -5177,7 +5177,7 @@ var require_definition = __commonJS({
|
|
|
5177
5177
|
return Constructor;
|
|
5178
5178
|
}
|
|
5179
5179
|
function isType(type) {
|
|
5180
|
-
return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) ||
|
|
5180
|
+
return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType12(type) || isInputObjectType8(type) || isListType8(type) || isNonNullType10(type);
|
|
5181
5181
|
}
|
|
5182
5182
|
function assertType(type) {
|
|
5183
5183
|
if (!isType(type)) {
|
|
@@ -5221,11 +5221,11 @@ var require_definition = __commonJS({
|
|
|
5221
5221
|
}
|
|
5222
5222
|
return type;
|
|
5223
5223
|
}
|
|
5224
|
-
function
|
|
5224
|
+
function isEnumType12(type) {
|
|
5225
5225
|
return (0, _instanceOf.default)(type, GraphQLEnumType4);
|
|
5226
5226
|
}
|
|
5227
5227
|
function assertEnumType(type) {
|
|
5228
|
-
if (!
|
|
5228
|
+
if (!isEnumType12(type)) {
|
|
5229
5229
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Enum type."));
|
|
5230
5230
|
}
|
|
5231
5231
|
return type;
|
|
@@ -5258,7 +5258,7 @@ var require_definition = __commonJS({
|
|
|
5258
5258
|
return type;
|
|
5259
5259
|
}
|
|
5260
5260
|
function isInputType(type) {
|
|
5261
|
-
return isScalarType13(type) ||
|
|
5261
|
+
return isScalarType13(type) || isEnumType12(type) || isInputObjectType8(type) || isWrappingType(type) && isInputType(type.ofType);
|
|
5262
5262
|
}
|
|
5263
5263
|
function assertInputType(type) {
|
|
5264
5264
|
if (!isInputType(type)) {
|
|
@@ -5267,7 +5267,7 @@ var require_definition = __commonJS({
|
|
|
5267
5267
|
return type;
|
|
5268
5268
|
}
|
|
5269
5269
|
function isOutputType(type) {
|
|
5270
|
-
return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) ||
|
|
5270
|
+
return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType12(type) || isWrappingType(type) && isOutputType(type.ofType);
|
|
5271
5271
|
}
|
|
5272
5272
|
function assertOutputType(type) {
|
|
5273
5273
|
if (!isOutputType(type)) {
|
|
@@ -5276,7 +5276,7 @@ var require_definition = __commonJS({
|
|
|
5276
5276
|
return type;
|
|
5277
5277
|
}
|
|
5278
5278
|
function isLeafType4(type) {
|
|
5279
|
-
return isScalarType13(type) ||
|
|
5279
|
+
return isScalarType13(type) || isEnumType12(type);
|
|
5280
5280
|
}
|
|
5281
5281
|
function assertLeafType(type) {
|
|
5282
5282
|
if (!isLeafType4(type)) {
|
|
@@ -5364,7 +5364,7 @@ var require_definition = __commonJS({
|
|
|
5364
5364
|
}
|
|
5365
5365
|
}
|
|
5366
5366
|
function isNamedType4(type) {
|
|
5367
|
-
return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) ||
|
|
5367
|
+
return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType12(type) || isInputObjectType8(type);
|
|
5368
5368
|
}
|
|
5369
5369
|
function assertNamedType(type) {
|
|
5370
5370
|
if (!isNamedType4(type)) {
|
|
@@ -73737,26 +73737,45 @@ function fragmentArguments(config2, filepath, definition) {
|
|
|
73737
73737
|
if (!typeArg || typeArg.kind !== "StringValue") {
|
|
73738
73738
|
return [];
|
|
73739
73739
|
}
|
|
73740
|
-
let type = typeArg.value;
|
|
73741
|
-
let name = arg.name.value;
|
|
73742
|
-
let required = false;
|
|
73740
|
+
let type = parseArgumentTypeString(typeArg.value);
|
|
73743
73741
|
let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
|
|
73744
|
-
if (type[type.length - 1] === "!") {
|
|
73745
|
-
type = type.slice(0, -1);
|
|
73746
|
-
required = true;
|
|
73747
|
-
defaultValue = null;
|
|
73748
|
-
}
|
|
73749
73742
|
return [
|
|
73750
73743
|
{
|
|
73751
|
-
name,
|
|
73744
|
+
name: arg.name.value,
|
|
73752
73745
|
type,
|
|
73753
|
-
required,
|
|
73746
|
+
required: type.kind === "NonNullType",
|
|
73754
73747
|
defaultValue
|
|
73755
73748
|
}
|
|
73756
73749
|
];
|
|
73757
73750
|
}) || []
|
|
73758
73751
|
);
|
|
73759
73752
|
}
|
|
73753
|
+
function parseArgumentTypeString(input) {
|
|
73754
|
+
if (input[input.length - 1] === "!") {
|
|
73755
|
+
const inner = parseArgumentTypeString(input.substring(0, input.length - 1));
|
|
73756
|
+
if (inner.kind === "NonNullType") {
|
|
73757
|
+
throw new Error("invalid type" + input);
|
|
73758
|
+
}
|
|
73759
|
+
return {
|
|
73760
|
+
kind: "NonNullType",
|
|
73761
|
+
type: inner
|
|
73762
|
+
};
|
|
73763
|
+
}
|
|
73764
|
+
if (input[input.length - 1] === "]") {
|
|
73765
|
+
const inner = parseArgumentTypeString(input.substring(1, input.length - 1));
|
|
73766
|
+
return {
|
|
73767
|
+
kind: "ListType",
|
|
73768
|
+
type: inner
|
|
73769
|
+
};
|
|
73770
|
+
}
|
|
73771
|
+
return {
|
|
73772
|
+
kind: "NamedType",
|
|
73773
|
+
name: {
|
|
73774
|
+
kind: "Name",
|
|
73775
|
+
value: input
|
|
73776
|
+
}
|
|
73777
|
+
};
|
|
73778
|
+
}
|
|
73760
73779
|
function collectDefaultArgumentValues(config2, filepath, definition) {
|
|
73761
73780
|
let result = {};
|
|
73762
73781
|
for (const { name, required, defaultValue } of fragmentArguments(
|
|
@@ -73819,19 +73838,9 @@ function fragmentArgumentsDefinitions(config2, filepath, definition) {
|
|
|
73819
73838
|
return [];
|
|
73820
73839
|
}
|
|
73821
73840
|
return args.map((arg) => {
|
|
73822
|
-
const innerType = {
|
|
73823
|
-
kind: "NamedType",
|
|
73824
|
-
name: {
|
|
73825
|
-
kind: "Name",
|
|
73826
|
-
value: arg.type
|
|
73827
|
-
}
|
|
73828
|
-
};
|
|
73829
73841
|
return {
|
|
73830
73842
|
kind: "VariableDefinition",
|
|
73831
|
-
type: arg.
|
|
73832
|
-
kind: "NonNullType",
|
|
73833
|
-
type: innerType
|
|
73834
|
-
},
|
|
73843
|
+
type: arg.type,
|
|
73835
73844
|
variable: {
|
|
73836
73845
|
kind: "Variable",
|
|
73837
73846
|
name: {
|
|
@@ -77168,7 +77177,7 @@ async function typeCheck(config2, docs) {
|
|
|
77168
77177
|
const lists = [];
|
|
77169
77178
|
const listTypes = [];
|
|
77170
77179
|
const fragments = {};
|
|
77171
|
-
for (const { document: parsed, filename } of docs) {
|
|
77180
|
+
for (const { document: parsed, originalString, filename } of docs) {
|
|
77172
77181
|
graphql25.visit(parsed, {
|
|
77173
77182
|
[graphql25.Kind.FRAGMENT_DEFINITION](definition) {
|
|
77174
77183
|
fragments[definition.name.value] = definition;
|
|
@@ -77366,7 +77375,7 @@ async function typeCheck(config2, docs) {
|
|
|
77366
77375
|
paginateArgs(config2, filepath),
|
|
77367
77376
|
noUnusedFragmentArguments(config2)
|
|
77368
77377
|
);
|
|
77369
|
-
for (const { filename, document: parsed } of docs) {
|
|
77378
|
+
for (const { filename, document: parsed, originalString } of docs) {
|
|
77370
77379
|
for (const error of graphql25.validate(config2.schema, parsed, rules(filename))) {
|
|
77371
77380
|
errors.push(
|
|
77372
77381
|
new HoudiniError({
|
|
@@ -77602,24 +77611,15 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77602
77611
|
)
|
|
77603
77612
|
);
|
|
77604
77613
|
} else {
|
|
77605
|
-
const zipped = appliedArgumentNames.map(
|
|
77606
|
-
|
|
77607
|
-
|
|
77608
|
-
|
|
77609
|
-
]
|
|
77610
|
-
);
|
|
77614
|
+
const zipped = appliedArgumentNames.map((name) => [
|
|
77615
|
+
appliedArguments[name],
|
|
77616
|
+
fragmentArguments2[fragmentName].find((arg) => arg.name === name).type
|
|
77617
|
+
]);
|
|
77611
77618
|
for (const [applied, target] of zipped) {
|
|
77612
|
-
if (
|
|
77613
|
-
continue;
|
|
77614
|
-
}
|
|
77615
|
-
const appliedType = applied.value.kind.substring(
|
|
77616
|
-
0,
|
|
77617
|
-
applied.value.kind.length - "Value".length
|
|
77618
|
-
);
|
|
77619
|
-
if (appliedType !== target) {
|
|
77619
|
+
if (!valueIsType(config2, applied.value, target)) {
|
|
77620
77620
|
ctx.reportError(
|
|
77621
77621
|
new graphql25.GraphQLError(
|
|
77622
|
-
`Invalid argument type. Expected ${target}, found ${
|
|
77622
|
+
`Invalid argument type. Expected ${target}, found ${applied.value.kind}`
|
|
77623
77623
|
)
|
|
77624
77624
|
);
|
|
77625
77625
|
}
|
|
@@ -77629,6 +77629,47 @@ function validateFragmentArguments(config2, filepath, fragments) {
|
|
|
77629
77629
|
};
|
|
77630
77630
|
};
|
|
77631
77631
|
}
|
|
77632
|
+
function valueIsType(config2, value, targetType) {
|
|
77633
|
+
if (value.kind === "NullValue") {
|
|
77634
|
+
return targetType.kind !== "NonNullType";
|
|
77635
|
+
}
|
|
77636
|
+
if (targetType.kind === "NonNullType") {
|
|
77637
|
+
targetType = targetType.type;
|
|
77638
|
+
}
|
|
77639
|
+
if (value.kind === "ListValue") {
|
|
77640
|
+
if (targetType.kind !== "ListType") {
|
|
77641
|
+
return false;
|
|
77642
|
+
}
|
|
77643
|
+
const listType = targetType.type;
|
|
77644
|
+
return value.values.every((value2) => valueIsType(config2, value2, listType));
|
|
77645
|
+
}
|
|
77646
|
+
if (value.kind === "BooleanValue") {
|
|
77647
|
+
return targetType.kind === "NamedType" && targetType.name.value === "Boolean";
|
|
77648
|
+
}
|
|
77649
|
+
if (value.kind === "StringValue") {
|
|
77650
|
+
return targetType.kind === "NamedType" && targetType.name.value === "String";
|
|
77651
|
+
}
|
|
77652
|
+
if (value.kind === "IntValue") {
|
|
77653
|
+
return targetType.kind === "NamedType" && targetType.name.value === "Int";
|
|
77654
|
+
}
|
|
77655
|
+
if (value.kind === "FloatValue") {
|
|
77656
|
+
return targetType.kind === "NamedType" && targetType.name.value === "Float";
|
|
77657
|
+
}
|
|
77658
|
+
if (value.kind === "ObjectValue" && targetType.kind === "NamedType") {
|
|
77659
|
+
return true;
|
|
77660
|
+
}
|
|
77661
|
+
if (value.kind === "EnumValue" && targetType.kind === "NamedType") {
|
|
77662
|
+
const enumType = config2.schema.getType(targetType.name.value);
|
|
77663
|
+
if (!graphql25.isEnumType(enumType)) {
|
|
77664
|
+
return false;
|
|
77665
|
+
}
|
|
77666
|
+
return enumType.getValues().some((enumValue) => enumValue.value === value.value);
|
|
77667
|
+
}
|
|
77668
|
+
if (value.kind === "Variable") {
|
|
77669
|
+
return true;
|
|
77670
|
+
}
|
|
77671
|
+
return false;
|
|
77672
|
+
}
|
|
77632
77673
|
function paginateArgs(config2, filepath) {
|
|
77633
77674
|
return function(ctx) {
|
|
77634
77675
|
let alreadyPaginated = false;
|
|
@@ -78688,8 +78729,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
78688
78729
|
}
|
|
78689
78730
|
packageJSON.devDependencies = {
|
|
78690
78731
|
...packageJSON.devDependencies,
|
|
78691
|
-
houdini: "^1.0.
|
|
78692
|
-
"houdini-svelte": "^1.0.
|
|
78732
|
+
houdini: "^1.0.1",
|
|
78733
|
+
"houdini-svelte": "^1.0.1"
|
|
78693
78734
|
};
|
|
78694
78735
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
78695
78736
|
}
|
|
@@ -16,11 +16,12 @@ export declare function inlineFragmentArgs({ config, filepath, fragmentDefinitio
|
|
|
16
16
|
export declare function withArguments(config: Config, node: graphql.FragmentSpreadNode): graphql.ArgumentNode[];
|
|
17
17
|
export type FragmentArgument = {
|
|
18
18
|
name: string;
|
|
19
|
-
type:
|
|
19
|
+
type: graphql.TypeNode;
|
|
20
20
|
required: boolean;
|
|
21
21
|
defaultValue: graphql.ValueNode | null;
|
|
22
22
|
};
|
|
23
23
|
export declare function fragmentArguments(config: Config, filepath: string, definition: graphql.FragmentDefinitionNode): FragmentArgument[];
|
|
24
|
+
export declare function parseArgumentTypeString(input: string): graphql.TypeNode;
|
|
24
25
|
export declare function collectWithArguments(config: Config, filepath: string, node: graphql.FragmentSpreadNode, scope?: ValueMap | null): {
|
|
25
26
|
args: ValueMap | null;
|
|
26
27
|
hash: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as graphql from 'graphql';
|
|
2
2
|
import type { Config, Document } from '../../lib';
|
|
3
3
|
export default function typeCheck(config: Config, docs: Document[]): Promise<void>;
|
|
4
|
+
export declare function valueIsType(config: Config, value: graphql.ValueNode, targetType: graphql.TypeNode): boolean;
|
|
4
5
|
export declare function getAndVerifyNodeInterface(config: Config): graphql.GraphQLInterfaceType | null;
|