houdini 0.19.4 → 1.0.0-next.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 +337 -355
- package/build/cmd-esm/index.js +337 -355
- package/build/codegen/utils/index.d.ts +0 -1
- package/build/codegen-cjs/index.js +324 -311
- package/build/codegen-esm/index.js +324 -311
- package/build/lib/graphql.d.ts +14 -0
- package/build/lib-cjs/index.js +119 -43
- package/build/lib-esm/index.js +115 -42
- package/build/runtime/lib/scalars.d.ts +1 -0
- package/build/runtime/lib/types.d.ts +1 -1
- package/build/runtime-cjs/lib/scalars.d.ts +1 -0
- package/build/runtime-cjs/lib/scalars.js +24 -1
- package/build/runtime-cjs/lib/types.d.ts +1 -1
- package/build/runtime-esm/lib/scalars.d.ts +1 -0
- package/build/runtime-esm/lib/scalars.js +23 -1
- package/build/runtime-esm/lib/types.d.ts +1 -1
- package/build/test-cjs/index.js +322 -309
- package/build/test-esm/index.js +322 -309
- package/build/vite-cjs/index.js +324 -311
- package/build/vite-esm/index.js +324 -311
- package/package.json +1 -1
- package/build/codegen/utils/graphql.d.ts +0 -15
package/build/lib-esm/index.js
CHANGED
|
@@ -537,7 +537,7 @@ var require_kinds = __commonJS({
|
|
|
537
537
|
value: true
|
|
538
538
|
});
|
|
539
539
|
exports.Kind = void 0;
|
|
540
|
-
var
|
|
540
|
+
var Kind19 = Object.freeze({
|
|
541
541
|
NAME: "Name",
|
|
542
542
|
DOCUMENT: "Document",
|
|
543
543
|
OPERATION_DEFINITION: "OperationDefinition",
|
|
@@ -582,7 +582,7 @@ var require_kinds = __commonJS({
|
|
|
582
582
|
ENUM_TYPE_EXTENSION: "EnumTypeExtension",
|
|
583
583
|
INPUT_OBJECT_TYPE_EXTENSION: "InputObjectTypeExtension"
|
|
584
584
|
});
|
|
585
|
-
exports.Kind =
|
|
585
|
+
exports.Kind = Kind19;
|
|
586
586
|
}
|
|
587
587
|
});
|
|
588
588
|
|
|
@@ -3373,8 +3373,8 @@ var require_definition = __commonJS({
|
|
|
3373
3373
|
exports.assertCompositeType = assertCompositeType;
|
|
3374
3374
|
exports.isAbstractType = isAbstractType;
|
|
3375
3375
|
exports.assertAbstractType = assertAbstractType;
|
|
3376
|
-
exports.GraphQLList =
|
|
3377
|
-
exports.GraphQLNonNull =
|
|
3376
|
+
exports.GraphQLList = GraphQLList6;
|
|
3377
|
+
exports.GraphQLNonNull = GraphQLNonNull6;
|
|
3378
3378
|
exports.isWrappingType = isWrappingType;
|
|
3379
3379
|
exports.assertWrappingType = assertWrappingType;
|
|
3380
3380
|
exports.isNullableType = isNullableType;
|
|
@@ -3489,7 +3489,7 @@ var require_definition = __commonJS({
|
|
|
3489
3489
|
return type;
|
|
3490
3490
|
}
|
|
3491
3491
|
function isListType7(type) {
|
|
3492
|
-
return (0, _instanceOf.default)(type,
|
|
3492
|
+
return (0, _instanceOf.default)(type, GraphQLList6);
|
|
3493
3493
|
}
|
|
3494
3494
|
function assertListType(type) {
|
|
3495
3495
|
if (!isListType7(type)) {
|
|
@@ -3498,7 +3498,7 @@ var require_definition = __commonJS({
|
|
|
3498
3498
|
return type;
|
|
3499
3499
|
}
|
|
3500
3500
|
function isNonNullType6(type) {
|
|
3501
|
-
return (0, _instanceOf.default)(type,
|
|
3501
|
+
return (0, _instanceOf.default)(type, GraphQLNonNull6);
|
|
3502
3502
|
}
|
|
3503
3503
|
function assertNonNullType(type) {
|
|
3504
3504
|
if (!isNonNullType6(type)) {
|
|
@@ -3551,44 +3551,44 @@ var require_definition = __commonJS({
|
|
|
3551
3551
|
}
|
|
3552
3552
|
return type;
|
|
3553
3553
|
}
|
|
3554
|
-
function
|
|
3555
|
-
if (this instanceof
|
|
3554
|
+
function GraphQLList6(ofType) {
|
|
3555
|
+
if (this instanceof GraphQLList6) {
|
|
3556
3556
|
this.ofType = assertType(ofType);
|
|
3557
3557
|
} else {
|
|
3558
|
-
return new
|
|
3558
|
+
return new GraphQLList6(ofType);
|
|
3559
3559
|
}
|
|
3560
3560
|
}
|
|
3561
|
-
|
|
3561
|
+
GraphQLList6.prototype.toString = function toString() {
|
|
3562
3562
|
return "[" + String(this.ofType) + "]";
|
|
3563
3563
|
};
|
|
3564
|
-
|
|
3564
|
+
GraphQLList6.prototype.toJSON = function toJSON() {
|
|
3565
3565
|
return this.toString();
|
|
3566
3566
|
};
|
|
3567
|
-
Object.defineProperty(
|
|
3567
|
+
Object.defineProperty(GraphQLList6.prototype, _symbols.SYMBOL_TO_STRING_TAG, {
|
|
3568
3568
|
get: function get() {
|
|
3569
3569
|
return "GraphQLList";
|
|
3570
3570
|
}
|
|
3571
3571
|
});
|
|
3572
|
-
(0, _defineInspect.default)(
|
|
3573
|
-
function
|
|
3574
|
-
if (this instanceof
|
|
3572
|
+
(0, _defineInspect.default)(GraphQLList6);
|
|
3573
|
+
function GraphQLNonNull6(ofType) {
|
|
3574
|
+
if (this instanceof GraphQLNonNull6) {
|
|
3575
3575
|
this.ofType = assertNullableType(ofType);
|
|
3576
3576
|
} else {
|
|
3577
|
-
return new
|
|
3577
|
+
return new GraphQLNonNull6(ofType);
|
|
3578
3578
|
}
|
|
3579
3579
|
}
|
|
3580
|
-
|
|
3580
|
+
GraphQLNonNull6.prototype.toString = function toString() {
|
|
3581
3581
|
return String(this.ofType) + "!";
|
|
3582
3582
|
};
|
|
3583
|
-
|
|
3583
|
+
GraphQLNonNull6.prototype.toJSON = function toJSON() {
|
|
3584
3584
|
return this.toString();
|
|
3585
3585
|
};
|
|
3586
|
-
Object.defineProperty(
|
|
3586
|
+
Object.defineProperty(GraphQLNonNull6.prototype, _symbols.SYMBOL_TO_STRING_TAG, {
|
|
3587
3587
|
get: function get() {
|
|
3588
3588
|
return "GraphQLNonNull";
|
|
3589
3589
|
}
|
|
3590
3590
|
});
|
|
3591
|
-
(0, _defineInspect.default)(
|
|
3591
|
+
(0, _defineInspect.default)(GraphQLNonNull6);
|
|
3592
3592
|
function isWrappingType(type) {
|
|
3593
3593
|
return isListType7(type) || isNonNullType6(type);
|
|
3594
3594
|
}
|
|
@@ -14717,9 +14717,9 @@ var require_graphql2 = __commonJS({
|
|
|
14717
14717
|
}
|
|
14718
14718
|
});
|
|
14719
14719
|
|
|
14720
|
-
// ../../node_modules/.pnpm/minimatch@5.1.
|
|
14720
|
+
// ../../node_modules/.pnpm/minimatch@5.1.2/node_modules/minimatch/lib/path.js
|
|
14721
14721
|
var require_path = __commonJS({
|
|
14722
|
-
"../../node_modules/.pnpm/minimatch@5.1.
|
|
14722
|
+
"../../node_modules/.pnpm/minimatch@5.1.2/node_modules/minimatch/lib/path.js"(exports, module) {
|
|
14723
14723
|
var isWindows = typeof process === "object" && process && process.platform === "win32";
|
|
14724
14724
|
module.exports = isWindows ? { sep: "\\" } : { sep: "/" };
|
|
14725
14725
|
}
|
|
@@ -14936,9 +14936,9 @@ var require_brace_expansion = __commonJS({
|
|
|
14936
14936
|
}
|
|
14937
14937
|
});
|
|
14938
14938
|
|
|
14939
|
-
// ../../node_modules/.pnpm/minimatch@5.1.
|
|
14939
|
+
// ../../node_modules/.pnpm/minimatch@5.1.2/node_modules/minimatch/minimatch.js
|
|
14940
14940
|
var require_minimatch = __commonJS({
|
|
14941
|
-
"../../node_modules/.pnpm/minimatch@5.1.
|
|
14941
|
+
"../../node_modules/.pnpm/minimatch@5.1.2/node_modules/minimatch/minimatch.js"(exports, module) {
|
|
14942
14942
|
var minimatch2 = module.exports = (p, pattern, options = {}) => {
|
|
14943
14943
|
assertValidPattern(pattern);
|
|
14944
14944
|
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
@@ -15024,7 +15024,9 @@ var require_minimatch = __commonJS({
|
|
|
15024
15024
|
return list;
|
|
15025
15025
|
};
|
|
15026
15026
|
var globUnescape = (s2) => s2.replace(/\\(.)/g, "$1");
|
|
15027
|
+
var charUnescape = (s2) => s2.replace(/\\([^-\]])/g, "$1");
|
|
15027
15028
|
var regExpEscape = (s2) => s2.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
15029
|
+
var braExpEscape = (s2) => s2.replace(/[[\]\\]/g, "\\$&");
|
|
15028
15030
|
var Minimatch = class {
|
|
15029
15031
|
constructor(pattern, options) {
|
|
15030
15032
|
assertValidPattern(pattern);
|
|
@@ -15216,6 +15218,10 @@ var require_minimatch = __commonJS({
|
|
|
15216
15218
|
return false;
|
|
15217
15219
|
}
|
|
15218
15220
|
case "\\":
|
|
15221
|
+
if (inClass && pattern.charAt(i2 + 1) === "-") {
|
|
15222
|
+
re += c;
|
|
15223
|
+
continue;
|
|
15224
|
+
}
|
|
15219
15225
|
clearStateChar();
|
|
15220
15226
|
escaping = true;
|
|
15221
15227
|
continue;
|
|
@@ -15298,17 +15304,13 @@ var require_minimatch = __commonJS({
|
|
|
15298
15304
|
}
|
|
15299
15305
|
cs = pattern.substring(classStart + 1, i2);
|
|
15300
15306
|
try {
|
|
15301
|
-
RegExp("[" + cs + "]");
|
|
15307
|
+
RegExp("[" + braExpEscape(charUnescape(cs)) + "]");
|
|
15308
|
+
re += c;
|
|
15302
15309
|
} catch (er) {
|
|
15303
|
-
|
|
15304
|
-
re = re.substring(0, reClassStart) + "\\[" + sp[0] + "\\]";
|
|
15305
|
-
hasMagic = hasMagic || sp[1];
|
|
15306
|
-
inClass = false;
|
|
15307
|
-
continue;
|
|
15310
|
+
re = re.substring(0, reClassStart) + "(?:$.)";
|
|
15308
15311
|
}
|
|
15309
15312
|
hasMagic = true;
|
|
15310
15313
|
inClass = false;
|
|
15311
|
-
re += c;
|
|
15312
15314
|
continue;
|
|
15313
15315
|
default:
|
|
15314
15316
|
clearStateChar();
|
|
@@ -27484,9 +27486,9 @@ var init_multipart_parser = __esm({
|
|
|
27484
27486
|
}
|
|
27485
27487
|
});
|
|
27486
27488
|
|
|
27487
|
-
// ../../node_modules/.pnpm/@babel+parser@7.20.
|
|
27489
|
+
// ../../node_modules/.pnpm/@babel+parser@7.20.7/node_modules/@babel/parser/lib/index.js
|
|
27488
27490
|
var require_lib3 = __commonJS({
|
|
27489
|
-
"../../node_modules/.pnpm/@babel+parser@7.20.
|
|
27491
|
+
"../../node_modules/.pnpm/@babel+parser@7.20.7/node_modules/@babel/parser/lib/index.js"(exports) {
|
|
27490
27492
|
"use strict";
|
|
27491
27493
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27492
27494
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
@@ -27602,9 +27604,9 @@ var require_lib3 = __commonJS({
|
|
|
27602
27604
|
AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
|
|
27603
27605
|
AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
|
|
27604
27606
|
AwaitNotInAsyncFunction: "'await' is only allowed within async functions.",
|
|
27605
|
-
BadGetterArity: "A 'get'
|
|
27606
|
-
BadSetterArity: "A 'set'
|
|
27607
|
-
BadSetterRestParameter: "A 'set'
|
|
27607
|
+
BadGetterArity: "A 'get' accessor must not have any formal parameters.",
|
|
27608
|
+
BadSetterArity: "A 'set' accessor must have exactly one formal parameter.",
|
|
27609
|
+
BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.",
|
|
27608
27610
|
ConstructorClassField: "Classes may not have a field named 'constructor'.",
|
|
27609
27611
|
ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
|
|
27610
27612
|
ConstructorIsAccessor: "Class constructor may not be an accessor.",
|
|
@@ -31038,7 +31040,7 @@ var require_lib3 = __commonJS({
|
|
|
31038
31040
|
}
|
|
31039
31041
|
this.parser.raise(toParseError, origin);
|
|
31040
31042
|
}
|
|
31041
|
-
|
|
31043
|
+
recordArrowParameterBindingError(error, {
|
|
31042
31044
|
at: node
|
|
31043
31045
|
}) {
|
|
31044
31046
|
const {
|
|
@@ -34797,6 +34799,7 @@ var require_lib3 = __commonJS({
|
|
|
34797
34799
|
}) => `Property '${propertyName}' cannot have an initializer because it is marked abstract.`,
|
|
34798
34800
|
AccesorCannotDeclareThisParameter: "'get' and 'set' accessors cannot declare 'this' parameters.",
|
|
34799
34801
|
AccesorCannotHaveTypeParameters: "An accessor cannot have type parameters.",
|
|
34802
|
+
AccessorCannotBeOptional: "An 'accessor' property cannot be declared optional.",
|
|
34800
34803
|
ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier.",
|
|
34801
34804
|
ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier.",
|
|
34802
34805
|
ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference: "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",
|
|
@@ -36759,8 +36762,12 @@ var require_lib3 = __commonJS({
|
|
|
36759
36762
|
node.typeParameters = typeParameters;
|
|
36760
36763
|
}
|
|
36761
36764
|
parseClassPropertyAnnotation(node) {
|
|
36762
|
-
if (!node.optional
|
|
36763
|
-
|
|
36765
|
+
if (!node.optional) {
|
|
36766
|
+
if (this.eat(35)) {
|
|
36767
|
+
node.definite = true;
|
|
36768
|
+
} else if (this.eat(17)) {
|
|
36769
|
+
node.optional = true;
|
|
36770
|
+
}
|
|
36764
36771
|
}
|
|
36765
36772
|
const type = this.tsTryParseTypeAnnotation();
|
|
36766
36773
|
if (type)
|
|
@@ -36799,6 +36806,15 @@ var require_lib3 = __commonJS({
|
|
|
36799
36806
|
this.parseClassPropertyAnnotation(node);
|
|
36800
36807
|
return super.parseClassPrivateProperty(node);
|
|
36801
36808
|
}
|
|
36809
|
+
parseClassAccessorProperty(node) {
|
|
36810
|
+
this.parseClassPropertyAnnotation(node);
|
|
36811
|
+
if (node.optional) {
|
|
36812
|
+
this.raise(TSErrors.AccessorCannotBeOptional, {
|
|
36813
|
+
at: node
|
|
36814
|
+
});
|
|
36815
|
+
}
|
|
36816
|
+
return super.parseClassAccessorProperty(node);
|
|
36817
|
+
}
|
|
36802
36818
|
pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
|
|
36803
36819
|
const typeParameters = this.tsTryParseTypeParameters();
|
|
36804
36820
|
if (typeParameters && isConstructor) {
|
|
@@ -37009,7 +37025,7 @@ var require_lib3 = __commonJS({
|
|
|
37009
37025
|
case "TSNonNullExpression":
|
|
37010
37026
|
case "TSTypeAssertion":
|
|
37011
37027
|
if (isLHS) {
|
|
37012
|
-
this.expressionScope.
|
|
37028
|
+
this.expressionScope.recordArrowParameterBindingError(TSErrors.UnexpectedTypeCastInParameter, {
|
|
37013
37029
|
at: node
|
|
37014
37030
|
});
|
|
37015
37031
|
} else {
|
|
@@ -37716,7 +37732,7 @@ var require_lib3 = __commonJS({
|
|
|
37716
37732
|
parenthesized = unwrapParenthesizedExpression(node);
|
|
37717
37733
|
if (isLHS) {
|
|
37718
37734
|
if (parenthesized.type === "Identifier") {
|
|
37719
|
-
this.expressionScope.
|
|
37735
|
+
this.expressionScope.recordArrowParameterBindingError(Errors.InvalidParenthesizedAssignment, {
|
|
37720
37736
|
at: node
|
|
37721
37737
|
});
|
|
37722
37738
|
} else if (parenthesized.type !== "MemberExpression") {
|
|
@@ -65491,6 +65507,60 @@ function operation_requires_variables(operation) {
|
|
|
65491
65507
|
)
|
|
65492
65508
|
);
|
|
65493
65509
|
}
|
|
65510
|
+
function unwrapType(config, type, wrappers = []) {
|
|
65511
|
+
if (type.kind === "NonNullType") {
|
|
65512
|
+
return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
|
|
65513
|
+
}
|
|
65514
|
+
if (type instanceof graphql3.GraphQLNonNull) {
|
|
65515
|
+
return unwrapType(config, type.ofType, [TypeWrapper.NonNull, ...wrappers]);
|
|
65516
|
+
}
|
|
65517
|
+
if (wrappers[0] !== TypeWrapper.NonNull) {
|
|
65518
|
+
wrappers.unshift(TypeWrapper.Nullable);
|
|
65519
|
+
}
|
|
65520
|
+
if (type.kind === "ListType") {
|
|
65521
|
+
return unwrapType(config, type.type, [TypeWrapper.List, ...wrappers]);
|
|
65522
|
+
}
|
|
65523
|
+
if (type instanceof graphql3.GraphQLList) {
|
|
65524
|
+
return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
|
|
65525
|
+
}
|
|
65526
|
+
const namedType = config.schema.getType(type.name.value || type.name);
|
|
65527
|
+
if (!namedType) {
|
|
65528
|
+
throw new Error("Could not unwrap type: " + JSON.stringify(type));
|
|
65529
|
+
}
|
|
65530
|
+
return { type: namedType, wrappers };
|
|
65531
|
+
}
|
|
65532
|
+
function wrapType({
|
|
65533
|
+
type,
|
|
65534
|
+
wrappers
|
|
65535
|
+
}) {
|
|
65536
|
+
const head = wrappers[0];
|
|
65537
|
+
const tail = wrappers.slice(1);
|
|
65538
|
+
let kind = graphql3.Kind.NAMED_TYPE;
|
|
65539
|
+
if (head === TypeWrapper.List) {
|
|
65540
|
+
kind = graphql3.Kind.LIST_TYPE;
|
|
65541
|
+
} else if (head === TypeWrapper.NonNull) {
|
|
65542
|
+
kind = graphql3.Kind.NON_NULL_TYPE;
|
|
65543
|
+
}
|
|
65544
|
+
if (kind === "NamedType") {
|
|
65545
|
+
return {
|
|
65546
|
+
kind,
|
|
65547
|
+
name: {
|
|
65548
|
+
kind: graphql3.Kind.NAME,
|
|
65549
|
+
value: type.name
|
|
65550
|
+
}
|
|
65551
|
+
};
|
|
65552
|
+
}
|
|
65553
|
+
return {
|
|
65554
|
+
kind,
|
|
65555
|
+
type: wrapType({ type, wrappers: tail })
|
|
65556
|
+
};
|
|
65557
|
+
}
|
|
65558
|
+
var TypeWrapper = /* @__PURE__ */ ((TypeWrapper2) => {
|
|
65559
|
+
TypeWrapper2["Nullable"] = "Nullable";
|
|
65560
|
+
TypeWrapper2["List"] = "List";
|
|
65561
|
+
TypeWrapper2["NonNull"] = "NonNull";
|
|
65562
|
+
return TypeWrapper2;
|
|
65563
|
+
})(TypeWrapper || {});
|
|
65494
65564
|
|
|
65495
65565
|
// src/lib/parse.ts
|
|
65496
65566
|
var import_parser = __toESM(require_lib3(), 1);
|
|
@@ -65763,6 +65833,7 @@ export {
|
|
|
65763
65833
|
HoudiniError,
|
|
65764
65834
|
LogLevel,
|
|
65765
65835
|
RefetchUpdateMode,
|
|
65836
|
+
TypeWrapper,
|
|
65766
65837
|
cleanupFiles,
|
|
65767
65838
|
computeID,
|
|
65768
65839
|
defaultConfigValues,
|
|
@@ -65789,7 +65860,9 @@ export {
|
|
|
65789
65860
|
readConfigFile,
|
|
65790
65861
|
runPipeline,
|
|
65791
65862
|
setMockConfig,
|
|
65792
|
-
siteURL
|
|
65863
|
+
siteURL,
|
|
65864
|
+
unwrapType,
|
|
65865
|
+
wrapType
|
|
65793
65866
|
};
|
|
65794
65867
|
/*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
|
65795
65868
|
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
|
@@ -11,3 +11,4 @@ export declare function marshalInputs<T>({ artifact, input, rootType, }: {
|
|
|
11
11
|
}): Promise<{} | null | undefined>;
|
|
12
12
|
export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data: any): {} | null | undefined;
|
|
13
13
|
export declare function isScalar(config: ConfigFile, type: string): boolean;
|
|
14
|
+
export declare function parseScalar(config: ConfigFile, type: string, value: string): string | number | boolean;
|
|
@@ -11,3 +11,4 @@ export declare function marshalInputs<T>({ artifact, input, rootType, }: {
|
|
|
11
11
|
}): Promise<{} | null | undefined>;
|
|
12
12
|
export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data: any): {} | null | undefined;
|
|
13
13
|
export declare function isScalar(config: ConfigFile, type: string): boolean;
|
|
14
|
+
export declare function parseScalar(config: ConfigFile, type: string, value: string): string | number | boolean;
|
|
@@ -21,6 +21,7 @@ __export(scalars_exports, {
|
|
|
21
21
|
isScalar: () => isScalar,
|
|
22
22
|
marshalInputs: () => marshalInputs,
|
|
23
23
|
marshalSelection: () => marshalSelection,
|
|
24
|
+
parseScalar: () => parseScalar,
|
|
24
25
|
unmarshalSelection: () => unmarshalSelection
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(scalars_exports);
|
|
@@ -129,7 +130,7 @@ function unmarshalSelection(config, selection, data) {
|
|
|
129
130
|
return [fieldName, value];
|
|
130
131
|
}
|
|
131
132
|
if (config.scalars?.[type]?.marshal) {
|
|
132
|
-
const unmarshalFn = config.scalars[type]
|
|
133
|
+
const unmarshalFn = config.scalars[type]?.unmarshal;
|
|
133
134
|
if (!unmarshalFn) {
|
|
134
135
|
throw new Error(
|
|
135
136
|
`scalar type ${type} is missing an \`unmarshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
|
|
@@ -147,10 +148,32 @@ function unmarshalSelection(config, selection, data) {
|
|
|
147
148
|
function isScalar(config, type) {
|
|
148
149
|
return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(config.scalars || {})).includes(type);
|
|
149
150
|
}
|
|
151
|
+
function parseScalar(config, type, value) {
|
|
152
|
+
if (type === "Boolean") {
|
|
153
|
+
return value === "true";
|
|
154
|
+
}
|
|
155
|
+
if (type === "ID") {
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
if (type === "String") {
|
|
159
|
+
return value;
|
|
160
|
+
}
|
|
161
|
+
if (type === "Int") {
|
|
162
|
+
return parseInt(value, 10);
|
|
163
|
+
}
|
|
164
|
+
if (type === "Float") {
|
|
165
|
+
return parseFloat(value);
|
|
166
|
+
}
|
|
167
|
+
if (config.scalars?.[type]?.marshal) {
|
|
168
|
+
return config.scalars[type]?.marshal(value);
|
|
169
|
+
}
|
|
170
|
+
return value;
|
|
171
|
+
}
|
|
150
172
|
// Annotate the CommonJS export names for ESM import in node:
|
|
151
173
|
0 && (module.exports = {
|
|
152
174
|
isScalar,
|
|
153
175
|
marshalInputs,
|
|
154
176
|
marshalSelection,
|
|
177
|
+
parseScalar,
|
|
155
178
|
unmarshalSelection
|
|
156
179
|
});
|
|
@@ -11,3 +11,4 @@ export declare function marshalInputs<T>({ artifact, input, rootType, }: {
|
|
|
11
11
|
}): Promise<{} | null | undefined>;
|
|
12
12
|
export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data: any): {} | null | undefined;
|
|
13
13
|
export declare function isScalar(config: ConfigFile, type: string): boolean;
|
|
14
|
+
export declare function parseScalar(config: ConfigFile, type: string, value: string): string | number | boolean;
|
|
@@ -103,7 +103,7 @@ function unmarshalSelection(config, selection, data) {
|
|
|
103
103
|
return [fieldName, value];
|
|
104
104
|
}
|
|
105
105
|
if (config.scalars?.[type]?.marshal) {
|
|
106
|
-
const unmarshalFn = config.scalars[type]
|
|
106
|
+
const unmarshalFn = config.scalars[type]?.unmarshal;
|
|
107
107
|
if (!unmarshalFn) {
|
|
108
108
|
throw new Error(
|
|
109
109
|
`scalar type ${type} is missing an \`unmarshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
|
|
@@ -121,9 +121,31 @@ function unmarshalSelection(config, selection, data) {
|
|
|
121
121
|
function isScalar(config, type) {
|
|
122
122
|
return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(config.scalars || {})).includes(type);
|
|
123
123
|
}
|
|
124
|
+
function parseScalar(config, type, value) {
|
|
125
|
+
if (type === "Boolean") {
|
|
126
|
+
return value === "true";
|
|
127
|
+
}
|
|
128
|
+
if (type === "ID") {
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
if (type === "String") {
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
if (type === "Int") {
|
|
135
|
+
return parseInt(value, 10);
|
|
136
|
+
}
|
|
137
|
+
if (type === "Float") {
|
|
138
|
+
return parseFloat(value);
|
|
139
|
+
}
|
|
140
|
+
if (config.scalars?.[type]?.marshal) {
|
|
141
|
+
return config.scalars[type]?.marshal(value);
|
|
142
|
+
}
|
|
143
|
+
return value;
|
|
144
|
+
}
|
|
124
145
|
export {
|
|
125
146
|
isScalar,
|
|
126
147
|
marshalInputs,
|
|
127
148
|
marshalSelection,
|
|
149
|
+
parseScalar,
|
|
128
150
|
unmarshalSelection
|
|
129
151
|
};
|