@apollo/client 3.8.4 → 3.8.6
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/apollo-client.cjs +168 -149
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +46 -11
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +46 -11
- package/cache/core/types/common.d.ts +2 -2
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/entityStore.js +35 -0
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.js +3 -3
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +10 -11
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +0 -2
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +0 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +11 -11
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +27 -30
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +27 -30
- package/dev/dev.cjs +124 -100
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +124 -100
- package/dev/loadErrorMessageHandler.js +2 -2
- package/dev/loadErrorMessageHandler.js.map +1 -1
- package/invariantErrorCodes.js +95 -80
- package/link/core/ApolloLink.js +2 -2
- package/link/core/core.cjs +2 -2
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +2 -2
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/http.cjs +3 -3
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +3 -3
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/persisted-queries/persisted-queries.cjs +2 -2
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
- package/link/utils/toPromise.js +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js +1 -1
- package/package.json +22 -22
- package/react/cache/QueryReference.d.ts.map +1 -1
- package/react/cache/QueryReference.js +7 -2
- package/react/cache/QueryReference.js.map +1 -1
- package/react/cache/index.d.ts +0 -4
- package/react/cache/index.d.ts.map +1 -1
- package/react/cache/index.js +0 -14
- package/react/cache/index.js.map +1 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +3 -3
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +3 -3
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs +2 -2
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +2 -2
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs +15 -10
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +15 -10
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useQuery.js +1 -1
- package/react/hooks/useReadQuery.js +1 -1
- package/react/hooks/useSubscription.js +2 -2
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/index.d.ts +0 -1
- package/react/index.d.ts.map +1 -1
- package/react/index.js +0 -1
- package/react/index.js.map +1 -1
- package/react/parser/index.js +5 -5
- package/react/parser/parser.cjs +5 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +5 -5
- package/react/react.cjs +1 -218
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +1 -218
- package/react/types/types.d.ts +0 -3
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +1 -1
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +1 -1
- package/testing/core/mocking/mockLink.js +1 -1
- package/testing/internal/ObservableStream.d.ts +26 -0
- package/testing/internal/ObservableStream.d.ts.map +1 -0
- package/testing/internal/ObservableStream.js +101 -0
- package/testing/internal/ObservableStream.js.map +1 -0
- package/testing/internal/index.d.ts +1 -0
- package/testing/internal/index.d.ts.map +1 -1
- package/testing/internal/index.js +1 -0
- package/testing/internal/index.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +1 -0
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js +2 -1
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +2 -1
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +2 -1
- package/utilities/globals/globals.cjs +29 -19
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +29 -19
- package/utilities/globals/invariantWrappers.d.ts.map +1 -1
- package/utilities/globals/invariantWrappers.js +28 -18
- package/utilities/globals/invariantWrappers.js.map +1 -1
- package/utilities/graphql/DocumentTransform.js +1 -1
- package/utilities/graphql/directives.js +4 -4
- package/utilities/graphql/fragments.js +3 -3
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.d.ts +5 -0
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.js +2 -2
- package/utilities/index.d.ts +1 -1
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js.map +1 -1
- package/utilities/observables/asyncMap.d.ts.map +1 -1
- package/utilities/observables/asyncMap.js +17 -34
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/utilities.cjs +36 -53
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +36 -53
- package/version.js +1 -1
|
@@ -6,7 +6,7 @@ export function getFragmentQueryDocument(document, fragmentName) {
|
|
|
6
6
|
document.definitions.forEach(function (definition) {
|
|
7
7
|
if (definition.kind === "OperationDefinition") {
|
|
8
8
|
throw newInvariantError(
|
|
9
|
-
|
|
9
|
+
70,
|
|
10
10
|
definition.operation,
|
|
11
11
|
definition.name ? " named '".concat(definition.name.value, "'") : ""
|
|
12
12
|
);
|
|
@@ -16,7 +16,7 @@ export function getFragmentQueryDocument(document, fragmentName) {
|
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
if (typeof actualFragmentName === "undefined") {
|
|
19
|
-
invariant(fragments.length === 1,
|
|
19
|
+
invariant(fragments.length === 1, 71, fragments.length);
|
|
20
20
|
actualFragmentName = fragments[0].name.value;
|
|
21
21
|
}
|
|
22
22
|
var query = __assign(__assign({}, document), { definitions: __spreadArray([
|
|
@@ -57,7 +57,7 @@ export function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
57
57
|
return fragmentMap(fragmentName);
|
|
58
58
|
}
|
|
59
59
|
var fragment = fragmentMap && fragmentMap[fragmentName];
|
|
60
|
-
invariant(fragment,
|
|
60
|
+
invariant(fragment, 72, fragmentName);
|
|
61
61
|
return fragment || null;
|
|
62
62
|
}
|
|
63
63
|
default:
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { invariant, newInvariantError } from "../globals/index.js";
|
|
2
2
|
import { valueToObjectRepresentation } from "./storeUtils.js";
|
|
3
3
|
export function checkDocument(doc) {
|
|
4
|
-
invariant(doc && doc.kind === "Document",
|
|
4
|
+
invariant(doc && doc.kind === "Document", 73);
|
|
5
5
|
var operations = doc.definitions
|
|
6
6
|
.filter(function (d) { return d.kind !== "FragmentDefinition"; })
|
|
7
7
|
.map(function (definition) {
|
|
8
8
|
if (definition.kind !== "OperationDefinition") {
|
|
9
|
-
throw newInvariantError(
|
|
9
|
+
throw newInvariantError(74, definition.kind);
|
|
10
10
|
}
|
|
11
11
|
return definition;
|
|
12
12
|
});
|
|
13
|
-
invariant(operations.length <= 1,
|
|
13
|
+
invariant(operations.length <= 1, 75, operations.length);
|
|
14
14
|
return doc;
|
|
15
15
|
}
|
|
16
16
|
export function getOperationDefinition(doc) {
|
|
@@ -33,14 +33,14 @@ export function getFragmentDefinitions(doc) {
|
|
|
33
33
|
}
|
|
34
34
|
export function getQueryDefinition(doc) {
|
|
35
35
|
var queryDef = getOperationDefinition(doc);
|
|
36
|
-
invariant(queryDef && queryDef.operation === "query",
|
|
36
|
+
invariant(queryDef && queryDef.operation === "query", 76);
|
|
37
37
|
return queryDef;
|
|
38
38
|
}
|
|
39
39
|
export function getFragmentDefinition(doc) {
|
|
40
|
-
invariant(doc.kind === "Document",
|
|
41
|
-
invariant(doc.definitions.length <= 1,
|
|
40
|
+
invariant(doc.kind === "Document", 77);
|
|
41
|
+
invariant(doc.definitions.length <= 1, 78);
|
|
42
42
|
var fragmentDef = doc.definitions[0];
|
|
43
|
-
invariant(fragmentDef.kind === "FragmentDefinition",
|
|
43
|
+
invariant(fragmentDef.kind === "FragmentDefinition", 79);
|
|
44
44
|
return fragmentDef;
|
|
45
45
|
}
|
|
46
46
|
export function getMainDefinition(queryDoc) {
|
|
@@ -63,7 +63,7 @@ export function getMainDefinition(queryDoc) {
|
|
|
63
63
|
if (fragmentDefinition) {
|
|
64
64
|
return fragmentDefinition;
|
|
65
65
|
}
|
|
66
|
-
throw newInvariantError(
|
|
66
|
+
throw newInvariantError(80);
|
|
67
67
|
}
|
|
68
68
|
export function getDefaultValues(definition) {
|
|
69
69
|
var defaultValues = Object.create(null);
|
|
@@ -10,6 +10,11 @@ export interface StoreObject {
|
|
|
10
10
|
__typename?: string;
|
|
11
11
|
[storeFieldName: string]: StoreValue;
|
|
12
12
|
}
|
|
13
|
+
export type AsStoreObject<T extends {
|
|
14
|
+
__typename?: string;
|
|
15
|
+
}> = {
|
|
16
|
+
[K in keyof T]: T[K];
|
|
17
|
+
};
|
|
13
18
|
export declare function isDocumentNode(value: any): value is DocumentNode;
|
|
14
19
|
export declare function valueToObjectRepresentation(argObj: any, name: NameNode, value: ValueNode, variables?: Object): void;
|
|
15
20
|
export declare function storeKeyNameFromField(field: FieldNode, variables?: Object): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storeUtils.d.ts","sourceRoot":"","sources":["../../../src/utilities/graphql/storeUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EAST,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,YAAY,EAEb,MAAM,SAAS,CAAC;AAGjB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,CAEnD;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,SAAS,CAItD;AAED,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,MAAM,GACN,MAAM,EAAE,GACR,SAAS,GACT,SAAS,EAAE,GACX,IAAI,GACJ,SAAS,GACT,IAAI,GACJ,MAAM,CAAC;AAEX,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,cAAc,EAAE,MAAM,GAAG,UAAU,CAAC;CACtC;
|
|
1
|
+
{"version":3,"file":"storeUtils.d.ts","sourceRoot":"","sources":["../../../src/utilities/graphql/storeUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EAST,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,QAA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AAM,EAAE,GAAG,CAAC,GAAG,IAAI,eACpB,UAAU,KACtB,MAAM;oBAmDS,gBAAgB,WAUa,GAAG,KAAG,MAAM;CAJ5D,CAAC;AAIF,QAAA,IAAI,SAAS,UAAoC,GAAG,KAAG,MAEtD,CAAC;AAiBF,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,SAAS,GAAG,aAAa,EAChC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC9B,MAAM,GAAG,IAAI,CASf;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAE/D;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,YAAY,EAAE,gBAAgB,EAC9B,WAAW,CAAC,EAAE,WAAW,GACxB,MAAM,GAAG,SAAS,CA4BpB;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,aAAa,GAAG,SAAS,IAAI,SAAS,CAExE;AAED,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,aAAa,GACvB,SAAS,IAAI,kBAAkB,CAEjC;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,GAAG,CAAC"}
|
|
@@ -71,7 +71,7 @@ export function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
71
71
|
argObj[name.value] = null;
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
74
|
-
throw newInvariantError(
|
|
74
|
+
throw newInvariantError(81, name.value, value.kind);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
export function storeKeyNameFromField(field, variables) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storeUtils.js","sourceRoot":"","sources":["../../../src/utilities/graphql/storeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAuBxD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAs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AC,CAAC;aAClD;SACF;aAAM,IAAI,SAAS,EAAE;YACpB,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC3B;aAAM;YACL,SAAS,GAAG,CAAC,SAAS,CAAC,CAAC;SACzB;KACF;IACD,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ,EAAE;QACzC,OAAO,MAAM,CAAC,UAAU,CAAC;KAC1B;IACD,IAAI,SAAS,EAAE;QACb,KAAwB,UAAS,EAAT,uBAAS,EAAT,uBAAS,EAAT,IAAS,EAAE;YAA9B,IAAM,SAAS,kBAAA;YAClB,IAAM,QAAQ,GAAG,qBAAqB,CACpC,MAAM,EACN,wBAAwB,CAAC,SAAS,EAAE,WAAW,CAAE,CAAC,YAAY,EAC9D,WAAW,CACZ,CAAC;YACF,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;gBAChC,OAAO,QAAQ,CAAC;aACjB;SACF;KACF;AACH,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,SAAwB;IAC9C,OAAO,SAAS,CAAC,IAAI,KAAK,OAAO,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,SAAwB;IAExB,OAAO,SAAS,CAAC,IAAI,KAAK,gBAAgB,CAAC;AAC7C,CAAC","sourcesContent":["import { newInvariantError } from \"../globals/index.js\";\n\nimport type {\n DirectiveNode,\n FieldNode,\n IntValueNode,\n FloatValueNode,\n StringValueNode,\n BooleanValueNode,\n ObjectValueNode,\n ListValueNode,\n EnumValueNode,\n NullValueNode,\n VariableNode,\n InlineFragmentNode,\n ValueNode,\n SelectionNode,\n NameNode,\n SelectionSetNode,\n DocumentNode,\n FragmentSpreadNode,\n} from \"graphql\";\n\nimport { isNonNullObject } from \"../common/objects.js\";\nimport type { FragmentMap } from \"./fragments.js\";\nimport { getFragmentFromSelection } from \"./fragments.js\";\n\nexport interface Reference {\n readonly __ref: string;\n}\n\nexport function makeReference(id: string): Reference {\n return { __ref: String(id) };\n}\n\nexport function isReference(obj: any): obj is Reference {\n return Boolean(\n obj && typeof obj === \"object\" && typeof obj.__ref === \"string\"\n );\n}\n\nexport type StoreValue =\n | number\n | string\n | string[]\n | Reference\n | Reference[]\n | null\n | undefined\n | void\n | Object;\n\nexport interface StoreObject {\n __typename?: string;\n [storeFieldName: string]: StoreValue;\n}\n\nexport function isDocumentNode(value: any): value is DocumentNode {\n return (\n isNonNullObject(value) &&\n (value as DocumentNode).kind === \"Document\" &&\n Array.isArray((value as DocumentNode).definitions)\n );\n}\n\nfunction isStringValue(value: ValueNode): value is StringValueNode {\n return value.kind === \"StringValue\";\n}\n\nfunction isBooleanValue(value: ValueNode): value is BooleanValueNode {\n return value.kind === \"BooleanValue\";\n}\n\nfunction isIntValue(value: ValueNode): value is IntValueNode {\n return value.kind === \"IntValue\";\n}\n\nfunction isFloatValue(value: ValueNode): value is FloatValueNode {\n return value.kind === \"FloatValue\";\n}\n\nfunction isVariable(value: ValueNode): value is VariableNode {\n return value.kind === \"Variable\";\n}\n\nfunction isObjectValue(value: ValueNode): value is ObjectValueNode {\n return value.kind === \"ObjectValue\";\n}\n\nfunction isListValue(value: ValueNode): value is ListValueNode {\n return value.kind === \"ListValue\";\n}\n\nfunction isEnumValue(value: ValueNode): value is EnumValueNode {\n return value.kind === \"EnumValue\";\n}\n\nfunction isNullValue(value: ValueNode): value is NullValueNode {\n return value.kind === \"NullValue\";\n}\n\nexport function valueToObjectRepresentation(\n argObj: any,\n name: NameNode,\n value: ValueNode,\n variables?: Object\n) {\n if (isIntValue(value) || isFloatValue(value)) {\n argObj[name.value] = Number(value.value);\n } else if (isBooleanValue(value) || isStringValue(value)) {\n argObj[name.value] = value.value;\n } else if (isObjectValue(value)) {\n const nestedArgObj = {};\n value.fields.map((obj) =>\n valueToObjectRepresentation(nestedArgObj, obj.name, obj.value, variables)\n );\n argObj[name.value] = nestedArgObj;\n } else if (isVariable(value)) {\n const variableValue = (variables || ({} as any))[value.name.value];\n argObj[name.value] = variableValue;\n } else if (isListValue(value)) {\n argObj[name.value] = value.values.map((listValue) => {\n const nestedArgArrayObj = {};\n valueToObjectRepresentation(\n nestedArgArrayObj,\n name,\n listValue,\n variables\n );\n return (nestedArgArrayObj as any)[name.value];\n });\n } else if (isEnumValue(value)) {\n argObj[name.value] = (value as EnumValueNode).value;\n } else if (isNullValue(value)) {\n argObj[name.value] = null;\n } else {\n throw newInvariantError(\n `The inline argument \"%s\" of kind \"%s\"` +\n \"is not supported. Use variables instead of inline arguments to \" +\n \"overcome this limitation.\",\n name.value,\n (value as any).kind\n );\n }\n}\n\nexport function storeKeyNameFromField(\n field: FieldNode,\n variables?: Object\n): string {\n let directivesObj: any = null;\n if (field.directives) {\n directivesObj = {};\n field.directives.forEach((directive) => {\n directivesObj[directive.name.value] = {};\n\n if (directive.arguments) {\n directive.arguments.forEach(({ name, value }) =>\n valueToObjectRepresentation(\n directivesObj[directive.name.value],\n name,\n value,\n variables\n )\n );\n }\n });\n }\n\n let argObj: any = null;\n if (field.arguments && field.arguments.length) {\n argObj = {};\n field.arguments.forEach(({ name, value }) =>\n valueToObjectRepresentation(argObj, name, value, variables)\n );\n }\n\n return getStoreKeyName(field.name.value, argObj, directivesObj);\n}\n\nexport type Directives = {\n [directiveName: string]: {\n [argName: string]: any;\n };\n};\n\nconst KNOWN_DIRECTIVES: string[] = [\n \"connection\",\n \"include\",\n \"skip\",\n \"client\",\n \"rest\",\n \"export\",\n \"nonreactive\",\n];\n\nexport const getStoreKeyName = Object.assign(\n function (\n fieldName: string,\n args?: Record<string, any> | null,\n directives?: Directives\n ): string {\n if (\n args &&\n directives &&\n directives[\"connection\"] &&\n directives[\"connection\"][\"key\"]\n ) {\n if (\n directives[\"connection\"][\"filter\"] &&\n (directives[\"connection\"][\"filter\"] as string[]).length > 0\n ) {\n const filterKeys = directives[\"connection\"][\"filter\"]\n ? (directives[\"connection\"][\"filter\"] as string[])\n : [];\n filterKeys.sort();\n\n const filteredArgs = {} as { [key: string]: any };\n filterKeys.forEach((key) => {\n filteredArgs[key] = args[key];\n });\n\n return `${directives[\"connection\"][\"key\"]}(${stringify(filteredArgs)})`;\n } else {\n return directives[\"connection\"][\"key\"];\n }\n }\n\n let completeFieldName: string = fieldName;\n\n if (args) {\n // We can't use `JSON.stringify` here since it's non-deterministic,\n // and can lead to different store key names being created even though\n // the `args` object used during creation has the same properties/values.\n const stringifiedArgs: string = stringify(args);\n completeFieldName += `(${stringifiedArgs})`;\n }\n\n if (directives) {\n Object.keys(directives).forEach((key) => {\n if (KNOWN_DIRECTIVES.indexOf(key) !== -1) return;\n if (directives[key] && Object.keys(directives[key]).length) {\n completeFieldName += `@${key}(${stringify(directives[key])})`;\n } else {\n completeFieldName += `@${key}`;\n }\n });\n }\n\n return completeFieldName;\n },\n {\n setStringify(s: typeof stringify) {\n const previous = stringify;\n stringify = s;\n return previous;\n },\n }\n);\n\n// Default stable JSON.stringify implementation. Can be updated/replaced with\n// something better by calling getStoreKeyName.setStringify.\nlet stringify = function defaultStringify(value: any): string {\n return JSON.stringify(value, stringifyReplacer);\n};\n\nfunction stringifyReplacer(_key: string, value: any): any {\n if (isNonNullObject(value) && !Array.isArray(value)) {\n value = Object.keys(value)\n .sort()\n .reduce(\n (copy, key) => {\n copy[key] = value[key];\n return copy;\n },\n {} as Record<string, any>\n );\n }\n return value;\n}\n\nexport function argumentsObjectFromField(\n field: FieldNode | DirectiveNode,\n variables?: Record<string, any>\n): Object | null {\n if (field.arguments && field.arguments.length) {\n const argObj: Object = {};\n field.arguments.forEach(({ name, value }) =>\n valueToObjectRepresentation(argObj, name, value, variables)\n );\n return argObj;\n }\n return null;\n}\n\nexport function resultKeyNameFromField(field: FieldNode): string {\n return field.alias ? field.alias.value : field.name.value;\n}\n\nexport function getTypenameFromResult(\n result: Record<string, any>,\n selectionSet: SelectionSetNode,\n fragmentMap?: FragmentMap\n): string | undefined {\n let fragments: undefined | Array<InlineFragmentNode | FragmentSpreadNode>;\n for (const selection of selectionSet.selections) {\n if (isField(selection)) {\n if (selection.name.value === \"__typename\") {\n return result[resultKeyNameFromField(selection)];\n }\n } else if (fragments) {\n fragments.push(selection);\n } else {\n fragments = [selection];\n }\n }\n if (typeof result.__typename === \"string\") {\n return result.__typename;\n }\n if (fragments) {\n for (const selection of fragments) {\n const typename = getTypenameFromResult(\n result,\n getFragmentFromSelection(selection, fragmentMap)!.selectionSet,\n fragmentMap\n );\n if (typeof typename === \"string\") {\n return typename;\n }\n }\n }\n}\n\nexport function isField(selection: SelectionNode): selection is FieldNode {\n return selection.kind === \"Field\";\n}\n\nexport function isInlineFragment(\n selection: SelectionNode\n): selection is InlineFragmentNode {\n return selection.kind === \"InlineFragment\";\n}\n\nexport type VariableValue = (node: VariableNode) => any;\n"]}
|
|
1
|
+
{"version":3,"file":"storeUtils.js","sourceRoot":"","sources":["../../../src/utilities/graphql/storeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAuBxD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAM1D,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAQ;IAClC,OAAO,OAAO,CACZ,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,CAChE,CAAC;AACJ,CAAC;AAoCD,MAAM,UAAU,cAAc,CAAC,KAAU;IACvC,OAAO,CACL,eAAe,CAAC,KAAK,CAAC;QACrB,KAAsB,CAAC,IAAI,KAAK,UAAU;QAC3C,KAAK,CAAC,OAAO,CAAE,KAAsB,CAAC,WAAW,CAAC,CACnD,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,KAAgB;IACrC,OAAO,KAAK,CAAC,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MAAM,UAAU,OAAO,CAAC,SAAwB;IAC9C,OAAO,SAAS,CAAC,IAAI,KAAK,OAAO,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,SAAwB;IAExB,OAAO,SAAS,CAAC,IAAI,KAAK,gBAAgB,CAAC;AAC7C,CAAC","sourcesContent":["import { newInvariantError } from \"../globals/index.js\";\n\nimport type {\n DirectiveNode,\n FieldNode,\n IntValueNode,\n FloatValueNode,\n StringValueNode,\n BooleanValueNode,\n ObjectValueNode,\n ListValueNode,\n EnumValueNode,\n NullValueNode,\n VariableNode,\n InlineFragmentNode,\n ValueNode,\n SelectionNode,\n NameNode,\n SelectionSetNode,\n DocumentNode,\n FragmentSpreadNode,\n} from \"graphql\";\n\nimport { isNonNullObject } from \"../common/objects.js\";\nimport type { FragmentMap } from \"./fragments.js\";\nimport { getFragmentFromSelection } from \"./fragments.js\";\n\nexport interface Reference {\n readonly __ref: string;\n}\n\nexport function makeReference(id: string): Reference {\n return { __ref: String(id) };\n}\n\nexport function isReference(obj: any): obj is Reference {\n return Boolean(\n obj && typeof obj === \"object\" && typeof obj.__ref === \"string\"\n );\n}\n\nexport type StoreValue =\n | number\n | string\n | string[]\n | Reference\n | Reference[]\n | null\n | undefined\n | void\n | Object;\n\nexport interface StoreObject {\n __typename?: string;\n [storeFieldName: string]: StoreValue;\n}\n\n/**\n * Workaround for a TypeScript quirk:\n * types per default have an implicit index signature that makes them\n * assignable to `StoreObject`.\n * interfaces do not have that implicit index signature, so they cannot\n * be assigned to `StoreObject`.\n * This type just maps over a type or interface that is passed in,\n * implicitly adding the index signature.\n * That way, the result can be assigned to `StoreObject`.\n *\n * This is important if some user-defined interface is used e.g.\n * in cache.modify, where the `toReference` method expects a\n * `StoreObject` as input.\n */\nexport type AsStoreObject<T extends { __typename?: string }> = {\n [K in keyof T]: T[K];\n};\n\nexport function isDocumentNode(value: any): value is DocumentNode {\n return (\n isNonNullObject(value) &&\n (value as DocumentNode).kind === \"Document\" &&\n Array.isArray((value as DocumentNode).definitions)\n );\n}\n\nfunction isStringValue(value: ValueNode): value is StringValueNode {\n return value.kind === \"StringValue\";\n}\n\nfunction isBooleanValue(value: ValueNode): value is BooleanValueNode {\n return value.kind === \"BooleanValue\";\n}\n\nfunction isIntValue(value: ValueNode): value is IntValueNode {\n return value.kind === \"IntValue\";\n}\n\nfunction isFloatValue(value: ValueNode): value is FloatValueNode {\n return value.kind === \"FloatValue\";\n}\n\nfunction isVariable(value: ValueNode): value is VariableNode {\n return value.kind === \"Variable\";\n}\n\nfunction isObjectValue(value: ValueNode): value is ObjectValueNode {\n return value.kind === \"ObjectValue\";\n}\n\nfunction isListValue(value: ValueNode): value is ListValueNode {\n return value.kind === \"ListValue\";\n}\n\nfunction isEnumValue(value: ValueNode): value is EnumValueNode {\n return value.kind === \"EnumValue\";\n}\n\nfunction isNullValue(value: ValueNode): value is NullValueNode {\n return value.kind === \"NullValue\";\n}\n\nexport function valueToObjectRepresentation(\n argObj: any,\n name: NameNode,\n value: ValueNode,\n variables?: Object\n) {\n if (isIntValue(value) || isFloatValue(value)) {\n argObj[name.value] = Number(value.value);\n } else if (isBooleanValue(value) || isStringValue(value)) {\n argObj[name.value] = value.value;\n } else if (isObjectValue(value)) {\n const nestedArgObj = {};\n value.fields.map((obj) =>\n valueToObjectRepresentation(nestedArgObj, obj.name, obj.value, variables)\n );\n argObj[name.value] = nestedArgObj;\n } else if (isVariable(value)) {\n const variableValue = (variables || ({} as any))[value.name.value];\n argObj[name.value] = variableValue;\n } else if (isListValue(value)) {\n argObj[name.value] = value.values.map((listValue) => {\n const nestedArgArrayObj = {};\n valueToObjectRepresentation(\n nestedArgArrayObj,\n name,\n listValue,\n variables\n );\n return (nestedArgArrayObj as any)[name.value];\n });\n } else if (isEnumValue(value)) {\n argObj[name.value] = (value as EnumValueNode).value;\n } else if (isNullValue(value)) {\n argObj[name.value] = null;\n } else {\n throw newInvariantError(\n `The inline argument \"%s\" of kind \"%s\"` +\n \"is not supported. Use variables instead of inline arguments to \" +\n \"overcome this limitation.\",\n name.value,\n (value as any).kind\n );\n }\n}\n\nexport function storeKeyNameFromField(\n field: FieldNode,\n variables?: Object\n): string {\n let directivesObj: any = null;\n if (field.directives) {\n directivesObj = {};\n field.directives.forEach((directive) => {\n directivesObj[directive.name.value] = {};\n\n if (directive.arguments) {\n directive.arguments.forEach(({ name, value }) =>\n valueToObjectRepresentation(\n directivesObj[directive.name.value],\n name,\n value,\n variables\n )\n );\n }\n });\n }\n\n let argObj: any = null;\n if (field.arguments && field.arguments.length) {\n argObj = {};\n field.arguments.forEach(({ name, value }) =>\n valueToObjectRepresentation(argObj, name, value, variables)\n );\n }\n\n return getStoreKeyName(field.name.value, argObj, directivesObj);\n}\n\nexport type Directives = {\n [directiveName: string]: {\n [argName: string]: any;\n };\n};\n\nconst KNOWN_DIRECTIVES: string[] = [\n \"connection\",\n \"include\",\n \"skip\",\n \"client\",\n \"rest\",\n \"export\",\n \"nonreactive\",\n];\n\nexport const getStoreKeyName = Object.assign(\n function (\n fieldName: string,\n args?: Record<string, any> | null,\n directives?: Directives\n ): string {\n if (\n args &&\n directives &&\n directives[\"connection\"] &&\n directives[\"connection\"][\"key\"]\n ) {\n if (\n directives[\"connection\"][\"filter\"] &&\n (directives[\"connection\"][\"filter\"] as string[]).length > 0\n ) {\n const filterKeys = directives[\"connection\"][\"filter\"]\n ? (directives[\"connection\"][\"filter\"] as string[])\n : [];\n filterKeys.sort();\n\n const filteredArgs = {} as { [key: string]: any };\n filterKeys.forEach((key) => {\n filteredArgs[key] = args[key];\n });\n\n return `${directives[\"connection\"][\"key\"]}(${stringify(filteredArgs)})`;\n } else {\n return directives[\"connection\"][\"key\"];\n }\n }\n\n let completeFieldName: string = fieldName;\n\n if (args) {\n // We can't use `JSON.stringify` here since it's non-deterministic,\n // and can lead to different store key names being created even though\n // the `args` object used during creation has the same properties/values.\n const stringifiedArgs: string = stringify(args);\n completeFieldName += `(${stringifiedArgs})`;\n }\n\n if (directives) {\n Object.keys(directives).forEach((key) => {\n if (KNOWN_DIRECTIVES.indexOf(key) !== -1) return;\n if (directives[key] && Object.keys(directives[key]).length) {\n completeFieldName += `@${key}(${stringify(directives[key])})`;\n } else {\n completeFieldName += `@${key}`;\n }\n });\n }\n\n return completeFieldName;\n },\n {\n setStringify(s: typeof stringify) {\n const previous = stringify;\n stringify = s;\n return previous;\n },\n }\n);\n\n// Default stable JSON.stringify implementation. Can be updated/replaced with\n// something better by calling getStoreKeyName.setStringify.\nlet stringify = function defaultStringify(value: any): string {\n return JSON.stringify(value, stringifyReplacer);\n};\n\nfunction stringifyReplacer(_key: string, value: any): any {\n if (isNonNullObject(value) && !Array.isArray(value)) {\n value = Object.keys(value)\n .sort()\n .reduce(\n (copy, key) => {\n copy[key] = value[key];\n return copy;\n },\n {} as Record<string, any>\n );\n }\n return value;\n}\n\nexport function argumentsObjectFromField(\n field: FieldNode | DirectiveNode,\n variables?: Record<string, any>\n): Object | null {\n if (field.arguments && field.arguments.length) {\n const argObj: Object = {};\n field.arguments.forEach(({ name, value }) =>\n valueToObjectRepresentation(argObj, name, value, variables)\n );\n return argObj;\n }\n return null;\n}\n\nexport function resultKeyNameFromField(field: FieldNode): string {\n return field.alias ? field.alias.value : field.name.value;\n}\n\nexport function getTypenameFromResult(\n result: Record<string, any>,\n selectionSet: SelectionSetNode,\n fragmentMap?: FragmentMap\n): string | undefined {\n let fragments: undefined | Array<InlineFragmentNode | FragmentSpreadNode>;\n for (const selection of selectionSet.selections) {\n if (isField(selection)) {\n if (selection.name.value === \"__typename\") {\n return result[resultKeyNameFromField(selection)];\n }\n } else if (fragments) {\n fragments.push(selection);\n } else {\n fragments = [selection];\n }\n }\n if (typeof result.__typename === \"string\") {\n return result.__typename;\n }\n if (fragments) {\n for (const selection of fragments) {\n const typename = getTypenameFromResult(\n result,\n getFragmentFromSelection(selection, fragmentMap)!.selectionSet,\n fragmentMap\n );\n if (typeof typename === \"string\") {\n return typename;\n }\n }\n }\n}\n\nexport function isField(selection: SelectionNode): selection is FieldNode {\n return selection.kind === \"Field\";\n}\n\nexport function isInlineFragment(\n selection: SelectionNode\n): selection is InlineFragmentNode {\n return selection.kind === \"InlineFragment\";\n}\n\nexport type VariableValue = (node: VariableNode) => any;\n"]}
|
|
@@ -78,7 +78,7 @@ export function removeDirectivesFromDocument(directives, doc) {
|
|
|
78
78
|
return getInUseByFragmentName(ancestor.name.value);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
globalThis.__DEV__ !== false && invariant.error(
|
|
81
|
+
globalThis.__DEV__ !== false && invariant.error(82);
|
|
82
82
|
return null;
|
|
83
83
|
};
|
|
84
84
|
var operationCount = 0;
|
|
@@ -265,7 +265,7 @@ var connectionRemoveConfig = {
|
|
|
265
265
|
if (willRemove) {
|
|
266
266
|
if (!directive.arguments ||
|
|
267
267
|
!directive.arguments.some(function (arg) { return arg.name.value === "key"; })) {
|
|
268
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
268
|
+
globalThis.__DEV__ !== false && invariant.warn(83);
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
return willRemove;
|
package/utilities/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type { FragmentMap, FragmentMapFunction } from "./graphql/fragments.js";
|
|
|
7
7
|
export { createFragmentMap, getFragmentQueryDocument, getFragmentFromSelection, } from "./graphql/fragments.js";
|
|
8
8
|
export { checkDocument, getOperationDefinition, getOperationName, getFragmentDefinitions, getQueryDefinition, getFragmentDefinition, getMainDefinition, getDefaultValues, } from "./graphql/getFromAST.js";
|
|
9
9
|
export { print } from "./graphql/print.js";
|
|
10
|
-
export type { StoreObject, Reference, StoreValue, Directives, VariableValue, } from "./graphql/storeUtils.js";
|
|
10
|
+
export type { StoreObject, AsStoreObject, Reference, StoreValue, Directives, VariableValue, } from "./graphql/storeUtils.js";
|
|
11
11
|
export { makeReference, isDocumentNode, isReference, isField, isInlineFragment, valueToObjectRepresentation, storeKeyNameFromField, argumentsObjectFromField, resultKeyNameFromField, getStoreKeyName, getTypenameFromResult, } from "./graphql/storeUtils.js";
|
|
12
12
|
export type { RemoveNodeConfig, GetNodeConfig, RemoveDirectiveConfig, GetDirectiveConfig, RemoveArgumentsConfig, GetFragmentSpreadConfig, RemoveFragmentSpreadConfig, RemoveFragmentDefinitionConfig, RemoveVariableDefinitionConfig, } from "./graphql/transform.js";
|
|
13
13
|
export { addTypenameToDocument, buildQueryFromSelectionSet, removeDirectivesFromDocument, removeConnectionDirectiveFromDocument, removeArgumentsFromDocument, removeFragmentSpreadFromDocument, removeClientSetsFromDocument, } from "./graphql/transform.js";
|
package/utilities/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,YAAY,EACV,aAAa,EACb,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,Y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AC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,cAAc,0BAA0B,CAAC;AACzC,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
|
package/utilities/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAMhD,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAMhD,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,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AAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,cAAc,0BAA0B,CAAC","sourcesContent":["export { DEV, maybe } from \"./globals/index.js\";\n\nexport type {\n DirectiveInfo,\n InclusionDirectives,\n} from \"./graphql/directives.js\";\nexport {\n shouldInclude,\n hasDirectives,\n hasAnyDirectives,\n hasAllDirectives,\n hasClientExports,\n getDirectiveNames,\n getInclusionDirectives,\n} from \"./graphql/directives.js\";\n\nexport type { DocumentTransformCacheKey } from \"./graphql/DocumentTransform.js\";\nexport { DocumentTransform } from \"./graphql/DocumentTransform.js\";\n\nexport type { FragmentMap, FragmentMapFunction } from \"./graphql/fragments.js\";\nexport {\n createFragmentMap,\n getFragmentQueryDocument,\n getFragmentFromSelection,\n} from \"./graphql/fragments.js\";\n\nexport {\n checkDocument,\n getOperationDefinition,\n getOperationName,\n getFragmentDefinitions,\n getQueryDefinition,\n getFragmentDefinition,\n getMainDefinition,\n getDefaultValues,\n} from \"./graphql/getFromAST.js\";\n\nexport { print } from \"./graphql/print.js\";\n\nexport type {\n StoreObject,\n AsStoreObject,\n Reference,\n StoreValue,\n Directives,\n VariableValue,\n} from \"./graphql/storeUtils.js\";\nexport {\n makeReference,\n isDocumentNode,\n isReference,\n isField,\n isInlineFragment,\n valueToObjectRepresentation,\n storeKeyNameFromField,\n argumentsObjectFromField,\n resultKeyNameFromField,\n getStoreKeyName,\n getTypenameFromResult,\n} from \"./graphql/storeUtils.js\";\n\nexport type {\n RemoveNodeConfig,\n GetNodeConfig,\n RemoveDirectiveConfig,\n GetDirectiveConfig,\n RemoveArgumentsConfig,\n GetFragmentSpreadConfig,\n RemoveFragmentSpreadConfig,\n RemoveFragmentDefinitionConfig,\n RemoveVariableDefinitionConfig,\n} from \"./graphql/transform.js\";\nexport {\n addTypenameToDocument,\n buildQueryFromSelectionSet,\n removeDirectivesFromDocument,\n removeConnectionDirectiveFromDocument,\n removeArgumentsFromDocument,\n removeFragmentSpreadFromDocument,\n removeClientSetsFromDocument,\n} from \"./graphql/transform.js\";\n\nexport {\n isMutationOperation,\n isQueryOperation,\n isSubscriptionOperation,\n} from \"./graphql/operations.js\";\n\nexport {\n concatPagination,\n offsetLimitPagination,\n relayStylePagination,\n} from \"./policies/pagination.js\";\n\nexport type {\n Observer,\n ObservableSubscription,\n} from \"./observables/Observable.js\";\nexport { Observable } from \"./observables/Observable.js\";\n\nexport {\n isStatefulPromise,\n createFulfilledPromise,\n createRejectedPromise,\n wrapPromiseWithState,\n} from \"./promises/decoration.js\";\n\nexport * from \"./common/mergeDeep.js\";\nexport * from \"./common/cloneDeep.js\";\nexport * from \"./common/maybeDeepFreeze.js\";\nexport * from \"./observables/iteration.js\";\nexport * from \"./observables/asyncMap.js\";\nexport * from \"./observables/Concast.js\";\nexport * from \"./observables/subclassing.js\";\nexport * from \"./common/arrays.js\";\nexport * from \"./common/objects.js\";\nexport * from \"./common/errorHandling.js\";\nexport * from \"./common/canUse.js\";\nexport * from \"./common/compact.js\";\nexport * from \"./common/makeUniqueId.js\";\nexport * from \"./common/stringifyForDisplay.js\";\nexport * from \"./common/mergeOptions.js\";\nexport * from \"./common/incrementalResult.js\";\n\nexport { omitDeep } from \"./common/omitDeep.js\";\nexport { stripTypename } from \"./common/stripTypename.js\";\n\nexport * from \"./types/IsStrictlyAny.js\";\nexport type { DeepOmit } from \"./types/DeepOmit.js\";\nexport type { DeepPartial } from \"./types/DeepPartial.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncMap.d.ts","sourceRoot":"","sources":["../../../src/utilities/observables/asyncMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EACvC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAC3C,UAAU,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"asyncMap.d.ts","sourceRoot":"","sources":["../../../src/utilities/observables/asyncMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EACvC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAC3C,UAAU,CAAC,CAAC,CAAC,CA+Cf"}
|
|
@@ -1,48 +1,31 @@
|
|
|
1
1
|
import { Observable } from "./Observable.js";
|
|
2
2
|
export function asyncMap(observable, mapFn, catchFn) {
|
|
3
3
|
return new Observable(function (observer) {
|
|
4
|
-
var next = observer.next, error = observer.error, complete = observer.complete;
|
|
5
|
-
var activeCallbackCount = 0;
|
|
6
|
-
var completed = false;
|
|
7
4
|
var promiseQueue = {
|
|
8
5
|
then: function (callback) {
|
|
9
6
|
return new Promise(function (resolve) { return resolve(callback()); });
|
|
10
7
|
},
|
|
11
8
|
};
|
|
12
|
-
function makeCallback(examiner,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
--activeCallbackCount;
|
|
27
|
-
throw error;
|
|
28
|
-
})
|
|
29
|
-
.catch(function (caught) {
|
|
30
|
-
error && error.call(observer, caught);
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return function (arg) { return delegate && delegate.call(observer, arg); };
|
|
36
|
-
}
|
|
9
|
+
function makeCallback(examiner, key) {
|
|
10
|
+
return function (arg) {
|
|
11
|
+
if (examiner) {
|
|
12
|
+
var both = function () {
|
|
13
|
+
return observer.closed
|
|
14
|
+
? 0
|
|
15
|
+
: examiner(arg);
|
|
16
|
+
};
|
|
17
|
+
promiseQueue = promiseQueue.then(both, both).then(function (result) { return observer.next(result); }, function (error) { return observer.error(error); });
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
observer[key](arg);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
37
23
|
}
|
|
38
24
|
var handler = {
|
|
39
|
-
next: makeCallback(mapFn, next),
|
|
40
|
-
error: makeCallback(catchFn, error),
|
|
25
|
+
next: makeCallback(mapFn, "next"),
|
|
26
|
+
error: makeCallback(catchFn, "error"),
|
|
41
27
|
complete: function () {
|
|
42
|
-
|
|
43
|
-
if (!activeCallbackCount) {
|
|
44
|
-
complete && complete.call(observer);
|
|
45
|
-
}
|
|
28
|
+
promiseQueue.then(function () { return observer.complete(); });
|
|
46
29
|
},
|
|
47
30
|
};
|
|
48
31
|
var sub = observable.subscribe(handler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncMap.js","sourceRoot":"","sources":["../../../src/utilities/observables/asyncMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,MAAM,UAAU,QAAQ,CACtB,UAAyB,EAC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AAO,CAAC;YACrC,QAAQ;gBAGc,YAAY,CAAC,IAAI,CAAC,cAAM,OAAA,QAAQ,CAAC,QAAQ,EAAE,EAAnB,CAAmB,CAAC,CAAC;YACnE,CAAC;SACF,CAAC;QAEF,IAAM,GAAG,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC1C,OAAO,cAAM,OAAA,GAAG,CAAC,WAAW,EAAE,EAAjB,CAAiB,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Observer } from \"./Observable.js\";\nimport { Observable } from \"./Observable.js\";\n\n// Like Observable.prototype.map, except that the mapping function can\n// optionally return a Promise (or be async).\nexport function asyncMap<V, R>(\n observable: Observable<V>,\n mapFn: (value: V) => R | PromiseLike<R>,\n catchFn?: (error: any) => R | PromiseLike<R>\n): Observable<R> {\n return new Observable<R>((observer) => {\n let promiseQueue = {\n // Normally we would initialize promiseQueue to Promise.resolve(), but\n // in this case, for backwards compatibility, we need to be careful to\n // invoke the first callback synchronously.\n then(callback: () => any) {\n return new Promise((resolve) => resolve(callback()));\n },\n } as Promise<void>;\n\n function makeCallback(\n examiner: typeof mapFn | typeof catchFn,\n key: \"next\" | \"error\"\n ): (arg: any) => void {\n return (arg) => {\n if (examiner) {\n const both = () =>\n // If the observer is closed, we don't want to continue calling the\n // mapping function - it's result will be swallowed anyways.\n observer.closed\n ? /* will be swallowed */ (0 as any)\n : examiner(arg);\n\n promiseQueue = promiseQueue.then(both, both).then(\n (result) => observer.next(result),\n (error) => observer.error(error)\n );\n } else {\n observer[key](arg);\n }\n };\n }\n\n const handler: Observer<V> = {\n next: makeCallback(mapFn, \"next\"),\n error: makeCallback(catchFn, \"error\"),\n complete() {\n // no need to reassign `promiseQueue`, after `observer.complete`,\n // the observer will be closed and short-circuit everything anyways\n /*promiseQueue = */ promiseQueue.then(() => observer.complete());\n },\n };\n\n const sub = observable.subscribe(handler);\n return () => sub.unsubscribe();\n });\n}\n"]}
|
package/utilities/utilities.cjs
CHANGED
|
@@ -20,7 +20,7 @@ function shouldInclude(_a, variables) {
|
|
|
20
20
|
if (ifArgument.value.kind === "Variable") {
|
|
21
21
|
evaledValue =
|
|
22
22
|
variables && variables[ifArgument.value.name.value];
|
|
23
|
-
globals.invariant(evaledValue !== void 0,
|
|
23
|
+
globals.invariant(evaledValue !== void 0, 66, directive.name.value);
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
26
|
evaledValue = ifArgument.value.value;
|
|
@@ -70,12 +70,12 @@ function getInclusionDirectives(directives) {
|
|
|
70
70
|
return;
|
|
71
71
|
var directiveArguments = directive.arguments;
|
|
72
72
|
var directiveName = directive.name.value;
|
|
73
|
-
globals.invariant(directiveArguments && directiveArguments.length === 1,
|
|
73
|
+
globals.invariant(directiveArguments && directiveArguments.length === 1, 67, directiveName);
|
|
74
74
|
var ifArgument = directiveArguments[0];
|
|
75
|
-
globals.invariant(ifArgument.name && ifArgument.name.value === "if",
|
|
75
|
+
globals.invariant(ifArgument.name && ifArgument.name.value === "if", 68, directiveName);
|
|
76
76
|
var ifValue = ifArgument.value;
|
|
77
77
|
globals.invariant(ifValue &&
|
|
78
|
-
(ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"),
|
|
78
|
+
(ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 69, directiveName);
|
|
79
79
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
80
80
|
});
|
|
81
81
|
}
|
|
@@ -107,7 +107,7 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
107
107
|
document.definitions.forEach(function (definition) {
|
|
108
108
|
if (definition.kind === "OperationDefinition") {
|
|
109
109
|
throw globals.newInvariantError(
|
|
110
|
-
|
|
110
|
+
70,
|
|
111
111
|
definition.operation,
|
|
112
112
|
definition.name ? " named '".concat(definition.name.value, "'") : ""
|
|
113
113
|
);
|
|
@@ -117,7 +117,7 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
if (typeof actualFragmentName === "undefined") {
|
|
120
|
-
globals.invariant(fragments.length === 1,
|
|
120
|
+
globals.invariant(fragments.length === 1, 71, fragments.length);
|
|
121
121
|
actualFragmentName = fragments[0].name.value;
|
|
122
122
|
}
|
|
123
123
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -158,7 +158,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
158
158
|
return fragmentMap(fragmentName);
|
|
159
159
|
}
|
|
160
160
|
var fragment = fragmentMap && fragmentMap[fragmentName];
|
|
161
|
-
globals.invariant(fragment,
|
|
161
|
+
globals.invariant(fragment, 72, fragmentName);
|
|
162
162
|
return fragment || null;
|
|
163
163
|
}
|
|
164
164
|
default:
|
|
@@ -236,7 +236,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
236
236
|
argObj[name.value] = null;
|
|
237
237
|
}
|
|
238
238
|
else {
|
|
239
|
-
throw globals.newInvariantError(
|
|
239
|
+
throw globals.newInvariantError(81, name.value, value.kind);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -383,16 +383,16 @@ function isInlineFragment(selection) {
|
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
function checkDocument(doc) {
|
|
386
|
-
globals.invariant(doc && doc.kind === "Document",
|
|
386
|
+
globals.invariant(doc && doc.kind === "Document", 73);
|
|
387
387
|
var operations = doc.definitions
|
|
388
388
|
.filter(function (d) { return d.kind !== "FragmentDefinition"; })
|
|
389
389
|
.map(function (definition) {
|
|
390
390
|
if (definition.kind !== "OperationDefinition") {
|
|
391
|
-
throw globals.newInvariantError(
|
|
391
|
+
throw globals.newInvariantError(74, definition.kind);
|
|
392
392
|
}
|
|
393
393
|
return definition;
|
|
394
394
|
});
|
|
395
|
-
globals.invariant(operations.length <= 1,
|
|
395
|
+
globals.invariant(operations.length <= 1, 75, operations.length);
|
|
396
396
|
return doc;
|
|
397
397
|
}
|
|
398
398
|
function getOperationDefinition(doc) {
|
|
@@ -415,14 +415,14 @@ function getFragmentDefinitions(doc) {
|
|
|
415
415
|
}
|
|
416
416
|
function getQueryDefinition(doc) {
|
|
417
417
|
var queryDef = getOperationDefinition(doc);
|
|
418
|
-
globals.invariant(queryDef && queryDef.operation === "query",
|
|
418
|
+
globals.invariant(queryDef && queryDef.operation === "query", 76);
|
|
419
419
|
return queryDef;
|
|
420
420
|
}
|
|
421
421
|
function getFragmentDefinition(doc) {
|
|
422
|
-
globals.invariant(doc.kind === "Document",
|
|
423
|
-
globals.invariant(doc.definitions.length <= 1,
|
|
422
|
+
globals.invariant(doc.kind === "Document", 77);
|
|
423
|
+
globals.invariant(doc.definitions.length <= 1, 78);
|
|
424
424
|
var fragmentDef = doc.definitions[0];
|
|
425
|
-
globals.invariant(fragmentDef.kind === "FragmentDefinition",
|
|
425
|
+
globals.invariant(fragmentDef.kind === "FragmentDefinition", 79);
|
|
426
426
|
return fragmentDef;
|
|
427
427
|
}
|
|
428
428
|
function getMainDefinition(queryDoc) {
|
|
@@ -445,7 +445,7 @@ function getMainDefinition(queryDoc) {
|
|
|
445
445
|
if (fragmentDefinition) {
|
|
446
446
|
return fragmentDefinition;
|
|
447
447
|
}
|
|
448
|
-
throw globals.newInvariantError(
|
|
448
|
+
throw globals.newInvariantError(80);
|
|
449
449
|
}
|
|
450
450
|
function getDefaultValues(definition) {
|
|
451
451
|
var defaultValues = Object.create(null);
|
|
@@ -517,7 +517,7 @@ var DocumentTransform = (function () {
|
|
|
517
517
|
return;
|
|
518
518
|
var cacheKeys = this.getCacheKey(document);
|
|
519
519
|
if (cacheKeys) {
|
|
520
|
-
globals.invariant(Array.isArray(cacheKeys),
|
|
520
|
+
globals.invariant(Array.isArray(cacheKeys), 65);
|
|
521
521
|
return this.stableCacheKeys.lookupArray(cacheKeys);
|
|
522
522
|
}
|
|
523
523
|
};
|
|
@@ -613,7 +613,7 @@ function removeDirectivesFromDocument(directives, doc) {
|
|
|
613
613
|
return getInUseByFragmentName(ancestor.name.value);
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
616
|
+
globalThis.__DEV__ !== false && globals.invariant.error(82);
|
|
617
617
|
return null;
|
|
618
618
|
};
|
|
619
619
|
var operationCount = 0;
|
|
@@ -800,7 +800,7 @@ var connectionRemoveConfig = {
|
|
|
800
800
|
if (willRemove) {
|
|
801
801
|
if (!directive.arguments ||
|
|
802
802
|
!directive.arguments.some(function (arg) { return arg.name.value === "key"; })) {
|
|
803
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
803
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(83);
|
|
804
804
|
}
|
|
805
805
|
}
|
|
806
806
|
return willRemove;
|
|
@@ -1249,48 +1249,31 @@ function iterateObserversSafely(observers, method, argument) {
|
|
|
1249
1249
|
|
|
1250
1250
|
function asyncMap(observable, mapFn, catchFn) {
|
|
1251
1251
|
return new zenObservableTs.Observable(function (observer) {
|
|
1252
|
-
var next = observer.next, error = observer.error, complete = observer.complete;
|
|
1253
|
-
var activeCallbackCount = 0;
|
|
1254
|
-
var completed = false;
|
|
1255
1252
|
var promiseQueue = {
|
|
1256
1253
|
then: function (callback) {
|
|
1257
1254
|
return new Promise(function (resolve) { return resolve(callback()); });
|
|
1258
1255
|
},
|
|
1259
1256
|
};
|
|
1260
|
-
function makeCallback(examiner,
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
--activeCallbackCount;
|
|
1275
|
-
throw error;
|
|
1276
|
-
})
|
|
1277
|
-
.catch(function (caught) {
|
|
1278
|
-
error && error.call(observer, caught);
|
|
1279
|
-
});
|
|
1280
|
-
};
|
|
1281
|
-
}
|
|
1282
|
-
else {
|
|
1283
|
-
return function (arg) { return delegate && delegate.call(observer, arg); };
|
|
1284
|
-
}
|
|
1257
|
+
function makeCallback(examiner, key) {
|
|
1258
|
+
return function (arg) {
|
|
1259
|
+
if (examiner) {
|
|
1260
|
+
var both = function () {
|
|
1261
|
+
return observer.closed
|
|
1262
|
+
? 0
|
|
1263
|
+
: examiner(arg);
|
|
1264
|
+
};
|
|
1265
|
+
promiseQueue = promiseQueue.then(both, both).then(function (result) { return observer.next(result); }, function (error) { return observer.error(error); });
|
|
1266
|
+
}
|
|
1267
|
+
else {
|
|
1268
|
+
observer[key](arg);
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1285
1271
|
}
|
|
1286
1272
|
var handler = {
|
|
1287
|
-
next: makeCallback(mapFn, next),
|
|
1288
|
-
error: makeCallback(catchFn, error),
|
|
1273
|
+
next: makeCallback(mapFn, "next"),
|
|
1274
|
+
error: makeCallback(catchFn, "error"),
|
|
1289
1275
|
complete: function () {
|
|
1290
|
-
|
|
1291
|
-
if (!activeCallbackCount) {
|
|
1292
|
-
complete && complete.call(observer);
|
|
1293
|
-
}
|
|
1276
|
+
promiseQueue.then(function () { return observer.complete(); });
|
|
1294
1277
|
},
|
|
1295
1278
|
};
|
|
1296
1279
|
var sub = observable.subscribe(handler);
|