houdini 0.17.13 → 0.18.0
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 +438 -201
- package/build/cmd-esm/index.js +438 -201
- package/build/codegen/utils/flattenSelections.d.ts +3 -1
- package/build/codegen-cjs/index.js +405 -180
- package/build/codegen-esm/index.js +405 -180
- package/build/lib/config.d.ts +8 -3
- package/build/lib-cjs/index.js +141 -81
- package/build/lib-esm/index.js +141 -81
- package/build/runtime/cache/subscription.d.ts +3 -3
- package/build/runtime/lib/config.d.ts +2 -1
- package/build/runtime/lib/scalars.d.ts +2 -2
- package/build/runtime/lib/selection.d.ts +2 -0
- package/build/runtime/lib/types.d.ts +26 -16
- package/build/runtime-cjs/cache/cache.js +38 -23
- package/build/runtime-cjs/cache/lists.js +40 -26
- package/build/runtime-cjs/cache/subscription.d.ts +3 -3
- package/build/runtime-cjs/cache/subscription.js +23 -21
- package/build/runtime-cjs/lib/config.d.ts +2 -1
- package/build/runtime-cjs/lib/scalars.d.ts +2 -2
- package/build/runtime-cjs/lib/scalars.js +9 -6
- package/build/runtime-cjs/lib/selection.d.ts +2 -0
- package/build/runtime-cjs/lib/selection.js +39 -0
- package/build/runtime-cjs/lib/types.d.ts +26 -16
- package/build/runtime-esm/cache/cache.js +38 -23
- package/build/runtime-esm/cache/lists.js +40 -26
- package/build/runtime-esm/cache/subscription.d.ts +3 -3
- package/build/runtime-esm/cache/subscription.js +23 -21
- package/build/runtime-esm/lib/config.d.ts +2 -1
- package/build/runtime-esm/lib/scalars.d.ts +2 -2
- package/build/runtime-esm/lib/scalars.js +9 -6
- package/build/runtime-esm/lib/selection.d.ts +2 -0
- package/build/runtime-esm/lib/selection.js +15 -0
- package/build/runtime-esm/lib/types.d.ts +26 -16
- package/build/test/index.d.ts +1 -2
- package/build/test-cjs/index.js +485 -195
- package/build/test-esm/index.js +485 -195
- package/build/vite-cjs/index.js +438 -193
- package/build/vite-esm/index.js +438 -193
- package/package.json +2 -2
- package/build/runtime-cjs/cache/tests/availability.test.js +0 -357
- package/build/runtime-cjs/cache/tests/gc.test.js +0 -271
- package/build/runtime-cjs/cache/tests/keys.test.js +0 -34
- package/build/runtime-cjs/cache/tests/list.test.js +0 -3390
- package/build/runtime-cjs/cache/tests/readwrite.test.js +0 -1076
- package/build/runtime-cjs/cache/tests/scalars.test.js +0 -181
- package/build/runtime-cjs/cache/tests/storage.test.js +0 -280
- package/build/runtime-cjs/cache/tests/subscriptions.test.js +0 -1469
- package/build/runtime-cjs/lib/scalars.test.js +0 -736
- package/build/runtime-esm/cache/tests/availability.test.js +0 -356
- package/build/runtime-esm/cache/tests/gc.test.js +0 -270
- package/build/runtime-esm/cache/tests/keys.test.js +0 -33
- package/build/runtime-esm/cache/tests/list.test.js +0 -3389
- package/build/runtime-esm/cache/tests/readwrite.test.js +0 -1075
- package/build/runtime-esm/cache/tests/scalars.test.js +0 -180
- package/build/runtime-esm/cache/tests/storage.test.js +0 -279
- package/build/runtime-esm/cache/tests/subscriptions.test.js +0 -1468
- package/build/runtime-esm/lib/scalars.test.js +0 -735
|
@@ -3345,7 +3345,7 @@ var require_definition = __commonJS({
|
|
|
3345
3345
|
exports.assertObjectType = assertObjectType;
|
|
3346
3346
|
exports.isInterfaceType = isInterfaceType6;
|
|
3347
3347
|
exports.assertInterfaceType = assertInterfaceType;
|
|
3348
|
-
exports.isUnionType =
|
|
3348
|
+
exports.isUnionType = isUnionType7;
|
|
3349
3349
|
exports.assertUnionType = assertUnionType;
|
|
3350
3350
|
exports.isEnumType = isEnumType4;
|
|
3351
3351
|
exports.assertEnumType = assertEnumType;
|
|
@@ -3363,7 +3363,7 @@ var require_definition = __commonJS({
|
|
|
3363
3363
|
exports.assertLeafType = assertLeafType;
|
|
3364
3364
|
exports.isCompositeType = isCompositeType;
|
|
3365
3365
|
exports.assertCompositeType = assertCompositeType;
|
|
3366
|
-
exports.isAbstractType =
|
|
3366
|
+
exports.isAbstractType = isAbstractType2;
|
|
3367
3367
|
exports.assertAbstractType = assertAbstractType;
|
|
3368
3368
|
exports.GraphQLList = GraphQLList2;
|
|
3369
3369
|
exports.GraphQLNonNull = GraphQLNonNull2;
|
|
@@ -3418,7 +3418,7 @@ var require_definition = __commonJS({
|
|
|
3418
3418
|
return Constructor;
|
|
3419
3419
|
}
|
|
3420
3420
|
function isType(type) {
|
|
3421
|
-
return isScalarType6(type) || isObjectType2(type) || isInterfaceType6(type) ||
|
|
3421
|
+
return isScalarType6(type) || isObjectType2(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType4(type) || isInputObjectType(type) || isListType3(type) || isNonNullType6(type);
|
|
3422
3422
|
}
|
|
3423
3423
|
function assertType(type) {
|
|
3424
3424
|
if (!isType(type)) {
|
|
@@ -3453,11 +3453,11 @@ var require_definition = __commonJS({
|
|
|
3453
3453
|
}
|
|
3454
3454
|
return type;
|
|
3455
3455
|
}
|
|
3456
|
-
function
|
|
3456
|
+
function isUnionType7(type) {
|
|
3457
3457
|
return (0, _instanceOf.default)(type, GraphQLUnionType);
|
|
3458
3458
|
}
|
|
3459
3459
|
function assertUnionType(type) {
|
|
3460
|
-
if (!
|
|
3460
|
+
if (!isUnionType7(type)) {
|
|
3461
3461
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Union type."));
|
|
3462
3462
|
}
|
|
3463
3463
|
return type;
|
|
@@ -3508,7 +3508,7 @@ var require_definition = __commonJS({
|
|
|
3508
3508
|
return type;
|
|
3509
3509
|
}
|
|
3510
3510
|
function isOutputType(type) {
|
|
3511
|
-
return isScalarType6(type) || isObjectType2(type) || isInterfaceType6(type) ||
|
|
3511
|
+
return isScalarType6(type) || isObjectType2(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType4(type) || isWrappingType(type) && isOutputType(type.ofType);
|
|
3512
3512
|
}
|
|
3513
3513
|
function assertOutputType(type) {
|
|
3514
3514
|
if (!isOutputType(type)) {
|
|
@@ -3526,7 +3526,7 @@ var require_definition = __commonJS({
|
|
|
3526
3526
|
return type;
|
|
3527
3527
|
}
|
|
3528
3528
|
function isCompositeType(type) {
|
|
3529
|
-
return isObjectType2(type) || isInterfaceType6(type) ||
|
|
3529
|
+
return isObjectType2(type) || isInterfaceType6(type) || isUnionType7(type);
|
|
3530
3530
|
}
|
|
3531
3531
|
function assertCompositeType(type) {
|
|
3532
3532
|
if (!isCompositeType(type)) {
|
|
@@ -3534,11 +3534,11 @@ var require_definition = __commonJS({
|
|
|
3534
3534
|
}
|
|
3535
3535
|
return type;
|
|
3536
3536
|
}
|
|
3537
|
-
function
|
|
3538
|
-
return isInterfaceType6(type) ||
|
|
3537
|
+
function isAbstractType2(type) {
|
|
3538
|
+
return isInterfaceType6(type) || isUnionType7(type);
|
|
3539
3539
|
}
|
|
3540
3540
|
function assertAbstractType(type) {
|
|
3541
|
-
if (!
|
|
3541
|
+
if (!isAbstractType2(type)) {
|
|
3542
3542
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
|
|
3543
3543
|
}
|
|
3544
3544
|
return type;
|
|
@@ -3605,7 +3605,7 @@ var require_definition = __commonJS({
|
|
|
3605
3605
|
}
|
|
3606
3606
|
}
|
|
3607
3607
|
function isNamedType(type) {
|
|
3608
|
-
return isScalarType6(type) || isObjectType2(type) || isInterfaceType6(type) ||
|
|
3608
|
+
return isScalarType6(type) || isObjectType2(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType4(type) || isInputObjectType(type);
|
|
3609
3609
|
}
|
|
3610
3610
|
function assertNamedType(type) {
|
|
3611
3611
|
if (!isNamedType(type)) {
|
|
@@ -53462,6 +53462,20 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
|
53462
53462
|
return true;
|
|
53463
53463
|
}
|
|
53464
53464
|
|
|
53465
|
+
// src/runtime/lib/selection.ts
|
|
53466
|
+
function getFieldsForType(selection2, __typename) {
|
|
53467
|
+
let targetSelection = selection2.fields || {};
|
|
53468
|
+
if (selection2.abstractFields && __typename) {
|
|
53469
|
+
const mappedType = selection2.abstractFields.typeMap[__typename];
|
|
53470
|
+
if (mappedType) {
|
|
53471
|
+
targetSelection = selection2.abstractFields.fields[mappedType];
|
|
53472
|
+
} else if (selection2.abstractFields.fields[__typename]) {
|
|
53473
|
+
targetSelection = selection2.abstractFields.fields[__typename];
|
|
53474
|
+
}
|
|
53475
|
+
}
|
|
53476
|
+
return targetSelection;
|
|
53477
|
+
}
|
|
53478
|
+
|
|
53465
53479
|
// src/runtime/cache/gc.ts
|
|
53466
53480
|
var GarbageCollector = class {
|
|
53467
53481
|
cache;
|
|
@@ -53684,23 +53698,32 @@ var List = class {
|
|
|
53684
53698
|
let insertData = data;
|
|
53685
53699
|
if (this.connection) {
|
|
53686
53700
|
insertSelection = {
|
|
53687
|
-
|
|
53688
|
-
|
|
53689
|
-
|
|
53690
|
-
|
|
53691
|
-
|
|
53692
|
-
keyRaw: "edges",
|
|
53693
|
-
type: "ConnectionEdge",
|
|
53694
|
-
update: where === "first" ? "prepend" : "append",
|
|
53701
|
+
fields: {
|
|
53702
|
+
newEntry: {
|
|
53703
|
+
keyRaw: this.key,
|
|
53704
|
+
type: "Connection",
|
|
53705
|
+
selection: {
|
|
53695
53706
|
fields: {
|
|
53696
|
-
|
|
53697
|
-
|
|
53698
|
-
|
|
53699
|
-
|
|
53700
|
-
|
|
53701
|
-
|
|
53702
|
-
|
|
53703
|
-
|
|
53707
|
+
edges: {
|
|
53708
|
+
keyRaw: "edges",
|
|
53709
|
+
type: "ConnectionEdge",
|
|
53710
|
+
update: where === "first" ? "prepend" : "append",
|
|
53711
|
+
selection: {
|
|
53712
|
+
fields: {
|
|
53713
|
+
node: {
|
|
53714
|
+
type: listType,
|
|
53715
|
+
keyRaw: "node",
|
|
53716
|
+
selection: {
|
|
53717
|
+
...selection2,
|
|
53718
|
+
fields: {
|
|
53719
|
+
...selection2.fields,
|
|
53720
|
+
__typename: {
|
|
53721
|
+
keyRaw: "__typename",
|
|
53722
|
+
type: "String"
|
|
53723
|
+
}
|
|
53724
|
+
}
|
|
53725
|
+
}
|
|
53726
|
+
}
|
|
53704
53727
|
}
|
|
53705
53728
|
}
|
|
53706
53729
|
}
|
|
@@ -53716,15 +53739,20 @@ var List = class {
|
|
|
53716
53739
|
};
|
|
53717
53740
|
} else {
|
|
53718
53741
|
insertSelection = {
|
|
53719
|
-
|
|
53720
|
-
|
|
53721
|
-
|
|
53722
|
-
|
|
53723
|
-
|
|
53724
|
-
|
|
53725
|
-
|
|
53726
|
-
|
|
53727
|
-
|
|
53742
|
+
fields: {
|
|
53743
|
+
newEntries: {
|
|
53744
|
+
keyRaw: this.key,
|
|
53745
|
+
type: listType,
|
|
53746
|
+
update: where === "first" ? "prepend" : "append",
|
|
53747
|
+
selection: {
|
|
53748
|
+
...selection2,
|
|
53749
|
+
fields: {
|
|
53750
|
+
...selection2.fields,
|
|
53751
|
+
__typename: {
|
|
53752
|
+
keyRaw: "__typename",
|
|
53753
|
+
type: "String"
|
|
53754
|
+
}
|
|
53755
|
+
}
|
|
53728
53756
|
}
|
|
53729
53757
|
}
|
|
53730
53758
|
}
|
|
@@ -53784,7 +53812,7 @@ var List = class {
|
|
|
53784
53812
|
const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
|
|
53785
53813
|
this.cache._internal_unstable.subscriptions.remove(
|
|
53786
53814
|
targetID,
|
|
53787
|
-
this.connection ? this.selection.edges.
|
|
53815
|
+
this.connection ? this.selection.fields.edges.selection : this.selection,
|
|
53788
53816
|
subscribers,
|
|
53789
53817
|
variables
|
|
53790
53818
|
);
|
|
@@ -54273,18 +54301,20 @@ var InMemorySubscriptions = class {
|
|
|
54273
54301
|
variables,
|
|
54274
54302
|
parentType
|
|
54275
54303
|
}) {
|
|
54276
|
-
|
|
54277
|
-
|
|
54304
|
+
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
54305
|
+
let targetSelection = getFieldsForType(selection2, __typename);
|
|
54306
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
54307
|
+
const { keyRaw, selection: innerSelection, type } = fieldSelection;
|
|
54278
54308
|
const key = evaluateKey(keyRaw, variables);
|
|
54279
54309
|
this.addFieldSubscription({
|
|
54280
54310
|
id: parent,
|
|
54281
54311
|
key,
|
|
54282
|
-
|
|
54312
|
+
field: fieldSelection,
|
|
54283
54313
|
spec,
|
|
54284
54314
|
parentType: parentType || spec.rootType,
|
|
54285
54315
|
variables
|
|
54286
54316
|
});
|
|
54287
|
-
if (
|
|
54317
|
+
if (innerSelection) {
|
|
54288
54318
|
const { value: linkedRecord } = this.cache._internal_unstable.storage.get(
|
|
54289
54319
|
parent,
|
|
54290
54320
|
key
|
|
@@ -54297,7 +54327,7 @@ var InMemorySubscriptions = class {
|
|
|
54297
54327
|
this.add({
|
|
54298
54328
|
parent: child,
|
|
54299
54329
|
spec,
|
|
54300
|
-
selection:
|
|
54330
|
+
selection: innerSelection,
|
|
54301
54331
|
variables,
|
|
54302
54332
|
parentType: type
|
|
54303
54333
|
});
|
|
@@ -54308,7 +54338,7 @@ var InMemorySubscriptions = class {
|
|
|
54308
54338
|
addFieldSubscription({
|
|
54309
54339
|
id,
|
|
54310
54340
|
key,
|
|
54311
|
-
|
|
54341
|
+
field,
|
|
54312
54342
|
spec,
|
|
54313
54343
|
parentType,
|
|
54314
54344
|
variables
|
|
@@ -54335,8 +54365,8 @@ var InMemorySubscriptions = class {
|
|
|
54335
54365
|
const counts = this.referenceCounts[id][key];
|
|
54336
54366
|
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
54337
54367
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
54338
|
-
const {
|
|
54339
|
-
if (
|
|
54368
|
+
const { selection: selection2, list, filters } = field;
|
|
54369
|
+
if (selection2 && list) {
|
|
54340
54370
|
this.cache._internal_unstable.lists.add({
|
|
54341
54371
|
name: list.name,
|
|
54342
54372
|
connection: list.connection,
|
|
@@ -54344,7 +54374,7 @@ var InMemorySubscriptions = class {
|
|
|
54344
54374
|
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
54345
54375
|
listType: list.type,
|
|
54346
54376
|
key,
|
|
54347
|
-
selection:
|
|
54377
|
+
selection: selection2,
|
|
54348
54378
|
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
54349
54379
|
return {
|
|
54350
54380
|
...acc,
|
|
@@ -54361,20 +54391,21 @@ var InMemorySubscriptions = class {
|
|
|
54361
54391
|
subscribers,
|
|
54362
54392
|
parentType
|
|
54363
54393
|
}) {
|
|
54364
|
-
|
|
54365
|
-
|
|
54394
|
+
let targetSelection = getFieldsForType(selection2, parentType);
|
|
54395
|
+
for (const fieldSelection of Object.values(targetSelection)) {
|
|
54396
|
+
const { type: linkedType, keyRaw, selection: innerSelection } = fieldSelection;
|
|
54366
54397
|
const key = evaluateKey(keyRaw, variables);
|
|
54367
54398
|
for (const spec of subscribers) {
|
|
54368
54399
|
this.addFieldSubscription({
|
|
54369
54400
|
id: parent,
|
|
54370
54401
|
key,
|
|
54371
|
-
|
|
54402
|
+
field: fieldSelection,
|
|
54372
54403
|
spec,
|
|
54373
54404
|
parentType,
|
|
54374
54405
|
variables
|
|
54375
54406
|
});
|
|
54376
54407
|
}
|
|
54377
|
-
if (
|
|
54408
|
+
if (innerSelection) {
|
|
54378
54409
|
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
54379
54410
|
const children = !Array.isArray(link) ? [link] : flattenList(link);
|
|
54380
54411
|
for (const linkedRecord of children) {
|
|
@@ -54383,7 +54414,7 @@ var InMemorySubscriptions = class {
|
|
|
54383
54414
|
}
|
|
54384
54415
|
this.addMany({
|
|
54385
54416
|
parent: linkedRecord,
|
|
54386
|
-
selection:
|
|
54417
|
+
selection: innerSelection,
|
|
54387
54418
|
variables,
|
|
54388
54419
|
subscribers,
|
|
54389
54420
|
parentType: linkedType
|
|
@@ -54395,22 +54426,20 @@ var InMemorySubscriptions = class {
|
|
|
54395
54426
|
get(id, field) {
|
|
54396
54427
|
return this.subscribers[id]?.[field] || [];
|
|
54397
54428
|
}
|
|
54398
|
-
remove(id,
|
|
54429
|
+
remove(id, selection2, targets, variables, visited = []) {
|
|
54399
54430
|
visited.push(id);
|
|
54400
54431
|
const linkedIDs = [];
|
|
54401
|
-
for (const
|
|
54402
|
-
const key = evaluateKey(
|
|
54432
|
+
for (const fieldSelection of Object.values(selection2.fields || {})) {
|
|
54433
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
54403
54434
|
this.removeSubscribers(id, key, targets);
|
|
54404
|
-
if (!
|
|
54435
|
+
if (!fieldSelection.selection?.fields) {
|
|
54405
54436
|
continue;
|
|
54406
54437
|
}
|
|
54407
|
-
if (selection2.list) {
|
|
54408
|
-
}
|
|
54409
54438
|
const { value: previousValue } = this.cache._internal_unstable.storage.get(id, key);
|
|
54410
54439
|
const links = !Array.isArray(previousValue) ? [previousValue] : flattenList(previousValue);
|
|
54411
54440
|
for (const link of links) {
|
|
54412
54441
|
if (link !== null) {
|
|
54413
|
-
linkedIDs.push([link,
|
|
54442
|
+
linkedIDs.push([link, fieldSelection.selection || {}]);
|
|
54414
54443
|
}
|
|
54415
54444
|
}
|
|
54416
54445
|
}
|
|
@@ -54588,8 +54617,9 @@ var CacheInternal = class {
|
|
|
54588
54617
|
if (this._disabled) {
|
|
54589
54618
|
return [];
|
|
54590
54619
|
}
|
|
54620
|
+
let targetSelection = getFieldsForType(selection2, data["__typename"]);
|
|
54591
54621
|
for (const [field, value] of Object.entries(data)) {
|
|
54592
|
-
if (!selection2 || !
|
|
54622
|
+
if (!selection2 || !targetSelection[field]) {
|
|
54593
54623
|
throw new Error(
|
|
54594
54624
|
"Could not find field listing in selection for " + field + " @ " + JSON.stringify(selection2)
|
|
54595
54625
|
);
|
|
@@ -54597,11 +54627,11 @@ var CacheInternal = class {
|
|
|
54597
54627
|
let {
|
|
54598
54628
|
type: linkedType,
|
|
54599
54629
|
keyRaw,
|
|
54600
|
-
|
|
54630
|
+
selection: fieldSelection,
|
|
54601
54631
|
operations,
|
|
54602
54632
|
abstract: isAbstract,
|
|
54603
54633
|
update
|
|
54604
|
-
} =
|
|
54634
|
+
} = targetSelection[field];
|
|
54605
54635
|
const key = evaluateKey(keyRaw, variables);
|
|
54606
54636
|
const currentSubscribers = this.subscriptions.get(parent, key);
|
|
54607
54637
|
const { value: previousValue, displayLayers } = this.storage.get(parent, key);
|
|
@@ -54609,7 +54639,7 @@ var CacheInternal = class {
|
|
|
54609
54639
|
if (displayLayer) {
|
|
54610
54640
|
this.lifetimes.resetLifetime(parent, key);
|
|
54611
54641
|
}
|
|
54612
|
-
if (!
|
|
54642
|
+
if (!fieldSelection) {
|
|
54613
54643
|
let newValue = value;
|
|
54614
54644
|
if (Array.isArray(value) && applyUpdates && update) {
|
|
54615
54645
|
if (update === "append") {
|
|
@@ -54629,7 +54659,7 @@ var CacheInternal = class {
|
|
|
54629
54659
|
}
|
|
54630
54660
|
const previousLinks = flattenList([previousValue]);
|
|
54631
54661
|
for (const link of previousLinks) {
|
|
54632
|
-
this.subscriptions.remove(link,
|
|
54662
|
+
this.subscriptions.remove(link, fieldSelection, currentSubscribers, variables);
|
|
54633
54663
|
}
|
|
54634
54664
|
layer.writeLink(parent, key, null);
|
|
54635
54665
|
toNotify.push(...currentSubscribers);
|
|
@@ -54655,14 +54685,14 @@ var CacheInternal = class {
|
|
|
54655
54685
|
if (previousValue && typeof previousValue === "string") {
|
|
54656
54686
|
this.subscriptions.remove(
|
|
54657
54687
|
previousValue,
|
|
54658
|
-
|
|
54688
|
+
fieldSelection,
|
|
54659
54689
|
currentSubscribers,
|
|
54660
54690
|
variables
|
|
54661
54691
|
);
|
|
54662
54692
|
}
|
|
54663
54693
|
this.subscriptions.addMany({
|
|
54664
54694
|
parent: linkedID,
|
|
54665
|
-
selection:
|
|
54695
|
+
selection: fieldSelection,
|
|
54666
54696
|
subscribers: currentSubscribers,
|
|
54667
54697
|
variables,
|
|
54668
54698
|
parentType: linkedType
|
|
@@ -54672,14 +54702,14 @@ var CacheInternal = class {
|
|
|
54672
54702
|
if (linkedID) {
|
|
54673
54703
|
this.writeSelection({
|
|
54674
54704
|
root,
|
|
54675
|
-
selection:
|
|
54705
|
+
selection: fieldSelection,
|
|
54676
54706
|
parent: linkedID,
|
|
54677
54707
|
data: value,
|
|
54678
54708
|
variables,
|
|
54679
54709
|
toNotify,
|
|
54680
54710
|
applyUpdates,
|
|
54681
54711
|
layer,
|
|
54682
|
-
forceNotify
|
|
54712
|
+
forceNotify
|
|
54683
54713
|
});
|
|
54684
54714
|
}
|
|
54685
54715
|
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || Array.isArray(previousValue))) {
|
|
@@ -54708,7 +54738,7 @@ var CacheInternal = class {
|
|
|
54708
54738
|
key,
|
|
54709
54739
|
linkedType,
|
|
54710
54740
|
variables,
|
|
54711
|
-
fields,
|
|
54741
|
+
fields: fieldSelection,
|
|
54712
54742
|
layer,
|
|
54713
54743
|
forceNotify
|
|
54714
54744
|
});
|
|
@@ -54758,7 +54788,7 @@ var CacheInternal = class {
|
|
|
54758
54788
|
if (linkedIDs.includes(lostID) || !lostID) {
|
|
54759
54789
|
continue;
|
|
54760
54790
|
}
|
|
54761
|
-
this.subscriptions.remove(lostID,
|
|
54791
|
+
this.subscriptions.remove(lostID, fieldSelection, currentSubscribers, variables);
|
|
54762
54792
|
}
|
|
54763
54793
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
54764
54794
|
layer.writeLink(parent, key, linkedIDs);
|
|
@@ -54769,7 +54799,7 @@ var CacheInternal = class {
|
|
|
54769
54799
|
}
|
|
54770
54800
|
this.subscriptions.addMany({
|
|
54771
54801
|
parent: id,
|
|
54772
|
-
selection:
|
|
54802
|
+
selection: fieldSelection,
|
|
54773
54803
|
subscribers: currentSubscribers,
|
|
54774
54804
|
variables,
|
|
54775
54805
|
parentType: linkedType
|
|
@@ -54794,9 +54824,14 @@ var CacheInternal = class {
|
|
|
54794
54824
|
}
|
|
54795
54825
|
const targets = Array.isArray(value) ? value : [value];
|
|
54796
54826
|
for (const target of targets) {
|
|
54797
|
-
if (operation.action === "insert" && target instanceof Object &&
|
|
54798
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
54799
|
-
|
|
54827
|
+
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
54828
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
54829
|
+
fieldSelection,
|
|
54830
|
+
target,
|
|
54831
|
+
variables,
|
|
54832
|
+
operation.position || "last"
|
|
54833
|
+
);
|
|
54834
|
+
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
54800
54835
|
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
54801
54836
|
} else if (operation.action === "delete" && operation.type) {
|
|
54802
54837
|
if (typeof target !== "string") {
|
|
@@ -54807,8 +54842,13 @@ var CacheInternal = class {
|
|
|
54807
54842
|
continue;
|
|
54808
54843
|
}
|
|
54809
54844
|
this.cache.delete(targetID);
|
|
54810
|
-
} else if (operation.action === "toggle" && target instanceof Object &&
|
|
54811
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
54845
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
54846
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
54847
|
+
fieldSelection,
|
|
54848
|
+
target,
|
|
54849
|
+
variables,
|
|
54850
|
+
operation.position || "last"
|
|
54851
|
+
);
|
|
54812
54852
|
}
|
|
54813
54853
|
}
|
|
54814
54854
|
}
|
|
@@ -54828,9 +54868,12 @@ var CacheInternal = class {
|
|
|
54828
54868
|
let hasData = false;
|
|
54829
54869
|
let partial = false;
|
|
54830
54870
|
let cascadeNull = false;
|
|
54831
|
-
|
|
54832
|
-
|
|
54833
|
-
|
|
54871
|
+
const typename = this.storage.get(parent, "__typename").value;
|
|
54872
|
+
let targetSelection = getFieldsForType(selection2, typename);
|
|
54873
|
+
for (const [
|
|
54874
|
+
attributeName,
|
|
54875
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
54876
|
+
] of Object.entries(targetSelection)) {
|
|
54834
54877
|
const key = evaluateKey(keyRaw, variables);
|
|
54835
54878
|
const { value } = this.storage.get(parent, key);
|
|
54836
54879
|
let nextStep = stepsFromConnection;
|
|
@@ -54853,7 +54896,7 @@ var CacheInternal = class {
|
|
|
54853
54896
|
if (typeof value !== "undefined") {
|
|
54854
54897
|
hasData = true;
|
|
54855
54898
|
}
|
|
54856
|
-
} else if (!
|
|
54899
|
+
} else if (!fieldSelection) {
|
|
54857
54900
|
const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
|
|
54858
54901
|
if (fnUnmarshal) {
|
|
54859
54902
|
target[attributeName] = fnUnmarshal(value);
|
|
@@ -54863,7 +54906,7 @@ var CacheInternal = class {
|
|
|
54863
54906
|
hasData = true;
|
|
54864
54907
|
} else if (Array.isArray(value)) {
|
|
54865
54908
|
const listValue = this.hydrateNestedList({
|
|
54866
|
-
fields,
|
|
54909
|
+
fields: fieldSelection,
|
|
54867
54910
|
variables,
|
|
54868
54911
|
linkedList: value,
|
|
54869
54912
|
stepsFromConnection: nextStep
|
|
@@ -54878,7 +54921,7 @@ var CacheInternal = class {
|
|
|
54878
54921
|
} else {
|
|
54879
54922
|
const objectFields = this.getSelection({
|
|
54880
54923
|
parent: value,
|
|
54881
|
-
selection:
|
|
54924
|
+
selection: fieldSelection,
|
|
54882
54925
|
variables,
|
|
54883
54926
|
stepsFromConnection: nextStep
|
|
54884
54927
|
});
|
|
@@ -55707,13 +55750,17 @@ function flattenSelections({
|
|
|
55707
55750
|
config: config2,
|
|
55708
55751
|
filepath,
|
|
55709
55752
|
selections,
|
|
55710
|
-
fragmentDefinitions
|
|
55753
|
+
fragmentDefinitions,
|
|
55754
|
+
applyFragments,
|
|
55755
|
+
ignoreMaskDisable
|
|
55711
55756
|
}) {
|
|
55712
55757
|
const fields = new FieldCollection({
|
|
55713
55758
|
config: config2,
|
|
55714
55759
|
filepath,
|
|
55715
55760
|
selections,
|
|
55716
|
-
fragmentDefinitions
|
|
55761
|
+
fragmentDefinitions,
|
|
55762
|
+
applyFragments,
|
|
55763
|
+
ignoreMaskDisable: !!ignoreMaskDisable
|
|
55717
55764
|
});
|
|
55718
55765
|
return fields.toSelectionSet();
|
|
55719
55766
|
}
|
|
@@ -55724,9 +55771,13 @@ var FieldCollection = class {
|
|
|
55724
55771
|
fields;
|
|
55725
55772
|
inlineFragments;
|
|
55726
55773
|
fragmentSpreads;
|
|
55774
|
+
applyFragments;
|
|
55775
|
+
ignoreMaskDisable;
|
|
55727
55776
|
constructor(args) {
|
|
55728
55777
|
this.config = args.config;
|
|
55729
55778
|
this.fragmentDefinitions = args.fragmentDefinitions;
|
|
55779
|
+
this.applyFragments = args.applyFragments;
|
|
55780
|
+
this.ignoreMaskDisable = args.ignoreMaskDisable;
|
|
55730
55781
|
this.fields = {};
|
|
55731
55782
|
this.inlineFragments = {};
|
|
55732
55783
|
this.fragmentSpreads = {};
|
|
@@ -55755,31 +55806,28 @@ var FieldCollection = class {
|
|
|
55755
55806
|
}
|
|
55756
55807
|
}
|
|
55757
55808
|
if (selection2.kind === "InlineFragment" && selection2.typeCondition) {
|
|
55758
|
-
|
|
55759
|
-
if (!this.inlineFragments[key]) {
|
|
55760
|
-
this.inlineFragments[key] = {
|
|
55761
|
-
astNode: selection2,
|
|
55762
|
-
selection: this.empty()
|
|
55763
|
-
};
|
|
55764
|
-
}
|
|
55765
|
-
for (const subselect of selection2.selectionSet?.selections || []) {
|
|
55766
|
-
this.inlineFragments[key].selection.add(subselect);
|
|
55767
|
-
}
|
|
55809
|
+
this.walkInlineFragment(selection2);
|
|
55768
55810
|
return;
|
|
55769
55811
|
}
|
|
55770
55812
|
if (selection2.kind === "FragmentSpread") {
|
|
55771
55813
|
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
55772
|
-
|
|
55773
|
-
|
|
55814
|
+
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
55815
|
+
const maskEnableDirective = selection2.directives?.find(
|
|
55816
|
+
({ name: name2 }) => name2.value === this.config.maskEnableDirective
|
|
55774
55817
|
);
|
|
55775
|
-
|
|
55776
|
-
|
|
55818
|
+
if (maskEnableDirective) {
|
|
55819
|
+
includeFragments = false;
|
|
55820
|
+
}
|
|
55821
|
+
const maskDisableDirective = selection2.directives?.find(
|
|
55822
|
+
({ name: name2 }) => name2.value === this.config.maskDisableDirective
|
|
55777
55823
|
);
|
|
55778
|
-
|
|
55779
|
-
|
|
55780
|
-
|
|
55824
|
+
if (maskDisableDirective) {
|
|
55825
|
+
includeFragments = true;
|
|
55826
|
+
}
|
|
55827
|
+
if (this.ignoreMaskDisable) {
|
|
55828
|
+
includeFragments = true;
|
|
55781
55829
|
}
|
|
55782
|
-
if (!includeFragments) {
|
|
55830
|
+
if (!includeFragments || !this.applyFragments) {
|
|
55783
55831
|
return;
|
|
55784
55832
|
}
|
|
55785
55833
|
const definition = this.fragmentDefinitions[selection2.name.value];
|
|
@@ -55789,9 +55837,20 @@ var FieldCollection = class {
|
|
|
55789
55837
|
message: "Could not find referenced fragment definition: " + selection2.name.value
|
|
55790
55838
|
});
|
|
55791
55839
|
}
|
|
55792
|
-
|
|
55793
|
-
|
|
55794
|
-
|
|
55840
|
+
this.add({
|
|
55841
|
+
kind: "InlineFragment",
|
|
55842
|
+
typeCondition: {
|
|
55843
|
+
kind: "NamedType",
|
|
55844
|
+
name: {
|
|
55845
|
+
kind: "Name",
|
|
55846
|
+
value: definition.typeCondition.name.value
|
|
55847
|
+
}
|
|
55848
|
+
},
|
|
55849
|
+
selectionSet: {
|
|
55850
|
+
kind: "SelectionSet",
|
|
55851
|
+
selections: [...definition.selectionSet.selections]
|
|
55852
|
+
}
|
|
55853
|
+
});
|
|
55795
55854
|
}
|
|
55796
55855
|
}
|
|
55797
55856
|
toSelectionSet() {
|
|
@@ -55807,12 +55866,30 @@ var FieldCollection = class {
|
|
|
55807
55866
|
})
|
|
55808
55867
|
).concat(Object.values(this.fragmentSpreads));
|
|
55809
55868
|
}
|
|
55869
|
+
walkInlineFragment(selection2) {
|
|
55870
|
+
const key = selection2.typeCondition.name.value;
|
|
55871
|
+
if (!this.inlineFragments[key]) {
|
|
55872
|
+
this.inlineFragments[key] = {
|
|
55873
|
+
astNode: selection2,
|
|
55874
|
+
selection: this.empty()
|
|
55875
|
+
};
|
|
55876
|
+
}
|
|
55877
|
+
for (const subselect of selection2.selectionSet.selections || []) {
|
|
55878
|
+
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
55879
|
+
this.inlineFragments[key].selection.add(subselect);
|
|
55880
|
+
continue;
|
|
55881
|
+
}
|
|
55882
|
+
this.walkInlineFragment(subselect);
|
|
55883
|
+
}
|
|
55884
|
+
}
|
|
55810
55885
|
empty() {
|
|
55811
55886
|
return new FieldCollection({
|
|
55812
55887
|
config: this.config,
|
|
55813
55888
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
55814
55889
|
selections: [],
|
|
55815
|
-
filepath: this.filepath
|
|
55890
|
+
filepath: this.filepath,
|
|
55891
|
+
applyFragments: this.applyFragments,
|
|
55892
|
+
ignoreMaskDisable: this.ignoreMaskDisable
|
|
55816
55893
|
});
|
|
55817
55894
|
}
|
|
55818
55895
|
};
|
|
@@ -56167,11 +56244,6 @@ function operationObject({
|
|
|
56167
56244
|
const when = internalDirectives.find(({ name: name2 }) => name2.value === "when");
|
|
56168
56245
|
const when_not = internalDirectives.find(({ name: name2 }) => name2.value === "when_not");
|
|
56169
56246
|
let parentIDArg = parent?.arguments?.find((argument) => argument.name.value === "value");
|
|
56170
|
-
if (!parentIDArg) {
|
|
56171
|
-
parentIDArg = (append || prepend)?.arguments?.find(
|
|
56172
|
-
({ name: name2 }) => name2.value === config2.listDirectiveParentIDArg
|
|
56173
|
-
);
|
|
56174
|
-
}
|
|
56175
56247
|
if (parentIDArg) {
|
|
56176
56248
|
if (parentIDArg.value.kind === "StringValue") {
|
|
56177
56249
|
parentID = parentIDArg.value.value;
|
|
@@ -57199,6 +57271,8 @@ function selection({
|
|
|
57199
57271
|
markEdges
|
|
57200
57272
|
}) {
|
|
57201
57273
|
let object = {};
|
|
57274
|
+
const typeMap = {};
|
|
57275
|
+
const abstractTypes = [];
|
|
57202
57276
|
for (const field of selections) {
|
|
57203
57277
|
if (field.kind === "FragmentSpread" && includeFragments) {
|
|
57204
57278
|
const fragmentDefinition = document.document.definitions.find(
|
|
@@ -57225,20 +57299,68 @@ function selection({
|
|
|
57225
57299
|
})
|
|
57226
57300
|
);
|
|
57227
57301
|
} else if (field.kind === "InlineFragment") {
|
|
57228
|
-
|
|
57229
|
-
|
|
57230
|
-
object,
|
|
57231
|
-
selection({
|
|
57232
|
-
config: config2,
|
|
57302
|
+
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
57303
|
+
object.fields = deepMerge(
|
|
57233
57304
|
filepath,
|
|
57234
|
-
|
|
57235
|
-
|
|
57236
|
-
|
|
57237
|
-
|
|
57238
|
-
|
|
57239
|
-
|
|
57240
|
-
|
|
57241
|
-
|
|
57305
|
+
object.fields || {},
|
|
57306
|
+
selection({
|
|
57307
|
+
config: config2,
|
|
57308
|
+
filepath,
|
|
57309
|
+
rootType: field.typeCondition?.name.value || rootType,
|
|
57310
|
+
operations,
|
|
57311
|
+
selections: field.selectionSet.selections,
|
|
57312
|
+
path: path2,
|
|
57313
|
+
includeFragments,
|
|
57314
|
+
document
|
|
57315
|
+
}).fields || {}
|
|
57316
|
+
);
|
|
57317
|
+
} else {
|
|
57318
|
+
if (!object.abstractFields) {
|
|
57319
|
+
object.abstractFields = {
|
|
57320
|
+
fields: {},
|
|
57321
|
+
typeMap: {}
|
|
57322
|
+
};
|
|
57323
|
+
}
|
|
57324
|
+
const parentType = config2.schema.getType(rootType);
|
|
57325
|
+
const typeConditionName = field.typeCondition.name.value;
|
|
57326
|
+
const typeCondition = config2.schema.getType(typeConditionName);
|
|
57327
|
+
const possibleTypes = [];
|
|
57328
|
+
if (!graphql10.isAbstractType(typeCondition)) {
|
|
57329
|
+
} else if (graphql10.isAbstractType(parentType)) {
|
|
57330
|
+
const possibleParentTypes = config2.schema.getPossibleTypes(parentType).map((type) => type.name);
|
|
57331
|
+
for (const possible of config2.schema.getPossibleTypes(typeCondition)) {
|
|
57332
|
+
if (possibleParentTypes.includes(possible.name)) {
|
|
57333
|
+
possibleTypes.push(possible.name);
|
|
57334
|
+
}
|
|
57335
|
+
}
|
|
57336
|
+
} else {
|
|
57337
|
+
possibleTypes.push(rootType);
|
|
57338
|
+
}
|
|
57339
|
+
if (possibleTypes.length > 0) {
|
|
57340
|
+
for (const type of possibleTypes) {
|
|
57341
|
+
const existing = typeMap[type];
|
|
57342
|
+
if (!existing || !existing.includes(type)) {
|
|
57343
|
+
typeMap[type] = [typeConditionName].concat(existing || []);
|
|
57344
|
+
}
|
|
57345
|
+
if (!abstractTypes.includes(typeConditionName)) {
|
|
57346
|
+
abstractTypes.push(typeConditionName);
|
|
57347
|
+
}
|
|
57348
|
+
}
|
|
57349
|
+
}
|
|
57350
|
+
object.abstractFields.fields = {
|
|
57351
|
+
...object.abstractFields.fields,
|
|
57352
|
+
[field.typeCondition.name.value]: selection({
|
|
57353
|
+
config: config2,
|
|
57354
|
+
filepath,
|
|
57355
|
+
rootType: field.typeCondition?.name.value || rootType,
|
|
57356
|
+
operations,
|
|
57357
|
+
selections: field.selectionSet.selections,
|
|
57358
|
+
path: path2,
|
|
57359
|
+
includeFragments,
|
|
57360
|
+
document
|
|
57361
|
+
}).fields
|
|
57362
|
+
};
|
|
57363
|
+
}
|
|
57242
57364
|
} else if (field.kind === "Field") {
|
|
57243
57365
|
const type = config2.schema.getType(rootType);
|
|
57244
57366
|
if (!type) {
|
|
@@ -57296,7 +57418,7 @@ function selection({
|
|
|
57296
57418
|
}
|
|
57297
57419
|
if (field.selectionSet) {
|
|
57298
57420
|
const edgesMark = paginated && document.refetch?.method === "cursor" ? document.refetch.update : markEdges;
|
|
57299
|
-
fieldObj.
|
|
57421
|
+
fieldObj.selection = selection({
|
|
57300
57422
|
config: config2,
|
|
57301
57423
|
filepath,
|
|
57302
57424
|
rootType: typeName,
|
|
@@ -57320,11 +57442,49 @@ function selection({
|
|
|
57320
57442
|
if (graphql10.isInterfaceType(fieldType) || graphql10.isUnionType(fieldType)) {
|
|
57321
57443
|
fieldObj.abstract = true;
|
|
57322
57444
|
}
|
|
57323
|
-
object
|
|
57324
|
-
|
|
57325
|
-
fieldObj
|
|
57326
|
-
|
|
57327
|
-
|
|
57445
|
+
object.fields = {
|
|
57446
|
+
...object.fields,
|
|
57447
|
+
[attributeName]: fieldObj
|
|
57448
|
+
};
|
|
57449
|
+
}
|
|
57450
|
+
}
|
|
57451
|
+
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
57452
|
+
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
57453
|
+
let overlap = false;
|
|
57454
|
+
for (const possible of possibles) {
|
|
57455
|
+
if (object.abstractFields.fields[typeName]) {
|
|
57456
|
+
object.abstractFields.fields[typeName] = deepMerge(
|
|
57457
|
+
filepath,
|
|
57458
|
+
object.abstractFields.fields[typeName] || {},
|
|
57459
|
+
object.abstractFields.fields[possible]
|
|
57460
|
+
);
|
|
57461
|
+
overlap = true;
|
|
57462
|
+
}
|
|
57463
|
+
}
|
|
57464
|
+
if (overlap) {
|
|
57465
|
+
delete typeMap[typeName];
|
|
57466
|
+
}
|
|
57467
|
+
}
|
|
57468
|
+
for (const [type, options] of Object.entries(typeMap)) {
|
|
57469
|
+
if (options.length > 1) {
|
|
57470
|
+
object.abstractFields.fields[type] = deepMerge(
|
|
57471
|
+
filepath,
|
|
57472
|
+
...options.map((opt) => object.abstractFields.fields[opt] || {})
|
|
57473
|
+
);
|
|
57474
|
+
delete typeMap[type];
|
|
57475
|
+
}
|
|
57476
|
+
}
|
|
57477
|
+
for (const [type, sel] of Object.entries(object.abstractFields?.fields || {})) {
|
|
57478
|
+
object.abstractFields.fields[type] = deepMerge(filepath, sel || {}, object.fields);
|
|
57479
|
+
}
|
|
57480
|
+
for (const [type, options] of Object.entries(typeMap)) {
|
|
57481
|
+
object.abstractFields.typeMap[type] = options[0];
|
|
57482
|
+
}
|
|
57483
|
+
const usedTypes = Object.values(object.abstractFields.typeMap);
|
|
57484
|
+
for (const type of abstractTypes) {
|
|
57485
|
+
if (!usedTypes.includes(type)) {
|
|
57486
|
+
delete object.abstractFields.fields[type];
|
|
57487
|
+
}
|
|
57328
57488
|
}
|
|
57329
57489
|
}
|
|
57330
57490
|
return object;
|
|
@@ -57459,6 +57619,22 @@ function artifactGenerator(stats) {
|
|
|
57459
57619
|
selectionSet = matchingFragment.selectionSet;
|
|
57460
57620
|
}
|
|
57461
57621
|
const inputs = operations[0]?.variableDefinitions;
|
|
57622
|
+
const mergedSelection = flattenSelections({
|
|
57623
|
+
config: config2,
|
|
57624
|
+
filepath: doc.filename,
|
|
57625
|
+
selections: selectionSet.selections,
|
|
57626
|
+
fragmentDefinitions: doc.document.definitions.filter(
|
|
57627
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
57628
|
+
).reduce(
|
|
57629
|
+
(prev, definition) => ({
|
|
57630
|
+
...prev,
|
|
57631
|
+
[definition.name.value]: definition
|
|
57632
|
+
}),
|
|
57633
|
+
{}
|
|
57634
|
+
),
|
|
57635
|
+
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
57636
|
+
applyFragments: docKind !== "HoudiniFragment"
|
|
57637
|
+
});
|
|
57462
57638
|
const artifact = {
|
|
57463
57639
|
name: name2,
|
|
57464
57640
|
kind: docKind,
|
|
@@ -57470,7 +57646,7 @@ function artifactGenerator(stats) {
|
|
|
57470
57646
|
config: config2,
|
|
57471
57647
|
filepath: doc.filename,
|
|
57472
57648
|
rootType,
|
|
57473
|
-
selections:
|
|
57649
|
+
selections: mergedSelection,
|
|
57474
57650
|
operations: operationsByPath(
|
|
57475
57651
|
config2,
|
|
57476
57652
|
doc.filename,
|
|
@@ -57766,6 +57942,17 @@ function inlineType({
|
|
|
57766
57942
|
continue;
|
|
57767
57943
|
}
|
|
57768
57944
|
const possibleParents = config2.schema.getPossibleTypes(type).map((t) => t.name);
|
|
57945
|
+
const freeSelections = [];
|
|
57946
|
+
const typeSpecificSelections = {};
|
|
57947
|
+
for (const node of selection2.selectionSet.selections) {
|
|
57948
|
+
if (node.kind !== "InlineFragment") {
|
|
57949
|
+
freeSelections.push(node);
|
|
57950
|
+
} else if (node.typeCondition) {
|
|
57951
|
+
typeSpecificSelections[node.typeCondition.name.value] = node.selectionSet.selections;
|
|
57952
|
+
} else {
|
|
57953
|
+
freeSelections.push(...node.selectionSet.selections);
|
|
57954
|
+
}
|
|
57955
|
+
}
|
|
57769
57956
|
for (const possibleType of config2.schema.getPossibleTypes(fragmentType)) {
|
|
57770
57957
|
if (!possibleParents.includes(possibleType.name)) {
|
|
57771
57958
|
continue;
|
|
@@ -57773,7 +57960,12 @@ function inlineType({
|
|
|
57773
57960
|
if (!inlineFragments[possibleType.name]) {
|
|
57774
57961
|
inlineFragments[possibleType.name] = [];
|
|
57775
57962
|
}
|
|
57776
|
-
inlineFragments[possibleType.name].push(...
|
|
57963
|
+
inlineFragments[possibleType.name].push(...freeSelections);
|
|
57964
|
+
if (typeSpecificSelections[possibleType.name]) {
|
|
57965
|
+
inlineFragments[possibleType.name].push(
|
|
57966
|
+
...typeSpecificSelections[possibleType.name]
|
|
57967
|
+
);
|
|
57968
|
+
}
|
|
57777
57969
|
}
|
|
57778
57970
|
} else if (selection2.kind === "InlineFragment" && !selection2.typeCondition) {
|
|
57779
57971
|
selectedFields.push(...selection2.selectionSet.selections);
|
|
@@ -57785,12 +57977,7 @@ function inlineType({
|
|
|
57785
57977
|
...(selectedFields || []).filter(
|
|
57786
57978
|
(field) => field.kind === "Field"
|
|
57787
57979
|
).map((selection2) => {
|
|
57788
|
-
const {
|
|
57789
|
-
config2.schema,
|
|
57790
|
-
filepath,
|
|
57791
|
-
rootObj,
|
|
57792
|
-
selection2
|
|
57793
|
-
);
|
|
57980
|
+
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection2);
|
|
57794
57981
|
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
57795
57982
|
let attributeType = inlineType({
|
|
57796
57983
|
config: config2,
|
|
@@ -57989,7 +58176,8 @@ async function typescriptGenerator(config2, docs) {
|
|
|
57989
58176
|
config: config2,
|
|
57990
58177
|
filepath: filename,
|
|
57991
58178
|
selections: definition.selectionSet.selections,
|
|
57992
|
-
fragmentDefinitions
|
|
58179
|
+
fragmentDefinitions,
|
|
58180
|
+
applyFragments: definition.kind === "OperationDefinition"
|
|
57993
58181
|
});
|
|
57994
58182
|
if (definition?.kind === "OperationDefinition") {
|
|
57995
58183
|
await generateOperationTypeDefs(
|
|
@@ -58502,14 +58690,12 @@ directive @${config2.paginateDirective}(${config2.paginateNameArg}: String) on F
|
|
|
58502
58690
|
"""
|
|
58503
58691
|
@${config2.listPrependDirective} is used to tell the runtime to add the result to the end of the list
|
|
58504
58692
|
"""
|
|
58505
|
-
directive @${config2.listPrependDirective}
|
|
58506
|
-
${config2.listDirectiveParentIDArg}: ID
|
|
58507
|
-
) on FRAGMENT_SPREAD
|
|
58693
|
+
directive @${config2.listPrependDirective} on FRAGMENT_SPREAD
|
|
58508
58694
|
|
|
58509
58695
|
"""
|
|
58510
58696
|
@${config2.listAppendDirective} is used to tell the runtime to add the result to the start of the list
|
|
58511
58697
|
"""
|
|
58512
|
-
directive @${config2.listAppendDirective}
|
|
58698
|
+
directive @${config2.listAppendDirective} on FRAGMENT_SPREAD
|
|
58513
58699
|
|
|
58514
58700
|
"""
|
|
58515
58701
|
@${config2.listAllListsDirective} is used to tell the runtime to add the result to all list
|
|
@@ -58543,18 +58729,19 @@ directive @${config2.argumentsDirective} on FRAGMENT_DEFINITION
|
|
|
58543
58729
|
directive @${config2.cacheDirective}(${config2.cachePolicyArg}: CachePolicy, ${config2.cachePartialArg}: Boolean) on QUERY
|
|
58544
58730
|
|
|
58545
58731
|
"""
|
|
58546
|
-
@${config2.
|
|
58732
|
+
@${config2.manualLoadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
|
|
58733
|
+
"""
|
|
58734
|
+
directive @${config2.manualLoadDirective} on QUERY
|
|
58735
|
+
|
|
58736
|
+
"""
|
|
58737
|
+
@${config2.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
|
|
58738
|
+
"""
|
|
58739
|
+
directive @${config2.maskEnableDirective} on FRAGMENT_SPREAD
|
|
58740
|
+
|
|
58547
58741
|
"""
|
|
58548
|
-
|
|
58549
|
-
|
|
58550
|
-
|
|
58551
|
-
"""
|
|
58552
|
-
load: Boolean! = true
|
|
58553
|
-
"""
|
|
58554
|
-
Mask fragment fields (only valid when used at a fragment spread)
|
|
58555
|
-
"""
|
|
58556
|
-
mask: Boolean! = ${config2.disableMasking ? "false" : "true"}
|
|
58557
|
-
) on QUERY | FRAGMENT_SPREAD
|
|
58742
|
+
@${config2.maskDisableDirective} to disable masking on fragment (overwriting the global conf)
|
|
58743
|
+
"""
|
|
58744
|
+
directive @${config2.maskDisableDirective} on FRAGMENT_SPREAD
|
|
58558
58745
|
`;
|
|
58559
58746
|
let currentSchema = graphql19.printSchema(config2.schema);
|
|
58560
58747
|
if (!currentSchema.includes(`directive @${config2.listDirective}`)) {
|
|
@@ -59047,26 +59234,42 @@ async function typeCheck(config2, docs) {
|
|
|
59047
59234
|
),
|
|
59048
59235
|
targetField.selectionSet
|
|
59049
59236
|
);
|
|
59050
|
-
|
|
59051
|
-
if (
|
|
59052
|
-
|
|
59053
|
-
|
|
59054
|
-
|
|
59055
|
-
|
|
59056
|
-
|
|
59057
|
-
|
|
59058
|
-
|
|
59059
|
-
|
|
59060
|
-
|
|
59061
|
-
|
|
59062
|
-
|
|
59063
|
-
|
|
59064
|
-
|
|
59065
|
-
|
|
59066
|
-
|
|
59067
|
-
)
|
|
59237
|
+
let targetTypes = [type];
|
|
59238
|
+
if (graphql23.isUnionType(type)) {
|
|
59239
|
+
targetTypes = config2.schema.getPossibleTypes(type);
|
|
59240
|
+
} else if (graphql23.isInterfaceType(type)) {
|
|
59241
|
+
try {
|
|
59242
|
+
for (const key of config2.keyFieldsForType(type.name)) {
|
|
59243
|
+
if (!type.getFields()[key]) {
|
|
59244
|
+
throw new Error("continue");
|
|
59245
|
+
}
|
|
59246
|
+
}
|
|
59247
|
+
} catch {
|
|
59248
|
+
targetTypes = config2.schema.getPossibleTypes(type);
|
|
59249
|
+
}
|
|
59250
|
+
}
|
|
59251
|
+
for (const targetType of targetTypes) {
|
|
59252
|
+
const missingIDFields = config2.keyFieldsForType(targetType.name).filter((fieldName) => !targetType.getFields()[fieldName]);
|
|
59253
|
+
if (missingIDFields.length > 0) {
|
|
59254
|
+
if (error) {
|
|
59255
|
+
errors.push(
|
|
59256
|
+
new HoudiniError({
|
|
59257
|
+
filepath: filename,
|
|
59258
|
+
message: error
|
|
59259
|
+
})
|
|
59260
|
+
);
|
|
59261
|
+
} else {
|
|
59262
|
+
errors.push(
|
|
59263
|
+
new HoudiniError({
|
|
59264
|
+
filepath: filename,
|
|
59265
|
+
message: `@${config2.listDirective} can only be applied to types with the necessary id fields: ${missingIDFields.join(
|
|
59266
|
+
", "
|
|
59267
|
+
)}.`
|
|
59268
|
+
})
|
|
59269
|
+
);
|
|
59270
|
+
}
|
|
59271
|
+
return;
|
|
59068
59272
|
}
|
|
59069
|
-
return;
|
|
59070
59273
|
}
|
|
59071
59274
|
lists.push(listName);
|
|
59072
59275
|
listTypes.push(type.name);
|
|
@@ -59096,6 +59299,7 @@ async function typeCheck(config2, docs) {
|
|
|
59096
59299
|
fragments
|
|
59097
59300
|
}),
|
|
59098
59301
|
checkMutationOperation(config2),
|
|
59302
|
+
checkMaskDirective(config2),
|
|
59099
59303
|
nodeDirectives(config2, [config2.paginateDirective]),
|
|
59100
59304
|
knownArguments(config2),
|
|
59101
59305
|
validateFragmentArguments(config2, filepath, fragments),
|
|
@@ -59160,10 +59364,14 @@ var validateLists = ({
|
|
|
59160
59364
|
]);
|
|
59161
59365
|
if (directive) {
|
|
59162
59366
|
let parentArg = directive.arguments?.find(
|
|
59163
|
-
(arg) => arg.name.value === config2.
|
|
59367
|
+
(arg) => arg.name.value === config2.deprecatedlistDirectiveParentIDArg
|
|
59164
59368
|
);
|
|
59165
59369
|
if (parentArg) {
|
|
59166
|
-
|
|
59370
|
+
ctx.reportError(
|
|
59371
|
+
new graphql23.GraphQLError(
|
|
59372
|
+
`@${config2.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
|
|
59373
|
+
)
|
|
59374
|
+
);
|
|
59167
59375
|
}
|
|
59168
59376
|
}
|
|
59169
59377
|
if (parentIdFound) {
|
|
@@ -59559,6 +59767,28 @@ function checkMutationOperation(config2) {
|
|
|
59559
59767
|
};
|
|
59560
59768
|
};
|
|
59561
59769
|
}
|
|
59770
|
+
function checkMaskDirective(config2) {
|
|
59771
|
+
return function(ctx) {
|
|
59772
|
+
return {
|
|
59773
|
+
FragmentSpread(node, _, __, ___, ancestors) {
|
|
59774
|
+
const maskEnableDirective = node.directives?.find(
|
|
59775
|
+
(c) => c.name.value === config2.maskEnableDirective
|
|
59776
|
+
);
|
|
59777
|
+
const maskDisableDirective = node.directives?.find(
|
|
59778
|
+
(c) => c.name.value === config2.maskDisableDirective
|
|
59779
|
+
);
|
|
59780
|
+
if (maskEnableDirective && maskDisableDirective) {
|
|
59781
|
+
ctx.reportError(
|
|
59782
|
+
new graphql23.GraphQLError(
|
|
59783
|
+
`You can't apply both @${config2.maskEnableDirective} and @${config2.maskDisableDirective} at the same time`
|
|
59784
|
+
)
|
|
59785
|
+
);
|
|
59786
|
+
return;
|
|
59787
|
+
}
|
|
59788
|
+
}
|
|
59789
|
+
};
|
|
59790
|
+
};
|
|
59791
|
+
}
|
|
59562
59792
|
function getAndVerifyNodeInterface(config2) {
|
|
59563
59793
|
const { schema } = config2;
|
|
59564
59794
|
const nodeInterface = schema.getType("Node");
|
|
@@ -59856,12 +60086,7 @@ async function collectDocuments(config2) {
|
|
|
59856
60086
|
}
|
|
59857
60087
|
async function processJSFile(config2, contents) {
|
|
59858
60088
|
const documents = [];
|
|
59859
|
-
|
|
59860
|
-
var program = (await parseJS(contents)).script;
|
|
59861
|
-
} catch (e) {
|
|
59862
|
-
console.log(contents);
|
|
59863
|
-
throw e;
|
|
59864
|
-
}
|
|
60089
|
+
var program = (await parseJS(contents)).script;
|
|
59865
60090
|
await find_graphql(config2, program, {
|
|
59866
60091
|
tag({ tagContent }) {
|
|
59867
60092
|
documents.push(tagContent);
|