@apollo/client 3.8.0-alpha.7 → 3.8.0-alpha.9
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/README.md +1 -1
- package/apollo-client.cjs +219 -183
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +34 -24
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +34 -24
- package/cache/core/types/DataProxy.d.ts +3 -2
- package/cache/core/types/DataProxy.d.ts.map +1 -1
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +2 -2
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js +2 -2
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +14 -3
- package/cache/inmemory/policies.js.map +1 -1
- package/core/ApolloClient.d.ts +3 -3
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +10 -4
- package/core/ApolloClient.js.map +1 -1
- package/core/core.cjs +11 -5
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +11 -5
- package/invariantErrorCodes.js +4 -3
- package/link/core/types.d.ts +3 -4
- package/link/core/types.d.ts.map +1 -1
- package/link/core/types.js.map +1 -1
- package/package.json +16 -17
- package/react/hooks/hooks.cjs +19 -11
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +19 -11
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +2 -1
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +1 -1
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseCache.d.ts +2 -1
- package/react/hooks/useSuspenseCache.d.ts.map +1 -1
- package/react/hooks/useSuspenseCache.js +6 -4
- package/react/hooks/useSuspenseCache.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js +10 -5
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/types/types.d.ts +2 -0
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/itAsync.js.map +1 -1
- package/utilities/common/arrays.d.ts +1 -0
- package/utilities/common/arrays.d.ts.map +1 -1
- package/utilities/common/arrays.js +1 -0
- package/utilities/common/arrays.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts.map +1 -1
- package/utilities/graphql/getFromAST.js +7 -3
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +167 -90
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js +2 -2
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/utilities.cjs +177 -105
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +177 -105
- package/version.js +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ Learn how to use Apollo Client with self-paced hands-on training on Odyssey, Apo
|
|
|
37
37
|
|
|
38
38
|
- [Apollo Studio](https://www.apollographql.com/studio/develop/) – A free, end-to-end platform for managing your GraphQL lifecycle. Track your GraphQL schemas in a hosted registry to create a source of truth for everything in your graph. Studio provides an IDE (Apollo Explorer) so you can explore data, collaborate on queries, observe usage, and safely make schema changes.
|
|
39
39
|
- [Apollo Federation](https://www.apollographql.com/apollo-federation) – The industry-standard open architecture for building a distributed graph. Use Apollo’s gateway to compose a unified graph from multiple subgraphs, determine a query plan, and route requests across your services.
|
|
40
|
-
- [Apollo Client](https://www.apollographql.com/apollo-client/) – The most popular GraphQL client for the web. Apollo also builds and maintains [Apollo iOS](https://github.com/apollographql/apollo-ios) and [Apollo
|
|
40
|
+
- [Apollo Client](https://www.apollographql.com/apollo-client/) – The most popular GraphQL client for the web. Apollo also builds and maintains [Apollo iOS](https://github.com/apollographql/apollo-ios) and [Apollo Kotlin](https://github.com/apollographql/apollo-kotlin).
|
|
41
41
|
- [Apollo Server](https://www.apollographql.com/docs/apollo-server/) – A production-ready JavaScript GraphQL server that connects to any microservice, API, or database. Compatible with all popular JavaScript frameworks and deployable in serverless environments.
|
|
42
42
|
|
|
43
43
|
## Learn how to build with Apollo
|
package/apollo-client.cjs
CHANGED
|
@@ -398,17 +398,21 @@ function checkDocument(doc) {
|
|
|
398
398
|
}
|
|
399
399
|
function getOperationDefinition(doc) {
|
|
400
400
|
checkDocument(doc);
|
|
401
|
-
return doc.definitions.filter(function (definition) {
|
|
401
|
+
return doc.definitions.filter(function (definition) {
|
|
402
|
+
return definition.kind === 'OperationDefinition';
|
|
403
|
+
})[0];
|
|
402
404
|
}
|
|
403
405
|
function getOperationName(doc) {
|
|
404
406
|
return (doc.definitions
|
|
405
407
|
.filter(function (definition) {
|
|
406
|
-
return definition.kind === 'OperationDefinition' && definition.name;
|
|
408
|
+
return definition.kind === 'OperationDefinition' && !!definition.name;
|
|
407
409
|
})
|
|
408
410
|
.map(function (x) { return x.name.value; })[0] || null);
|
|
409
411
|
}
|
|
410
412
|
function getFragmentDefinitions(doc) {
|
|
411
|
-
return doc.definitions.filter(function (definition) {
|
|
413
|
+
return doc.definitions.filter(function (definition) {
|
|
414
|
+
return definition.kind === 'FragmentDefinition';
|
|
415
|
+
});
|
|
412
416
|
}
|
|
413
417
|
function getQueryDefinition(doc) {
|
|
414
418
|
var queryDef = getOperationDefinition(doc);
|
|
@@ -457,26 +461,20 @@ function getDefaultValues(definition) {
|
|
|
457
461
|
return defaultValues;
|
|
458
462
|
}
|
|
459
463
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
if (test.call(this, elem, i, array)) {
|
|
464
|
-
array[target++] = elem;
|
|
465
|
-
}
|
|
466
|
-
}, context);
|
|
467
|
-
array.length = target;
|
|
468
|
-
return array;
|
|
464
|
+
var isArray = Array.isArray;
|
|
465
|
+
function isNonEmptyArray(value) {
|
|
466
|
+
return Array.isArray(value) && value.length > 0;
|
|
469
467
|
}
|
|
470
468
|
|
|
471
469
|
var TYPENAME_FIELD = {
|
|
472
|
-
kind:
|
|
470
|
+
kind: graphql.Kind.FIELD,
|
|
473
471
|
name: {
|
|
474
|
-
kind:
|
|
472
|
+
kind: graphql.Kind.NAME,
|
|
475
473
|
value: '__typename',
|
|
476
474
|
},
|
|
477
475
|
};
|
|
478
476
|
function isEmpty(op, fragmentMap) {
|
|
479
|
-
return !op || op.selectionSet.selections.every(function (selection) { return selection.kind ===
|
|
477
|
+
return !op || op.selectionSet.selections.every(function (selection) { return selection.kind === graphql.Kind.FRAGMENT_SPREAD &&
|
|
480
478
|
isEmpty(fragmentMap[selection.name.value], fragmentMap); });
|
|
481
479
|
}
|
|
482
480
|
function nullIfDocIsEmpty(doc) {
|
|
@@ -485,84 +483,190 @@ function nullIfDocIsEmpty(doc) {
|
|
|
485
483
|
: doc;
|
|
486
484
|
}
|
|
487
485
|
function getDirectiveMatcher(directives) {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
486
|
+
var nameSet = new Set();
|
|
487
|
+
var tests = [];
|
|
488
|
+
directives.forEach(function (directive) {
|
|
489
|
+
if (directive.name) {
|
|
490
|
+
nameSet.add(directive.name);
|
|
491
|
+
}
|
|
492
|
+
else if (directive.test) {
|
|
493
|
+
tests.push(directive.test);
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
return function (directive) { return (nameSet.has(directive.name.value) ||
|
|
497
|
+
tests.some(function (test) { return test(directive); })); };
|
|
498
|
+
}
|
|
499
|
+
function makeInUseGetterFunction(defaultKey) {
|
|
500
|
+
var map = new Map();
|
|
501
|
+
return function inUseGetterFunction(key) {
|
|
502
|
+
if (key === void 0) { key = defaultKey; }
|
|
503
|
+
var inUse = map.get(key);
|
|
504
|
+
if (!inUse) {
|
|
505
|
+
map.set(key, inUse = {
|
|
506
|
+
variables: new Set,
|
|
507
|
+
fragmentSpreads: new Set,
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
return inUse;
|
|
493
511
|
};
|
|
494
512
|
}
|
|
495
513
|
function removeDirectivesFromDocument(directives, doc) {
|
|
496
|
-
var
|
|
497
|
-
var
|
|
498
|
-
var
|
|
499
|
-
|
|
500
|
-
|
|
514
|
+
var getInUseByOperationName = makeInUseGetterFunction("");
|
|
515
|
+
var getInUseByFragmentName = makeInUseGetterFunction("");
|
|
516
|
+
var getInUse = function (ancestors) {
|
|
517
|
+
for (var p = 0, ancestor = void 0; p < ancestors.length && (ancestor = ancestors[p]); ++p) {
|
|
518
|
+
if (isArray(ancestor))
|
|
519
|
+
continue;
|
|
520
|
+
if (ancestor.kind === graphql.Kind.OPERATION_DEFINITION) {
|
|
521
|
+
return getInUseByOperationName(ancestor.name && ancestor.name.value);
|
|
522
|
+
}
|
|
523
|
+
if (ancestor.kind === graphql.Kind.FRAGMENT_DEFINITION) {
|
|
524
|
+
return getInUseByFragmentName(ancestor.name.value);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
__DEV__ && tsInvariant.invariant.error("Could not find operation or fragment");
|
|
528
|
+
return null;
|
|
529
|
+
};
|
|
530
|
+
var operationCount = 0;
|
|
531
|
+
for (var i = doc.definitions.length - 1; i >= 0; --i) {
|
|
532
|
+
if (doc.definitions[i].kind === graphql.Kind.OPERATION_DEFINITION) {
|
|
533
|
+
++operationCount;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
var directiveMatcher = getDirectiveMatcher(directives);
|
|
537
|
+
var hasRemoveDirective = directives.some(function (directive) { return directive.remove; });
|
|
538
|
+
var shouldRemoveField = function (nodeDirectives) { return (hasRemoveDirective &&
|
|
539
|
+
nodeDirectives &&
|
|
540
|
+
nodeDirectives.some(directiveMatcher)); };
|
|
541
|
+
var originalFragmentDefsByPath = new Map();
|
|
542
|
+
var firstVisitMadeChanges = false;
|
|
543
|
+
var fieldOrInlineFragmentVisitor = {
|
|
544
|
+
enter: function (node) {
|
|
545
|
+
if (shouldRemoveField(node.directives)) {
|
|
546
|
+
firstVisitMadeChanges = true;
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
};
|
|
551
|
+
var docWithoutDirectiveSubtrees = graphql.visit(doc, {
|
|
552
|
+
Field: fieldOrInlineFragmentVisitor,
|
|
553
|
+
InlineFragment: fieldOrInlineFragmentVisitor,
|
|
554
|
+
VariableDefinition: {
|
|
555
|
+
enter: function () {
|
|
556
|
+
return false;
|
|
557
|
+
},
|
|
558
|
+
},
|
|
501
559
|
Variable: {
|
|
502
|
-
enter: function (node, _key,
|
|
503
|
-
|
|
504
|
-
|
|
560
|
+
enter: function (node, _key, _parent, _path, ancestors) {
|
|
561
|
+
var inUse = getInUse(ancestors);
|
|
562
|
+
if (inUse) {
|
|
563
|
+
inUse.variables.add(node.name.value);
|
|
505
564
|
}
|
|
506
565
|
},
|
|
507
566
|
},
|
|
508
|
-
|
|
509
|
-
enter: function (node) {
|
|
510
|
-
if (
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
if (arg.value.kind === 'Variable') {
|
|
518
|
-
variablesToRemove.push({
|
|
519
|
-
name: arg.value.name.value,
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
if (node.selectionSet) {
|
|
525
|
-
getAllFragmentSpreadsFromSelectionSet(node.selectionSet).forEach(function (frag) {
|
|
526
|
-
fragmentSpreadsToRemove.push({
|
|
527
|
-
name: frag.name.value,
|
|
528
|
-
});
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
return null;
|
|
532
|
-
}
|
|
567
|
+
FragmentSpread: {
|
|
568
|
+
enter: function (node, _key, _parent, _path, ancestors) {
|
|
569
|
+
if (shouldRemoveField(node.directives)) {
|
|
570
|
+
firstVisitMadeChanges = true;
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
var inUse = getInUse(ancestors);
|
|
574
|
+
if (inUse) {
|
|
575
|
+
inUse.fragmentSpreads.add(node.name.value);
|
|
533
576
|
}
|
|
534
577
|
},
|
|
535
578
|
},
|
|
536
|
-
|
|
537
|
-
enter: function (node) {
|
|
538
|
-
|
|
579
|
+
FragmentDefinition: {
|
|
580
|
+
enter: function (node, _key, _parent, path) {
|
|
581
|
+
originalFragmentDefsByPath.set(JSON.stringify(path), node);
|
|
582
|
+
},
|
|
583
|
+
leave: function (node, _key, _parent, path) {
|
|
584
|
+
var originalNode = originalFragmentDefsByPath.get(JSON.stringify(path));
|
|
585
|
+
if (node === originalNode) {
|
|
586
|
+
return node;
|
|
587
|
+
}
|
|
588
|
+
if (operationCount > 0 &&
|
|
589
|
+
node.selectionSet.selections.every(function (selection) { return (selection.kind === graphql.Kind.FIELD &&
|
|
590
|
+
selection.name.value === '__typename'); })) {
|
|
591
|
+
getInUseByFragmentName(node.name.value).removed = true;
|
|
592
|
+
firstVisitMadeChanges = true;
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
539
595
|
},
|
|
540
596
|
},
|
|
541
597
|
Directive: {
|
|
542
|
-
|
|
543
|
-
if (
|
|
598
|
+
leave: function (node) {
|
|
599
|
+
if (directiveMatcher(node)) {
|
|
600
|
+
firstVisitMadeChanges = true;
|
|
544
601
|
return null;
|
|
545
602
|
}
|
|
546
603
|
},
|
|
547
604
|
},
|
|
605
|
+
});
|
|
606
|
+
if (!firstVisitMadeChanges) {
|
|
607
|
+
return doc;
|
|
608
|
+
}
|
|
609
|
+
var populateTransitiveVars = function (inUse) {
|
|
610
|
+
if (!inUse.transitiveVars) {
|
|
611
|
+
inUse.transitiveVars = new Set(inUse.variables);
|
|
612
|
+
if (!inUse.removed) {
|
|
613
|
+
inUse.fragmentSpreads.forEach(function (childFragmentName) {
|
|
614
|
+
populateTransitiveVars(getInUseByFragmentName(childFragmentName)).transitiveVars.forEach(function (varName) {
|
|
615
|
+
inUse.transitiveVars.add(varName);
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return inUse;
|
|
621
|
+
};
|
|
622
|
+
var allFragmentNamesUsed = new Set();
|
|
623
|
+
docWithoutDirectiveSubtrees.definitions.forEach(function (def) {
|
|
624
|
+
if (def.kind === graphql.Kind.OPERATION_DEFINITION) {
|
|
625
|
+
populateTransitiveVars(getInUseByOperationName(def.name && def.name.value)).fragmentSpreads.forEach(function (childFragmentName) {
|
|
626
|
+
allFragmentNamesUsed.add(childFragmentName);
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
else if (def.kind === graphql.Kind.FRAGMENT_DEFINITION &&
|
|
630
|
+
operationCount === 0 &&
|
|
631
|
+
!getInUseByFragmentName(def.name.value).removed) {
|
|
632
|
+
allFragmentNamesUsed.add(def.name.value);
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
allFragmentNamesUsed.forEach(function (fragmentName) {
|
|
636
|
+
populateTransitiveVars(getInUseByFragmentName(fragmentName)).fragmentSpreads.forEach(function (childFragmentName) {
|
|
637
|
+
allFragmentNamesUsed.add(childFragmentName);
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
var fragmentWillBeRemoved = function (fragmentName) { return !!(!allFragmentNamesUsed.has(fragmentName) ||
|
|
641
|
+
getInUseByFragmentName(fragmentName).removed); };
|
|
642
|
+
var enterVisitor = {
|
|
643
|
+
enter: function (node) {
|
|
644
|
+
if (fragmentWillBeRemoved(node.name.value)) {
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
},
|
|
648
|
+
};
|
|
649
|
+
return nullIfDocIsEmpty(graphql.visit(docWithoutDirectiveSubtrees, {
|
|
650
|
+
FragmentSpread: enterVisitor,
|
|
651
|
+
FragmentDefinition: enterVisitor,
|
|
652
|
+
OperationDefinition: {
|
|
653
|
+
leave: function (node) {
|
|
654
|
+
if (node.variableDefinitions) {
|
|
655
|
+
var usedVariableNames_1 = populateTransitiveVars(getInUseByOperationName(node.name && node.name.value)).transitiveVars;
|
|
656
|
+
if (usedVariableNames_1.size < node.variableDefinitions.length) {
|
|
657
|
+
return tslib.__assign(tslib.__assign({}, node), { variableDefinitions: node.variableDefinitions.filter(function (varDef) { return usedVariableNames_1.has(varDef.variable.name.value); }) });
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
},
|
|
548
662
|
}));
|
|
549
|
-
if (modifiedDoc &&
|
|
550
|
-
filterInPlace(variablesToRemove, function (v) { return !!v.name && !variablesInUse[v.name]; }).length) {
|
|
551
|
-
modifiedDoc = removeArgumentsFromDocument(variablesToRemove, modifiedDoc);
|
|
552
|
-
}
|
|
553
|
-
if (modifiedDoc &&
|
|
554
|
-
filterInPlace(fragmentSpreadsToRemove, function (fs) { return !!fs.name && !fragmentSpreadsInUse[fs.name]; })
|
|
555
|
-
.length) {
|
|
556
|
-
modifiedDoc = removeFragmentSpreadFromDocument(fragmentSpreadsToRemove, modifiedDoc);
|
|
557
|
-
}
|
|
558
|
-
return modifiedDoc;
|
|
559
663
|
}
|
|
560
664
|
var addTypenameToDocument = Object.assign(function (doc) {
|
|
561
665
|
return graphql.visit(doc, {
|
|
562
666
|
SelectionSet: {
|
|
563
667
|
enter: function (node, _key, parent) {
|
|
564
668
|
if (parent &&
|
|
565
|
-
parent.kind ===
|
|
669
|
+
parent.kind === graphql.Kind.OPERATION_DEFINITION) {
|
|
566
670
|
return;
|
|
567
671
|
}
|
|
568
672
|
var selections = node.selections;
|
|
@@ -608,78 +712,6 @@ var connectionRemoveConfig = {
|
|
|
608
712
|
function removeConnectionDirectiveFromDocument(doc) {
|
|
609
713
|
return removeDirectivesFromDocument([connectionRemoveConfig], checkDocument(doc));
|
|
610
714
|
}
|
|
611
|
-
function getArgumentMatcher(config) {
|
|
612
|
-
return function argumentMatcher(argument) {
|
|
613
|
-
return config.some(function (aConfig) {
|
|
614
|
-
return argument.value &&
|
|
615
|
-
argument.value.kind === 'Variable' &&
|
|
616
|
-
argument.value.name &&
|
|
617
|
-
(aConfig.name === argument.value.name.value ||
|
|
618
|
-
(aConfig.test && aConfig.test(argument)));
|
|
619
|
-
});
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
function removeArgumentsFromDocument(config, doc) {
|
|
623
|
-
var argMatcher = getArgumentMatcher(config);
|
|
624
|
-
return nullIfDocIsEmpty(graphql.visit(doc, {
|
|
625
|
-
OperationDefinition: {
|
|
626
|
-
enter: function (node) {
|
|
627
|
-
return tslib.__assign(tslib.__assign({}, node), { variableDefinitions: node.variableDefinitions ? node.variableDefinitions.filter(function (varDef) {
|
|
628
|
-
return !config.some(function (arg) { return arg.name === varDef.variable.name.value; });
|
|
629
|
-
}) : [] });
|
|
630
|
-
},
|
|
631
|
-
},
|
|
632
|
-
Field: {
|
|
633
|
-
enter: function (node) {
|
|
634
|
-
var shouldRemoveField = config.some(function (argConfig) { return argConfig.remove; });
|
|
635
|
-
if (shouldRemoveField) {
|
|
636
|
-
var argMatchCount_1 = 0;
|
|
637
|
-
if (node.arguments) {
|
|
638
|
-
node.arguments.forEach(function (arg) {
|
|
639
|
-
if (argMatcher(arg)) {
|
|
640
|
-
argMatchCount_1 += 1;
|
|
641
|
-
}
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
if (argMatchCount_1 === 1) {
|
|
645
|
-
return null;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
},
|
|
649
|
-
},
|
|
650
|
-
Argument: {
|
|
651
|
-
enter: function (node) {
|
|
652
|
-
if (argMatcher(node)) {
|
|
653
|
-
return null;
|
|
654
|
-
}
|
|
655
|
-
},
|
|
656
|
-
},
|
|
657
|
-
}));
|
|
658
|
-
}
|
|
659
|
-
function removeFragmentSpreadFromDocument(config, doc) {
|
|
660
|
-
function enter(node) {
|
|
661
|
-
if (config.some(function (def) { return def.name === node.name.value; })) {
|
|
662
|
-
return null;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
return nullIfDocIsEmpty(graphql.visit(doc, {
|
|
666
|
-
FragmentSpread: { enter: enter },
|
|
667
|
-
FragmentDefinition: { enter: enter },
|
|
668
|
-
}));
|
|
669
|
-
}
|
|
670
|
-
function getAllFragmentSpreadsFromSelectionSet(selectionSet) {
|
|
671
|
-
var allFragments = [];
|
|
672
|
-
selectionSet.selections.forEach(function (selection) {
|
|
673
|
-
if ((isField(selection) || isInlineFragment(selection)) &&
|
|
674
|
-
selection.selectionSet) {
|
|
675
|
-
getAllFragmentSpreadsFromSelectionSet(selection.selectionSet).forEach(function (frag) { return allFragments.push(frag); });
|
|
676
|
-
}
|
|
677
|
-
else if (selection.kind === 'FragmentSpread') {
|
|
678
|
-
allFragments.push(selection);
|
|
679
|
-
}
|
|
680
|
-
});
|
|
681
|
-
return allFragments;
|
|
682
|
-
}
|
|
683
715
|
function buildQueryFromSelectionSet(document) {
|
|
684
716
|
var definition = getMainDefinition(document);
|
|
685
717
|
var definitionOperation = definition.operation;
|
|
@@ -703,22 +735,6 @@ function removeClientSetsFromDocument(document) {
|
|
|
703
735
|
remove: true,
|
|
704
736
|
},
|
|
705
737
|
], document);
|
|
706
|
-
if (modifiedDoc) {
|
|
707
|
-
modifiedDoc = graphql.visit(modifiedDoc, {
|
|
708
|
-
FragmentDefinition: {
|
|
709
|
-
enter: function (node) {
|
|
710
|
-
if (node.selectionSet) {
|
|
711
|
-
var isTypenameOnly = node.selectionSet.selections.every(function (selection) {
|
|
712
|
-
return isField(selection) && selection.name.value === '__typename';
|
|
713
|
-
});
|
|
714
|
-
if (isTypenameOnly) {
|
|
715
|
-
return null;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
},
|
|
719
|
-
},
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
738
|
return modifiedDoc;
|
|
723
739
|
}
|
|
724
740
|
|
|
@@ -971,9 +987,9 @@ var Concast = (function (_super) {
|
|
|
971
987
|
}
|
|
972
988
|
},
|
|
973
989
|
complete: function () {
|
|
974
|
-
var sub =
|
|
990
|
+
var _a = _this, sub = _a.sub, _b = _a.sources, sources = _b === void 0 ? [] : _b;
|
|
975
991
|
if (sub !== null) {
|
|
976
|
-
var value =
|
|
992
|
+
var value = sources.shift();
|
|
977
993
|
if (!value) {
|
|
978
994
|
if (sub)
|
|
979
995
|
setTimeout(function () { return sub.unsubscribe(); });
|
|
@@ -1067,10 +1083,6 @@ var Concast = (function (_super) {
|
|
|
1067
1083
|
}(zenObservableTs.Observable));
|
|
1068
1084
|
fixObservableSubclass(Concast);
|
|
1069
1085
|
|
|
1070
|
-
function isNonEmptyArray(value) {
|
|
1071
|
-
return Array.isArray(value) && value.length > 0;
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
1086
|
function isExecutionPatchIncrementalResult(value) {
|
|
1075
1087
|
return "incremental" in value;
|
|
1076
1088
|
}
|
|
@@ -1383,7 +1395,7 @@ var concat = ApolloLink.concat;
|
|
|
1383
1395
|
|
|
1384
1396
|
var execute = ApolloLink.execute;
|
|
1385
1397
|
|
|
1386
|
-
var version = '3.8.0-alpha.
|
|
1398
|
+
var version = '3.8.0-alpha.9';
|
|
1387
1399
|
|
|
1388
1400
|
function asyncIterator(source) {
|
|
1389
1401
|
var _a;
|
|
@@ -2066,7 +2078,6 @@ var hasOwn = Object.prototype.hasOwnProperty;
|
|
|
2066
2078
|
function isNullish(value) {
|
|
2067
2079
|
return value === null || value === void 0;
|
|
2068
2080
|
}
|
|
2069
|
-
var isArray = Array.isArray;
|
|
2070
2081
|
function defaultDataIdFromObject(_a, context) {
|
|
2071
2082
|
var __typename = _a.__typename, id = _a.id, _id = _a._id;
|
|
2072
2083
|
if (typeof __typename === "string") {
|
|
@@ -3310,9 +3321,20 @@ var Policies = (function () {
|
|
|
3310
3321
|
if (!hasOwn.call(this.typePolicies, typename)) {
|
|
3311
3322
|
var policy_1 = this.typePolicies[typename] = Object.create(null);
|
|
3312
3323
|
policy_1.fields = Object.create(null);
|
|
3313
|
-
var
|
|
3314
|
-
if (
|
|
3315
|
-
|
|
3324
|
+
var supertypes_1 = this.supertypeMap.get(typename);
|
|
3325
|
+
if (!supertypes_1 && this.fuzzySubtypes.size) {
|
|
3326
|
+
supertypes_1 = this.getSupertypeSet(typename, true);
|
|
3327
|
+
this.fuzzySubtypes.forEach(function (regExp, fuzzy) {
|
|
3328
|
+
if (regExp.test(typename)) {
|
|
3329
|
+
var fuzzySupertypes = _this.supertypeMap.get(fuzzy);
|
|
3330
|
+
if (fuzzySupertypes) {
|
|
3331
|
+
fuzzySupertypes.forEach(function (supertype) { return supertypes_1.add(supertype); });
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
});
|
|
3335
|
+
}
|
|
3336
|
+
if (supertypes_1 && supertypes_1.size) {
|
|
3337
|
+
supertypes_1.forEach(function (supertype) {
|
|
3316
3338
|
var _a = _this.getTypePolicy(supertype), fields = _a.fields, rest = tslib.__rest(_a, ["fields"]);
|
|
3317
3339
|
Object.assign(policy_1, rest);
|
|
3318
3340
|
Object.assign(policy_1.fields, fields);
|
|
@@ -6402,12 +6424,18 @@ var ApolloClient = (function () {
|
|
|
6402
6424
|
return this.cache.readFragment(options, optimistic);
|
|
6403
6425
|
};
|
|
6404
6426
|
ApolloClient.prototype.writeQuery = function (options) {
|
|
6405
|
-
this.cache.writeQuery(options);
|
|
6406
|
-
|
|
6427
|
+
var ref = this.cache.writeQuery(options);
|
|
6428
|
+
if (options.broadcast !== false) {
|
|
6429
|
+
this.queryManager.broadcastQueries();
|
|
6430
|
+
}
|
|
6431
|
+
return ref;
|
|
6407
6432
|
};
|
|
6408
6433
|
ApolloClient.prototype.writeFragment = function (options) {
|
|
6409
|
-
this.cache.writeFragment(options);
|
|
6410
|
-
|
|
6434
|
+
var ref = this.cache.writeFragment(options);
|
|
6435
|
+
if (options.broadcast !== false) {
|
|
6436
|
+
this.queryManager.broadcastQueries();
|
|
6437
|
+
}
|
|
6438
|
+
return ref;
|
|
6411
6439
|
};
|
|
6412
6440
|
ApolloClient.prototype.__actionHookForDevTools = function (cb) {
|
|
6413
6441
|
this.devToolsHookCb = cb;
|
|
@@ -6793,7 +6821,7 @@ var InternalState = (function () {
|
|
|
6793
6821
|
}
|
|
6794
6822
|
};
|
|
6795
6823
|
var subscription = obsQuery.subscribe(onNext, onError);
|
|
6796
|
-
return function () { return subscription.unsubscribe(); };
|
|
6824
|
+
return function () { return setTimeout(function () { return subscription.unsubscribe(); }); };
|
|
6797
6825
|
}, [
|
|
6798
6826
|
obsQuery,
|
|
6799
6827
|
this.renderPromises,
|
|
@@ -7060,8 +7088,9 @@ function useMutation(mutation, options) {
|
|
|
7060
7088
|
}
|
|
7061
7089
|
var execute = React.useCallback(function (executeOptions) {
|
|
7062
7090
|
if (executeOptions === void 0) { executeOptions = {}; }
|
|
7063
|
-
var _a = ref.current,
|
|
7091
|
+
var _a = ref.current, options = _a.options, mutation = _a.mutation;
|
|
7064
7092
|
var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
|
|
7093
|
+
var client = executeOptions.client || ref.current.client;
|
|
7065
7094
|
if (!ref.current.result.loading && !baseOptions.ignoreResults && ref.current.isMounted) {
|
|
7066
7095
|
setResult(ref.current.result = {
|
|
7067
7096
|
loading: true,
|
|
@@ -7328,10 +7357,12 @@ var useIsomorphicLayoutEffect = canUseLayoutEffect
|
|
|
7328
7357
|
? React.useLayoutEffect
|
|
7329
7358
|
: React.useEffect;
|
|
7330
7359
|
|
|
7331
|
-
function useSuspenseCache() {
|
|
7332
|
-
var
|
|
7333
|
-
|
|
7334
|
-
|
|
7360
|
+
function useSuspenseCache(override) {
|
|
7361
|
+
var context = React.useContext(getApolloContext());
|
|
7362
|
+
var suspenseCache = override || context.suspenseCache;
|
|
7363
|
+
__DEV__ ? tsInvariant.invariant(suspenseCache, 'Could not find a "suspenseCache" in the context or passed in as an option. ' +
|
|
7364
|
+
'Wrap the root component in an <ApolloProvider> and provide a suspenseCache, ' +
|
|
7365
|
+
'or pass a SuspenseCache instance in via options.') : tsInvariant.invariant(suspenseCache, 33);
|
|
7335
7366
|
return suspenseCache;
|
|
7336
7367
|
}
|
|
7337
7368
|
|
|
@@ -7346,7 +7377,7 @@ var DEFAULT_SUSPENSE_POLICY = 'always';
|
|
|
7346
7377
|
var DEFAULT_ERROR_POLICY = 'none';
|
|
7347
7378
|
function useSuspenseQuery_experimental(query, options) {
|
|
7348
7379
|
if (options === void 0) { options = Object.create(null); }
|
|
7349
|
-
var suspenseCache = useSuspenseCache();
|
|
7380
|
+
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
7350
7381
|
var client = useApolloClient(options.client);
|
|
7351
7382
|
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options, client: client });
|
|
7352
7383
|
var previousWatchQueryOptionsRef = React.useRef(watchQueryOptions);
|
|
@@ -7472,6 +7503,7 @@ function useIsDeferred(query) {
|
|
|
7472
7503
|
function useObservableQueryResult(observable) {
|
|
7473
7504
|
var resultRef = React.useRef();
|
|
7474
7505
|
var isMountedRef = React.useRef(false);
|
|
7506
|
+
var subscribeTimeoutRef = React.useRef();
|
|
7475
7507
|
if (!resultRef.current) {
|
|
7476
7508
|
resultRef.current = observable.getCurrentResult();
|
|
7477
7509
|
}
|
|
@@ -7482,6 +7514,7 @@ function useObservableQueryResult(observable) {
|
|
|
7482
7514
|
};
|
|
7483
7515
|
}, []);
|
|
7484
7516
|
return useSyncExternalStore(React.useCallback(function (forceUpdate) {
|
|
7517
|
+
clearTimeout(subscribeTimeoutRef.current);
|
|
7485
7518
|
function handleUpdate() {
|
|
7486
7519
|
var previousResult = resultRef.current;
|
|
7487
7520
|
var result = observable.getCurrentResult();
|
|
@@ -7495,12 +7528,15 @@ function useObservableQueryResult(observable) {
|
|
|
7495
7528
|
forceUpdate();
|
|
7496
7529
|
}
|
|
7497
7530
|
}
|
|
7498
|
-
var subscription
|
|
7499
|
-
|
|
7500
|
-
|
|
7531
|
+
var subscription;
|
|
7532
|
+
subscribeTimeoutRef.current = setTimeout(function () {
|
|
7533
|
+
subscription = observable.subscribe({
|
|
7534
|
+
next: handleUpdate,
|
|
7535
|
+
error: handleUpdate,
|
|
7536
|
+
});
|
|
7501
7537
|
});
|
|
7502
7538
|
return function () {
|
|
7503
|
-
subscription.unsubscribe();
|
|
7539
|
+
subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
|
|
7504
7540
|
};
|
|
7505
7541
|
}, [observable]), function () { return resultRef.current; }, function () { return resultRef.current; });
|
|
7506
7542
|
}
|