@isograph/react 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-compile-libs.log +9 -2
- package/dist/_virtual/rolldown_runtime.js +25 -0
- package/dist/core/FragmentReference.d.mts +38 -0
- package/dist/core/FragmentReference.d.mts.map +1 -0
- package/dist/core/FragmentReference.d.ts +31 -29
- package/dist/core/FragmentReference.d.ts.map +1 -1
- package/dist/core/FragmentReference.js +7 -5
- package/dist/core/FragmentReference.mjs +10 -0
- package/dist/core/FragmentReference.mjs.map +1 -0
- package/dist/core/IsographEnvironment.d.mts +89 -0
- package/dist/core/IsographEnvironment.d.mts.map +1 -0
- package/dist/core/IsographEnvironment.d.ts +76 -79
- package/dist/core/IsographEnvironment.d.ts.map +1 -1
- package/dist/core/IsographEnvironment.js +60 -82
- package/dist/core/IsographEnvironment.mjs +67 -0
- package/dist/core/IsographEnvironment.mjs.map +1 -0
- package/dist/core/PromiseWrapper.d.mts +36 -0
- package/dist/core/PromiseWrapper.d.mts.map +1 -0
- package/dist/core/PromiseWrapper.d.ts +26 -23
- package/dist/core/PromiseWrapper.d.ts.map +1 -1
- package/dist/core/PromiseWrapper.js +45 -43
- package/dist/core/PromiseWrapper.mjs +49 -0
- package/dist/core/PromiseWrapper.mjs.map +1 -0
- package/dist/core/areEqualWithDeepComparison.js +56 -108
- package/dist/core/areEqualWithDeepComparison.mjs +62 -0
- package/dist/core/areEqualWithDeepComparison.mjs.map +1 -0
- package/dist/core/brand.d.mts +19 -0
- package/dist/core/brand.d.mts.map +1 -0
- package/dist/core/brand.d.ts +6 -6
- package/dist/core/brand.d.ts.map +1 -1
- package/dist/core/cache.d.mts +20 -0
- package/dist/core/cache.d.mts.map +1 -0
- package/dist/core/cache.d.ts +18 -37
- package/dist/core/cache.d.ts.map +1 -1
- package/dist/core/cache.js +203 -537
- package/dist/core/cache.mjs +237 -0
- package/dist/core/cache.mjs.map +1 -0
- package/dist/core/check.d.mts +28 -0
- package/dist/core/check.d.mts.map +1 -0
- package/dist/core/check.d.ts +21 -19
- package/dist/core/check.d.ts.map +1 -1
- package/dist/core/check.js +80 -127
- package/dist/core/check.mjs +84 -0
- package/dist/core/check.mjs.map +1 -0
- package/dist/core/componentCache.js +9 -35
- package/dist/core/componentCache.mjs +12 -0
- package/dist/core/componentCache.mjs.map +1 -0
- package/dist/core/entrypoint.d.mts +99 -0
- package/dist/core/entrypoint.d.mts.map +1 -0
- package/dist/core/entrypoint.d.ts +83 -78
- package/dist/core/entrypoint.d.ts.map +1 -1
- package/dist/core/entrypoint.js +6 -5
- package/dist/core/entrypoint.mjs +8 -0
- package/dist/core/entrypoint.mjs.map +1 -0
- package/dist/core/garbageCollection.d.mts +18 -0
- package/dist/core/garbageCollection.d.mts.map +1 -0
- package/dist/core/garbageCollection.d.ts +15 -16
- package/dist/core/garbageCollection.d.ts.map +1 -1
- package/dist/core/garbageCollection.js +76 -115
- package/dist/core/garbageCollection.mjs +89 -0
- package/dist/core/garbageCollection.mjs.map +1 -0
- package/dist/core/getOrCreateCacheForArtifact.js +37 -0
- package/dist/core/getOrCreateCacheForArtifact.mjs +38 -0
- package/dist/core/getOrCreateCacheForArtifact.mjs.map +1 -0
- package/dist/core/logging.d.mts +95 -0
- package/dist/core/logging.d.mts.map +1 -0
- package/dist/core/logging.d.ts +66 -61
- package/dist/core/logging.d.ts.map +1 -1
- package/dist/core/logging.js +17 -18
- package/dist/core/logging.mjs +20 -0
- package/dist/core/logging.mjs.map +1 -0
- package/dist/core/makeNetworkRequest.d.mts +13 -0
- package/dist/core/makeNetworkRequest.d.mts.map +1 -0
- package/dist/core/makeNetworkRequest.d.ts +12 -10
- package/dist/core/makeNetworkRequest.d.ts.map +1 -1
- package/dist/core/makeNetworkRequest.js +180 -264
- package/dist/core/makeNetworkRequest.mjs +195 -0
- package/dist/core/makeNetworkRequest.mjs.map +1 -0
- package/dist/core/optimisticProxy.d.mts +43 -0
- package/dist/core/optimisticProxy.d.mts.map +1 -0
- package/dist/core/optimisticProxy.d.ts +37 -53
- package/dist/core/optimisticProxy.d.ts.map +1 -1
- package/dist/core/optimisticProxy.js +245 -371
- package/dist/core/optimisticProxy.mjs +268 -0
- package/dist/core/optimisticProxy.mjs.map +1 -0
- package/dist/core/read.d.mts +29 -0
- package/dist/core/read.d.mts.map +1 -0
- package/dist/core/read.d.ts +23 -28
- package/dist/core/read.d.ts.map +1 -1
- package/dist/core/read.js +435 -650
- package/dist/core/read.mjs +456 -0
- package/dist/core/read.mjs.map +1 -0
- package/dist/core/reader.d.mts +89 -0
- package/dist/core/reader.d.mts.map +1 -0
- package/dist/core/reader.d.ts +78 -77
- package/dist/core/reader.d.ts.map +1 -1
- package/dist/core/startUpdate.js +115 -152
- package/dist/core/startUpdate.mjs +125 -0
- package/dist/core/startUpdate.mjs.map +1 -0
- package/dist/core/subscribe.d.mts +12 -0
- package/dist/core/subscribe.d.mts.map +1 -0
- package/dist/core/subscribe.d.ts +12 -0
- package/dist/core/subscribe.d.ts.map +1 -0
- package/dist/core/subscribe.js +79 -0
- package/dist/core/subscribe.mjs +79 -0
- package/dist/core/subscribe.mjs.map +1 -0
- package/dist/core/util.d.mts +27 -0
- package/dist/core/util.d.mts.map +1 -0
- package/dist/core/util.d.ts +21 -17
- package/dist/core/util.d.ts.map +1 -1
- package/dist/core/util.js +22 -2
- package/dist/core/util.mjs +21 -0
- package/dist/core/util.mjs.map +1 -0
- package/dist/core/writeData.d.mts +11 -0
- package/dist/core/writeData.d.mts.map +1 -0
- package/dist/core/writeData.d.ts +11 -0
- package/dist/core/writeData.d.ts.map +1 -0
- package/dist/core/writeData.js +41 -0
- package/dist/core/writeData.mjs +42 -0
- package/dist/core/writeData.mjs.map +1 -0
- package/dist/index.d.mts +32 -0
- package/dist/index.d.ts +32 -29
- package/dist/index.js +70 -69
- package/dist/index.mjs +31 -0
- package/dist/loadable-hooks/useClientSideDefer.d.mts +12 -0
- package/dist/loadable-hooks/useClientSideDefer.d.mts.map +1 -0
- package/dist/loadable-hooks/useClientSideDefer.d.ts +9 -12
- package/dist/loadable-hooks/useClientSideDefer.d.ts.map +1 -1
- package/dist/loadable-hooks/useClientSideDefer.js +13 -44
- package/dist/loadable-hooks/useClientSideDefer.mjs +14 -0
- package/dist/loadable-hooks/useClientSideDefer.mjs.map +1 -0
- package/dist/loadable-hooks/useConnectionSpecPagination.d.mts +33 -0
- package/dist/loadable-hooks/useConnectionSpecPagination.d.mts.map +1 -0
- package/dist/loadable-hooks/useConnectionSpecPagination.d.ts +26 -22
- package/dist/loadable-hooks/useConnectionSpecPagination.d.ts.map +1 -1
- package/dist/loadable-hooks/useConnectionSpecPagination.js +133 -172
- package/dist/loadable-hooks/useConnectionSpecPagination.mjs +134 -0
- package/dist/loadable-hooks/useConnectionSpecPagination.mjs.map +1 -0
- package/dist/loadable-hooks/useImperativeExposedMutationField.d.mts +8 -0
- package/dist/loadable-hooks/useImperativeExposedMutationField.d.mts.map +1 -0
- package/dist/loadable-hooks/useImperativeExposedMutationField.d.ts +6 -3
- package/dist/loadable-hooks/useImperativeExposedMutationField.d.ts.map +1 -1
- package/dist/loadable-hooks/useImperativeExposedMutationField.js +9 -12
- package/dist/loadable-hooks/useImperativeExposedMutationField.mjs +11 -0
- package/dist/loadable-hooks/useImperativeExposedMutationField.mjs.map +1 -0
- package/dist/loadable-hooks/useImperativeLoadableField.d.mts +19 -0
- package/dist/loadable-hooks/useImperativeLoadableField.d.mts.map +1 -0
- package/dist/loadable-hooks/useImperativeLoadableField.d.ts +15 -11
- package/dist/loadable-hooks/useImperativeLoadableField.d.ts.map +1 -1
- package/dist/loadable-hooks/useImperativeLoadableField.js +16 -12
- package/dist/loadable-hooks/useImperativeLoadableField.mjs +17 -0
- package/dist/loadable-hooks/useImperativeLoadableField.mjs.map +1 -0
- package/dist/loadable-hooks/useSkipLimitPagination.d.mts +24 -0
- package/dist/loadable-hooks/useSkipLimitPagination.d.mts.map +1 -0
- package/dist/loadable-hooks/useSkipLimitPagination.d.ts +19 -15
- package/dist/loadable-hooks/useSkipLimitPagination.d.ts.map +1 -1
- package/dist/loadable-hooks/useSkipLimitPagination.js +118 -160
- package/dist/loadable-hooks/useSkipLimitPagination.mjs +119 -0
- package/dist/loadable-hooks/useSkipLimitPagination.mjs.map +1 -0
- package/dist/react/FragmentReader.d.mts +18 -0
- package/dist/react/FragmentReader.d.mts.map +1 -0
- package/dist/react/FragmentReader.d.ts +16 -8
- package/dist/react/FragmentReader.d.ts.map +1 -1
- package/dist/react/FragmentReader.js +8 -7
- package/dist/react/FragmentReader.mjs +10 -0
- package/dist/react/FragmentReader.mjs.map +1 -0
- package/dist/react/FragmentRenderer.d.mts +20 -0
- package/dist/react/FragmentRenderer.d.mts.map +1 -0
- package/dist/react/FragmentRenderer.d.ts +18 -14
- package/dist/react/FragmentRenderer.d.ts.map +1 -1
- package/dist/react/FragmentRenderer.js +11 -33
- package/dist/react/FragmentRenderer.mjs +12 -0
- package/dist/react/FragmentRenderer.mjs.map +1 -0
- package/dist/react/IsographEnvironmentProvider.d.mts +17 -0
- package/dist/react/IsographEnvironmentProvider.d.mts.map +1 -0
- package/dist/react/IsographEnvironmentProvider.d.ts +15 -9
- package/dist/react/IsographEnvironmentProvider.d.ts.map +1 -1
- package/dist/react/IsographEnvironmentProvider.js +15 -39
- package/dist/react/IsographEnvironmentProvider.mjs +17 -0
- package/dist/react/IsographEnvironmentProvider.mjs.map +1 -0
- package/dist/react/LoadableFieldReader.d.mts +21 -0
- package/dist/react/LoadableFieldReader.d.mts.map +1 -0
- package/dist/react/LoadableFieldReader.d.ts +15 -12
- package/dist/react/LoadableFieldReader.d.ts.map +1 -1
- package/dist/react/LoadableFieldReader.js +13 -47
- package/dist/react/LoadableFieldReader.mjs +14 -0
- package/dist/react/LoadableFieldReader.mjs.map +1 -0
- package/dist/react/LoadableFieldRenderer.d.mts +22 -0
- package/dist/react/LoadableFieldRenderer.d.mts.map +1 -0
- package/dist/react/LoadableFieldRenderer.d.ts +16 -13
- package/dist/react/LoadableFieldRenderer.d.ts.map +1 -1
- package/dist/react/LoadableFieldRenderer.js +13 -70
- package/dist/react/LoadableFieldRenderer.mjs +14 -0
- package/dist/react/LoadableFieldRenderer.mjs.map +1 -0
- package/dist/react/RenderAfterCommit__DO_NOT_USE.d.mts +18 -0
- package/dist/react/RenderAfterCommit__DO_NOT_USE.d.mts.map +1 -0
- package/dist/react/RenderAfterCommit__DO_NOT_USE.d.ts +11 -3
- package/dist/react/RenderAfterCommit__DO_NOT_USE.d.ts.map +1 -1
- package/dist/react/RenderAfterCommit__DO_NOT_USE.js +17 -13
- package/dist/react/RenderAfterCommit__DO_NOT_USE.mjs +18 -0
- package/dist/react/RenderAfterCommit__DO_NOT_USE.mjs.map +1 -0
- package/dist/react/createIsographEnvironment.d.mts +9 -0
- package/dist/react/createIsographEnvironment.d.mts.map +1 -0
- package/dist/react/createIsographEnvironment.d.ts +8 -0
- package/dist/react/createIsographEnvironment.d.ts.map +1 -0
- package/dist/react/createIsographEnvironment.js +10 -0
- package/dist/react/createIsographEnvironment.mjs +11 -0
- package/dist/react/createIsographEnvironment.mjs.map +1 -0
- package/dist/react/maybeUnwrapNetworkRequest.js +11 -0
- package/dist/react/maybeUnwrapNetworkRequest.mjs +12 -0
- package/dist/react/maybeUnwrapNetworkRequest.mjs.map +1 -0
- package/dist/react/useImperativeReference.d.mts +15 -0
- package/dist/react/useImperativeReference.d.mts.map +1 -0
- package/dist/react/useImperativeReference.d.ts +13 -8
- package/dist/react/useImperativeReference.d.ts.map +1 -1
- package/dist/react/useImperativeReference.js +34 -30
- package/dist/react/useImperativeReference.mjs +35 -0
- package/dist/react/useImperativeReference.mjs.map +1 -0
- package/dist/react/useLazyReference.d.mts +13 -0
- package/dist/react/useLazyReference.d.mts.map +1 -0
- package/dist/react/useLazyReference.d.ts +11 -6
- package/dist/react/useLazyReference.d.ts.map +1 -1
- package/dist/react/useLazyReference.js +17 -40
- package/dist/react/useLazyReference.mjs +18 -0
- package/dist/react/useLazyReference.mjs.map +1 -0
- package/dist/react/useReadAndSubscribe.d.mts +20 -0
- package/dist/react/useReadAndSubscribe.d.mts.map +1 -0
- package/dist/react/useReadAndSubscribe.d.ts +14 -9
- package/dist/react/useReadAndSubscribe.d.ts.map +1 -1
- package/dist/react/useReadAndSubscribe.js +57 -37
- package/dist/react/useReadAndSubscribe.mjs +59 -0
- package/dist/react/useReadAndSubscribe.mjs.map +1 -0
- package/dist/react/useRerenderOnChange.d.mts +12 -0
- package/dist/react/useRerenderOnChange.d.mts.map +1 -0
- package/dist/react/useRerenderOnChange.d.ts +10 -6
- package/dist/react/useRerenderOnChange.d.ts.map +1 -1
- package/dist/react/useRerenderOnChange.js +16 -20
- package/dist/react/useRerenderOnChange.mjs +17 -0
- package/dist/react/useRerenderOnChange.mjs.map +1 -0
- package/dist/react/useResult.d.mts +8 -0
- package/dist/react/useResult.d.mts.map +1 -0
- package/dist/react/useResult.d.ts +7 -5
- package/dist/react/useResult.d.ts.map +1 -1
- package/dist/react/useResult.js +27 -40
- package/dist/react/useResult.mjs +30 -0
- package/dist/react/useResult.mjs.map +1 -0
- package/package.json +17 -9
- package/src/core/FragmentReference.ts +3 -3
- package/src/core/IsographEnvironment.ts +29 -16
- package/src/core/areEqualWithDeepComparison.ts +2 -18
- package/src/core/cache.ts +18 -383
- package/src/core/check.ts +9 -16
- package/src/core/componentCache.ts +10 -47
- package/src/core/entrypoint.ts +15 -3
- package/src/core/garbageCollection.ts +21 -10
- package/src/core/getOrCreateCacheForArtifact.ts +86 -0
- package/src/core/logging.ts +10 -10
- package/src/core/makeNetworkRequest.ts +16 -23
- package/src/core/optimisticProxy.ts +28 -47
- package/src/core/read.ts +21 -38
- package/src/core/reader.ts +8 -11
- package/src/core/startUpdate.ts +2 -6
- package/src/core/subscribe.ts +189 -0
- package/src/core/util.ts +26 -0
- package/src/core/writeData.ts +79 -0
- package/src/index.ts +5 -4
- package/src/loadable-hooks/useClientSideDefer.ts +4 -4
- package/src/loadable-hooks/useConnectionSpecPagination.ts +20 -18
- package/src/loadable-hooks/useImperativeLoadableField.ts +3 -3
- package/src/loadable-hooks/useSkipLimitPagination.ts +20 -18
- package/src/react/IsographEnvironmentProvider.tsx +2 -1
- package/src/react/LoadableFieldReader.tsx +2 -4
- package/src/react/LoadableFieldRenderer.tsx +2 -4
- package/src/react/createIsographEnvironment.ts +23 -0
- package/src/react/maybeUnwrapNetworkRequest.ts +17 -0
- package/src/react/useImperativeReference.ts +5 -4
- package/src/react/useLazyReference.ts +7 -8
- package/src/react/useReadAndSubscribe.ts +53 -5
- package/src/react/useRerenderOnChange.ts +3 -3
- package/src/react/useResult.ts +6 -24
- package/src/tests/__isograph/Economist/__link/output_type.ts +2 -0
- package/src/tests/garbageCollection.test.ts +3 -6
- package/src/tests/meNameSuccessor.ts +1 -1
- package/src/tests/nodeQuery.ts +2 -2
- package/src/tests/normalizeData.test.ts +5 -3
- package/src/tests/optimisticProxy.test.ts +7 -5
- package/src/tests/startUpdate.test.ts +5 -7
- package/vitest.config.ts +5 -0
- package/dist/core/areEqualWithDeepComparison.d.ts +0 -3
- package/dist/core/areEqualWithDeepComparison.d.ts.map +0 -1
- package/dist/core/brand.js +0 -2
- package/dist/core/componentCache.d.ts +0 -5
- package/dist/core/componentCache.d.ts.map +0 -1
- package/dist/core/reader.js +0 -2
- package/dist/core/startUpdate.d.ts +0 -9
- package/dist/core/startUpdate.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isograph/react",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Use Isograph with React",
|
|
5
5
|
"homepage": "https://isograph.dev",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
8
|
"author": "Isograph Labs",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@isograph/disposable-types": "0.5.
|
|
12
|
-
"@isograph/
|
|
13
|
-
"@isograph/
|
|
11
|
+
"@isograph/disposable-types": "0.5.1",
|
|
12
|
+
"@isograph/reference-counted-pointer": "0.5.1",
|
|
13
|
+
"@isograph/react-disposable-state": "0.5.1"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -29,14 +29,22 @@
|
|
|
29
29
|
"directory": "libs/isograph-react"
|
|
30
30
|
},
|
|
31
31
|
"sideEffects": false,
|
|
32
|
+
"module": "./dist/index.mjs",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": "./dist/index.mjs",
|
|
36
|
+
"require": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
32
40
|
"scripts": {
|
|
33
|
-
"compile-libs": "
|
|
34
|
-
"
|
|
41
|
+
"compile-libs": "tsdown",
|
|
42
|
+
"watch-libs": "tsdown --watch",
|
|
35
43
|
"test": "vitest run",
|
|
36
44
|
"test-watch": "vitest watch",
|
|
37
45
|
"coverage": "vitest run --coverage",
|
|
38
46
|
"tsc": "tsc",
|
|
39
47
|
"tsc-force": "tsc --build --clean && tsc --build --force",
|
|
40
|
-
"iso": "
|
|
48
|
+
"iso": "../../target/debug/isograph_cli --config ./isograph.config.json"
|
|
41
49
|
}
|
|
42
50
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ReaderWithRefetchQueries } from '
|
|
2
|
-
import { stableCopy } from './cache';
|
|
1
|
+
import type { ReaderWithRefetchQueries } from './entrypoint';
|
|
3
2
|
import {
|
|
4
3
|
type ComponentOrFieldName,
|
|
5
4
|
type StoreLink,
|
|
6
5
|
} from './IsographEnvironment';
|
|
7
|
-
import { PromiseWrapper } from './PromiseWrapper';
|
|
6
|
+
import type { PromiseWrapper } from './PromiseWrapper';
|
|
8
7
|
import type { StartUpdate } from './reader';
|
|
8
|
+
import { stableCopy } from './util';
|
|
9
9
|
|
|
10
10
|
// TODO type this better
|
|
11
11
|
export type VariableValue =
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { ParentCache } from '@isograph/react-disposable-state';
|
|
1
|
+
import type { ParentCache } from '@isograph/react-disposable-state';
|
|
2
2
|
import type { Brand } from './brand';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import type {
|
|
5
4
|
IsographEntrypoint,
|
|
6
5
|
IsographOperation,
|
|
7
6
|
IsographPersistedOperation,
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
ReaderWithRefetchQueries,
|
|
8
|
+
ReaderWithRefetchQueriesLoader,
|
|
10
9
|
} from './entrypoint';
|
|
11
|
-
import {
|
|
10
|
+
import type {
|
|
11
|
+
ExtractStartUpdate,
|
|
12
12
|
FragmentReference,
|
|
13
|
+
StableIdForFragmentReference,
|
|
14
|
+
UnknownTReadFromStore,
|
|
13
15
|
Variables,
|
|
14
|
-
type StableIdForFragmentReference,
|
|
15
|
-
type UnknownTReadFromStore,
|
|
16
16
|
} from './FragmentReference';
|
|
17
17
|
import type { RetainedQuery } from './garbageCollection';
|
|
18
|
-
import { LogFunction, WrappedLogFunction } from './logging';
|
|
18
|
+
import type { LogFunction, WrappedLogFunction } from './logging';
|
|
19
19
|
import { type StoreLayer } from './optimisticProxy';
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
import type { PromiseWrapper } from './PromiseWrapper';
|
|
21
|
+
import { wrapPromise, wrapResolvedValue } from './PromiseWrapper';
|
|
22
|
+
import type {
|
|
23
|
+
NetworkRequestReaderOptions,
|
|
24
|
+
WithEncounteredRecords,
|
|
25
|
+
} from './read';
|
|
26
26
|
import type { ReaderAst, StartUpdate } from './reader';
|
|
27
|
+
import { isArray } from './util';
|
|
27
28
|
|
|
28
29
|
export type ComponentOrFieldName = string;
|
|
29
30
|
export type StringifiedArgs = string;
|
|
@@ -66,6 +67,7 @@ export type CacheMap<T> = { [index: string]: ParentCache<T> };
|
|
|
66
67
|
export type IsographEnvironment = {
|
|
67
68
|
store: StoreLayer;
|
|
68
69
|
readonly networkFunction: IsographNetworkFunction;
|
|
70
|
+
readonly componentFunction: IsographComponentFunction;
|
|
69
71
|
readonly missingFieldHandler: MissingFieldHandler | null;
|
|
70
72
|
readonly componentCache: FieldCache<React.FC<any>>;
|
|
71
73
|
readonly eagerReaderCache: FieldCache<StartUpdate<any> | undefined>;
|
|
@@ -97,6 +99,15 @@ export type IsographNetworkFunction = (
|
|
|
97
99
|
variables: Variables,
|
|
98
100
|
) => Promise<any>;
|
|
99
101
|
|
|
102
|
+
export type IsographComponentFunction = <
|
|
103
|
+
TReadFromStore extends UnknownTReadFromStore = any,
|
|
104
|
+
>(
|
|
105
|
+
environment: IsographEnvironment,
|
|
106
|
+
fragmentReference: FragmentReference<TReadFromStore, any>,
|
|
107
|
+
networkRequestOptions: NetworkRequestReaderOptions,
|
|
108
|
+
startUpdate: ExtractStartUpdate<TReadFromStore>,
|
|
109
|
+
) => React.FC<any>;
|
|
110
|
+
|
|
100
111
|
export interface Link<T extends TypeName> extends StoreLink {
|
|
101
112
|
readonly __link: Brand<DataId, T>;
|
|
102
113
|
readonly __typename: T;
|
|
@@ -146,9 +157,10 @@ export interface BaseStoreLayerData extends StoreLayerData {
|
|
|
146
157
|
}
|
|
147
158
|
|
|
148
159
|
const DEFAULT_GC_BUFFER_SIZE = 10;
|
|
149
|
-
export function
|
|
160
|
+
export function createIsographEnvironmentCore(
|
|
150
161
|
baseStoreLayerData: BaseStoreLayerData,
|
|
151
162
|
networkFunction: IsographNetworkFunction,
|
|
163
|
+
componentFunction: IsographComponentFunction,
|
|
152
164
|
missingFieldHandler?: MissingFieldHandler | null,
|
|
153
165
|
logFunction?: LogFunction | null,
|
|
154
166
|
): IsographEnvironment {
|
|
@@ -164,6 +176,7 @@ export function createIsographEnvironment(
|
|
|
164
176
|
return {
|
|
165
177
|
store,
|
|
166
178
|
networkFunction,
|
|
179
|
+
componentFunction,
|
|
167
180
|
missingFieldHandler: missingFieldHandler ?? null,
|
|
168
181
|
componentCache: {},
|
|
169
182
|
eagerReaderCache: {},
|
|
@@ -6,12 +6,8 @@ function mergeUsingReaderAst(
|
|
|
6
6
|
oldItem: unknown,
|
|
7
7
|
newItem: unknown,
|
|
8
8
|
): unknown {
|
|
9
|
-
if (newItem
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (newItem === undefined) {
|
|
14
|
-
return oldItem === undefined ? oldItem : newItem;
|
|
9
|
+
if (newItem == null || oldItem == null) {
|
|
10
|
+
return newItem;
|
|
15
11
|
}
|
|
16
12
|
|
|
17
13
|
if (Array.isArray(newItem)) {
|
|
@@ -31,12 +27,6 @@ function mergeUsingReaderAst(
|
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
return mergeObjectsUsingReaderAst(field.selections, oldItem, newItem);
|
|
34
|
-
default: {
|
|
35
|
-
// Ensure we have covered all variants
|
|
36
|
-
let _: never = field;
|
|
37
|
-
_;
|
|
38
|
-
throw new Error('Unexpected case.');
|
|
39
|
-
}
|
|
40
30
|
}
|
|
41
31
|
}
|
|
42
32
|
|
|
@@ -124,12 +114,6 @@ export function mergeObjectsUsingReaderAst(
|
|
|
124
114
|
case 'ImperativelyLoadedField':
|
|
125
115
|
case 'LoadablySelectedField':
|
|
126
116
|
break;
|
|
127
|
-
default: {
|
|
128
|
-
// Ensure we have covered all variants
|
|
129
|
-
let _: never = field;
|
|
130
|
-
_;
|
|
131
|
-
throw new Error('Unexpected case.');
|
|
132
|
-
}
|
|
133
117
|
}
|
|
134
118
|
}
|
|
135
119
|
|
package/src/core/cache.ts
CHANGED
|
@@ -1,51 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
ParentCache,
|
|
5
|
-
} from '@isograph/react-disposable-state';
|
|
6
|
-
import {
|
|
7
|
-
IsographEntrypoint,
|
|
1
|
+
import { type Factory, ParentCache } from '@isograph/react-disposable-state';
|
|
2
|
+
import type {
|
|
3
|
+
NormalizationAstNodes,
|
|
8
4
|
NormalizationInlineFragment,
|
|
9
5
|
NormalizationLinkedField,
|
|
10
6
|
NormalizationScalarField,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type NormalizationAstNodes,
|
|
14
|
-
} from '../core/entrypoint';
|
|
15
|
-
import { mergeObjectsUsingReaderAst } from './areEqualWithDeepComparison';
|
|
16
|
-
import { FetchOptions } from './check';
|
|
17
|
-
import {
|
|
18
|
-
ExtractParameters,
|
|
7
|
+
} from './entrypoint';
|
|
8
|
+
import type {
|
|
19
9
|
FragmentReference,
|
|
10
|
+
UnknownTReadFromStore,
|
|
20
11
|
Variables,
|
|
21
|
-
|
|
22
|
-
type VariableValue,
|
|
12
|
+
VariableValue,
|
|
23
13
|
} from './FragmentReference';
|
|
24
14
|
import {
|
|
25
|
-
DataId,
|
|
26
|
-
DataTypeValue,
|
|
27
|
-
FragmentSubscription,
|
|
15
|
+
type DataId,
|
|
16
|
+
type DataTypeValue,
|
|
28
17
|
getLink,
|
|
29
|
-
getOrLoadReaderWithRefetchQueries,
|
|
30
|
-
ROOT_ID,
|
|
31
|
-
StoreLink,
|
|
32
|
-
StoreRecord,
|
|
33
18
|
type IsographEnvironment,
|
|
19
|
+
ROOT_ID,
|
|
20
|
+
type StoreLink,
|
|
21
|
+
type StoreRecord,
|
|
34
22
|
type TypeName,
|
|
35
23
|
} from './IsographEnvironment';
|
|
36
24
|
import { logMessage } from './logging';
|
|
37
25
|
import {
|
|
38
|
-
maybeMakeNetworkRequest,
|
|
39
|
-
retainQueryWithoutMakingNetworkRequest,
|
|
40
|
-
} from './makeNetworkRequest';
|
|
41
|
-
import {
|
|
42
|
-
addNetworkResponseStoreLayer,
|
|
43
26
|
getMutableStoreRecordProxy,
|
|
44
27
|
type StoreLayerWithData,
|
|
45
28
|
} from './optimisticProxy';
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import { Argument, ArgumentValue } from './util';
|
|
29
|
+
import type { ReaderLinkedField, ReaderScalarField } from './reader';
|
|
30
|
+
import { type Argument, type ArgumentValue, isArray, stableCopy } from './util';
|
|
49
31
|
|
|
50
32
|
export const TYPENAME_FIELD_NAME = '__typename';
|
|
51
33
|
|
|
@@ -64,90 +46,6 @@ export function getOrCreateItemInSuspenseCache<
|
|
|
64
46
|
return environment.fragmentCache[index];
|
|
65
47
|
}
|
|
66
48
|
|
|
67
|
-
/**
|
|
68
|
-
* Creates a copy of the provided value, ensuring any nested objects have their
|
|
69
|
-
* keys sorted such that equivalent values would have identical JSON.stringify
|
|
70
|
-
* results.
|
|
71
|
-
*/
|
|
72
|
-
export function stableCopy<T>(value: T): T {
|
|
73
|
-
if (!value || typeof value !== 'object') {
|
|
74
|
-
return value;
|
|
75
|
-
}
|
|
76
|
-
if (isArray(value)) {
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
return value.map(stableCopy);
|
|
79
|
-
}
|
|
80
|
-
const keys = Object.keys(value).sort();
|
|
81
|
-
const stable: { [index: string]: any } = {};
|
|
82
|
-
for (let i = 0; i < keys.length; i++) {
|
|
83
|
-
// @ts-ignore
|
|
84
|
-
stable[keys[i]] = stableCopy(value[keys[i]]);
|
|
85
|
-
}
|
|
86
|
-
return stable as any;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function getOrCreateCacheForArtifact<
|
|
90
|
-
TReadFromStore extends UnknownTReadFromStore,
|
|
91
|
-
TClientFieldValue,
|
|
92
|
-
TNormalizationAst extends NormalizationAst | NormalizationAstLoader,
|
|
93
|
-
TRawResponseType extends NetworkResponseObject,
|
|
94
|
-
>(
|
|
95
|
-
environment: IsographEnvironment,
|
|
96
|
-
entrypoint: IsographEntrypoint<
|
|
97
|
-
TReadFromStore,
|
|
98
|
-
TClientFieldValue,
|
|
99
|
-
TNormalizationAst,
|
|
100
|
-
TRawResponseType
|
|
101
|
-
>,
|
|
102
|
-
variables: ExtractParameters<TReadFromStore>,
|
|
103
|
-
fetchOptions?: FetchOptions<TClientFieldValue, TRawResponseType>,
|
|
104
|
-
): ParentCache<FragmentReference<TReadFromStore, TClientFieldValue>> {
|
|
105
|
-
let cacheKey = '';
|
|
106
|
-
switch (entrypoint.networkRequestInfo.operation.kind) {
|
|
107
|
-
case 'Operation':
|
|
108
|
-
cacheKey =
|
|
109
|
-
entrypoint.networkRequestInfo.operation.text +
|
|
110
|
-
JSON.stringify(stableCopy(variables));
|
|
111
|
-
break;
|
|
112
|
-
case 'PersistedOperation':
|
|
113
|
-
cacheKey =
|
|
114
|
-
entrypoint.networkRequestInfo.operation.operationId +
|
|
115
|
-
JSON.stringify(stableCopy(variables));
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
const factory = () => {
|
|
119
|
-
const { fieldName, readerArtifactKind, readerWithRefetchQueries } =
|
|
120
|
-
getOrLoadReaderWithRefetchQueries(
|
|
121
|
-
environment,
|
|
122
|
-
entrypoint.readerWithRefetchQueries,
|
|
123
|
-
);
|
|
124
|
-
const [networkRequest, disposeNetworkRequest] = maybeMakeNetworkRequest(
|
|
125
|
-
environment,
|
|
126
|
-
entrypoint,
|
|
127
|
-
variables,
|
|
128
|
-
readerWithRefetchQueries,
|
|
129
|
-
fetchOptions ?? null,
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
const itemCleanupPair: ItemCleanupPair<
|
|
133
|
-
FragmentReference<TReadFromStore, TClientFieldValue>
|
|
134
|
-
> = [
|
|
135
|
-
{
|
|
136
|
-
kind: 'FragmentReference',
|
|
137
|
-
readerWithRefetchQueries,
|
|
138
|
-
fieldName,
|
|
139
|
-
readerArtifactKind,
|
|
140
|
-
root: { __link: ROOT_ID, __typename: entrypoint.concreteType },
|
|
141
|
-
variables,
|
|
142
|
-
networkRequest: networkRequest,
|
|
143
|
-
},
|
|
144
|
-
disposeNetworkRequest,
|
|
145
|
-
];
|
|
146
|
-
return itemCleanupPair;
|
|
147
|
-
};
|
|
148
|
-
return getOrCreateItemInSuspenseCache(environment, cacheKey, factory);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
49
|
export type NetworkResponseScalarValue = string | number | boolean;
|
|
152
50
|
export type NetworkResponseValue =
|
|
153
51
|
| NetworkResponseScalarValue
|
|
@@ -222,33 +120,6 @@ export function subscribeToAnyChangesToRecord(
|
|
|
222
120
|
return () => environment.subscriptions.delete(subscription);
|
|
223
121
|
}
|
|
224
122
|
|
|
225
|
-
export function subscribe<TReadFromStore extends UnknownTReadFromStore>(
|
|
226
|
-
environment: IsographEnvironment,
|
|
227
|
-
encounteredDataAndRecords: WithEncounteredRecords<TReadFromStore>,
|
|
228
|
-
fragmentReference: FragmentReference<TReadFromStore, any>,
|
|
229
|
-
callback: (
|
|
230
|
-
newEncounteredDataAndRecords: WithEncounteredRecords<TReadFromStore>,
|
|
231
|
-
) => void,
|
|
232
|
-
readerAst: ReaderAst<TReadFromStore>,
|
|
233
|
-
): () => void {
|
|
234
|
-
const fragmentSubscription: FragmentSubscription<TReadFromStore> = {
|
|
235
|
-
kind: 'FragmentSubscription',
|
|
236
|
-
callback,
|
|
237
|
-
encounteredDataAndRecords,
|
|
238
|
-
fragmentReference,
|
|
239
|
-
readerAst,
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
// subscribe is called in an effect. (We should actually subscribe during the
|
|
243
|
-
// initial render.) Because it's called in an effect, we might have missed some
|
|
244
|
-
// changes since the initial render! So, at this point, we re-read and call the
|
|
245
|
-
// subscription (i.e. re-render) if the fragment data has changed.
|
|
246
|
-
callSubscriptionIfDataChanged(environment, fragmentSubscription);
|
|
247
|
-
|
|
248
|
-
environment.subscriptions.add(fragmentSubscription);
|
|
249
|
-
return () => environment.subscriptions.delete(fragmentSubscription);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
123
|
export function onNextChangeToRecord(
|
|
253
124
|
environment: IsographEnvironment,
|
|
254
125
|
recordLink: StoreLink,
|
|
@@ -265,161 +136,6 @@ export function onNextChangeToRecord(
|
|
|
265
136
|
});
|
|
266
137
|
}
|
|
267
138
|
|
|
268
|
-
// Calls to readButDoNotEvaluate can suspend (i.e. throw a promise).
|
|
269
|
-
// Maybe in the future, they will be able to throw errors.
|
|
270
|
-
//
|
|
271
|
-
// That's probably okay to ignore. We don't, however, want to prevent
|
|
272
|
-
// updating other subscriptions if one subscription had missing data.
|
|
273
|
-
function logAnyError(
|
|
274
|
-
environment: IsographEnvironment,
|
|
275
|
-
context: any,
|
|
276
|
-
f: () => void,
|
|
277
|
-
) {
|
|
278
|
-
try {
|
|
279
|
-
f();
|
|
280
|
-
} catch (e) {
|
|
281
|
-
logMessage(environment, () => ({
|
|
282
|
-
kind: 'ErrorEncounteredInWithErrorHandling',
|
|
283
|
-
error: e,
|
|
284
|
-
context,
|
|
285
|
-
}));
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
export function callSubscriptions(
|
|
290
|
-
environment: IsographEnvironment,
|
|
291
|
-
recordsEncounteredWhenNormalizing: EncounteredIds,
|
|
292
|
-
) {
|
|
293
|
-
environment.subscriptions.forEach((subscription) =>
|
|
294
|
-
logAnyError(environment, { situation: 'calling subscriptions' }, () => {
|
|
295
|
-
switch (subscription.kind) {
|
|
296
|
-
case 'FragmentSubscription': {
|
|
297
|
-
// TODO if there are multiple components subscribed to the same
|
|
298
|
-
// fragment, we will call readButNotEvaluate multiple times. We
|
|
299
|
-
// should fix that.
|
|
300
|
-
if (
|
|
301
|
-
hasOverlappingIds(
|
|
302
|
-
recordsEncounteredWhenNormalizing,
|
|
303
|
-
subscription.encounteredDataAndRecords.encounteredRecords,
|
|
304
|
-
)
|
|
305
|
-
) {
|
|
306
|
-
callSubscriptionIfDataChanged(environment, subscription);
|
|
307
|
-
}
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
case 'AnyRecords': {
|
|
311
|
-
logAnyError(
|
|
312
|
-
environment,
|
|
313
|
-
{ situation: 'calling AnyRecords callback' },
|
|
314
|
-
() => subscription.callback(),
|
|
315
|
-
);
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
case 'AnyChangesToRecord': {
|
|
319
|
-
if (
|
|
320
|
-
recordsEncounteredWhenNormalizing
|
|
321
|
-
.get(subscription.recordLink.__typename)
|
|
322
|
-
?.has(subscription.recordLink.__link)
|
|
323
|
-
) {
|
|
324
|
-
logAnyError(
|
|
325
|
-
environment,
|
|
326
|
-
{ situation: 'calling AnyChangesToRecord callback' },
|
|
327
|
-
() => subscription.callback(),
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
default: {
|
|
333
|
-
// Ensure we have covered all variants
|
|
334
|
-
const _: never = subscription;
|
|
335
|
-
_;
|
|
336
|
-
throw new Error('Unexpected case');
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}),
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function callSubscriptionIfDataChanged<
|
|
344
|
-
TReadFromStore extends UnknownTReadFromStore,
|
|
345
|
-
>(
|
|
346
|
-
environment: IsographEnvironment,
|
|
347
|
-
subscription: FragmentSubscription<TReadFromStore>,
|
|
348
|
-
) {
|
|
349
|
-
const newEncounteredDataAndRecords = readButDoNotEvaluate(
|
|
350
|
-
environment,
|
|
351
|
-
subscription.fragmentReference,
|
|
352
|
-
// Is this wrong?
|
|
353
|
-
// Reasons to think no:
|
|
354
|
-
// - we are only updating the read-out value, and the network
|
|
355
|
-
// options only affect whether we throw.
|
|
356
|
-
// - the component will re-render, and re-throw on its own, anyway.
|
|
357
|
-
//
|
|
358
|
-
// Reasons to think not:
|
|
359
|
-
// - it seems more efficient to suspend here and not update state,
|
|
360
|
-
// if we expect that the component will just throw anyway
|
|
361
|
-
// - consistency
|
|
362
|
-
// - it's also weird, this is called from makeNetworkRequest, where
|
|
363
|
-
// we don't currently pass network request options
|
|
364
|
-
{
|
|
365
|
-
suspendIfInFlight: false,
|
|
366
|
-
throwOnNetworkError: false,
|
|
367
|
-
},
|
|
368
|
-
);
|
|
369
|
-
|
|
370
|
-
const mergedItem = mergeObjectsUsingReaderAst(
|
|
371
|
-
subscription.readerAst,
|
|
372
|
-
subscription.encounteredDataAndRecords.item,
|
|
373
|
-
newEncounteredDataAndRecords.item,
|
|
374
|
-
);
|
|
375
|
-
|
|
376
|
-
logMessage(environment, () => ({
|
|
377
|
-
kind: 'DeepEqualityCheck',
|
|
378
|
-
fragmentReference: subscription.fragmentReference,
|
|
379
|
-
old: subscription.encounteredDataAndRecords.item,
|
|
380
|
-
new: newEncounteredDataAndRecords.item,
|
|
381
|
-
deeplyEqual: mergedItem === subscription.encounteredDataAndRecords.item,
|
|
382
|
-
}));
|
|
383
|
-
|
|
384
|
-
if (mergedItem !== subscription.encounteredDataAndRecords.item) {
|
|
385
|
-
logAnyError(
|
|
386
|
-
environment,
|
|
387
|
-
{ situation: 'calling FragmentSubscription callback' },
|
|
388
|
-
() => {
|
|
389
|
-
subscription.callback(newEncounteredDataAndRecords);
|
|
390
|
-
},
|
|
391
|
-
);
|
|
392
|
-
subscription.encounteredDataAndRecords = newEncounteredDataAndRecords;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function hasOverlappingIds(
|
|
397
|
-
ids1: EncounteredIds,
|
|
398
|
-
ids2: EncounteredIds,
|
|
399
|
-
): boolean {
|
|
400
|
-
for (const [typeName, set1] of ids1.entries()) {
|
|
401
|
-
const set2 = ids2.get(typeName);
|
|
402
|
-
if (set2 === undefined) {
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
if (isNotDisjointFrom(set1, set2)) {
|
|
407
|
-
return true;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return false;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// TODO use a polyfill library
|
|
414
|
-
function isNotDisjointFrom<T>(set1: Set<T>, set2: Set<T>): boolean {
|
|
415
|
-
for (const id of set1) {
|
|
416
|
-
if (set2.has(id)) {
|
|
417
|
-
return true;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
139
|
export type EncounteredIds = Map<TypeName, Set<DataId>>;
|
|
424
140
|
/**
|
|
425
141
|
* Mutate targetParentRecord according to the normalizationAst and networkResponseParentRecord.
|
|
@@ -478,12 +194,6 @@ function normalizeDataIntoRecord(
|
|
|
478
194
|
recordHasBeenUpdated || inlineFragmentResultedInChange;
|
|
479
195
|
break;
|
|
480
196
|
}
|
|
481
|
-
default: {
|
|
482
|
-
// Ensure we have covered all variants
|
|
483
|
-
let _: never = normalizationNode;
|
|
484
|
-
_;
|
|
485
|
-
throw new Error('Unexpected normalization node kind');
|
|
486
|
-
}
|
|
487
197
|
}
|
|
488
198
|
}
|
|
489
199
|
if (recordHasBeenUpdated) {
|
|
@@ -520,7 +230,7 @@ function normalizeScalarField(
|
|
|
520
230
|
|
|
521
231
|
if (networkResponseData == null) {
|
|
522
232
|
targetStoreRecord[parentRecordKey] = null;
|
|
523
|
-
return existingValue
|
|
233
|
+
return existingValue === undefined || existingValue != null;
|
|
524
234
|
}
|
|
525
235
|
|
|
526
236
|
if (isScalarOrEmptyArray(networkResponseData)) {
|
|
@@ -531,10 +241,6 @@ function normalizeScalarField(
|
|
|
531
241
|
}
|
|
532
242
|
}
|
|
533
243
|
|
|
534
|
-
export function isArray(value: unknown): value is readonly unknown[] {
|
|
535
|
-
return Array.isArray(value);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
244
|
/**
|
|
539
245
|
* Mutate targetParentRecord with a given linked field ast node.
|
|
540
246
|
*/
|
|
@@ -555,7 +261,7 @@ function normalizeLinkedField(
|
|
|
555
261
|
|
|
556
262
|
if (networkResponseData == null) {
|
|
557
263
|
targetParentRecord[parentRecordKey] = null;
|
|
558
|
-
return existingValue
|
|
264
|
+
return existingValue === undefined || existingValue != null;
|
|
559
265
|
}
|
|
560
266
|
|
|
561
267
|
if (
|
|
@@ -741,7 +447,7 @@ function isScalarOrEmptyArray(
|
|
|
741
447
|
return data.every((x) => isScalarOrEmptyArray(x));
|
|
742
448
|
}
|
|
743
449
|
const isScalarValue =
|
|
744
|
-
data
|
|
450
|
+
data == null ||
|
|
745
451
|
typeof data === 'string' ||
|
|
746
452
|
typeof data === 'number' ||
|
|
747
453
|
typeof data === 'boolean';
|
|
@@ -758,7 +464,7 @@ function isNullOrEmptyArray(
|
|
|
758
464
|
return data.every((x) => isNullOrEmptyArray(x));
|
|
759
465
|
}
|
|
760
466
|
|
|
761
|
-
return data
|
|
467
|
+
return data == null;
|
|
762
468
|
}
|
|
763
469
|
|
|
764
470
|
export function getParentRecordKey(
|
|
@@ -808,13 +514,6 @@ function getStoreKeyChunkForArgumentValue(
|
|
|
808
514
|
case 'Enum': {
|
|
809
515
|
return argumentValue.value;
|
|
810
516
|
}
|
|
811
|
-
default: {
|
|
812
|
-
// TODO configure eslint to allow unused vars starting with _
|
|
813
|
-
// Ensure we have covered all variants
|
|
814
|
-
const _: never = argumentValue;
|
|
815
|
-
_;
|
|
816
|
-
throw new Error('Unexpected case');
|
|
817
|
-
}
|
|
818
517
|
}
|
|
819
518
|
}
|
|
820
519
|
|
|
@@ -875,12 +574,6 @@ function getArgumentValueChunk(argumentValue: ArgumentValue): string {
|
|
|
875
574
|
case 'Enum': {
|
|
876
575
|
return 'e_' + argumentValue.value;
|
|
877
576
|
}
|
|
878
|
-
default: {
|
|
879
|
-
// Ensure we have covered all variants
|
|
880
|
-
let _: never = argumentValue;
|
|
881
|
-
_;
|
|
882
|
-
throw new Error('Unexpected case');
|
|
883
|
-
}
|
|
884
577
|
}
|
|
885
578
|
}
|
|
886
579
|
|
|
@@ -926,61 +619,3 @@ function getDataIdOfNetworkResponse(
|
|
|
926
619
|
}
|
|
927
620
|
return storeKey;
|
|
928
621
|
}
|
|
929
|
-
|
|
930
|
-
export function writeData<
|
|
931
|
-
TReadFromStore extends UnknownTReadFromStore,
|
|
932
|
-
TRawResponseType extends NetworkResponseObject,
|
|
933
|
-
TClientFieldValue,
|
|
934
|
-
>(
|
|
935
|
-
environment: IsographEnvironment,
|
|
936
|
-
entrypoint: IsographEntrypoint<
|
|
937
|
-
TReadFromStore,
|
|
938
|
-
TClientFieldValue,
|
|
939
|
-
NormalizationAst,
|
|
940
|
-
TRawResponseType
|
|
941
|
-
>,
|
|
942
|
-
data: TRawResponseType,
|
|
943
|
-
variables: ExtractParameters<TReadFromStore>,
|
|
944
|
-
): ItemCleanupPair<FragmentReference<TReadFromStore, TClientFieldValue>> {
|
|
945
|
-
const encounteredIds: EncounteredIds = new Map();
|
|
946
|
-
environment.store = addNetworkResponseStoreLayer(environment.store);
|
|
947
|
-
normalizeData(
|
|
948
|
-
environment,
|
|
949
|
-
environment.store,
|
|
950
|
-
entrypoint.networkRequestInfo.normalizationAst.selections,
|
|
951
|
-
data,
|
|
952
|
-
variables,
|
|
953
|
-
{ __link: ROOT_ID, __typename: entrypoint.concreteType },
|
|
954
|
-
encounteredIds,
|
|
955
|
-
);
|
|
956
|
-
logMessage(environment, () => ({
|
|
957
|
-
kind: 'AfterNormalization',
|
|
958
|
-
store: environment.store,
|
|
959
|
-
encounteredIds,
|
|
960
|
-
}));
|
|
961
|
-
|
|
962
|
-
callSubscriptions(environment, encounteredIds);
|
|
963
|
-
|
|
964
|
-
const { fieldName, readerArtifactKind, readerWithRefetchQueries } =
|
|
965
|
-
getOrLoadReaderWithRefetchQueries(
|
|
966
|
-
environment,
|
|
967
|
-
entrypoint.readerWithRefetchQueries,
|
|
968
|
-
);
|
|
969
|
-
const [networkRequest, disposeNetworkRequest] =
|
|
970
|
-
retainQueryWithoutMakingNetworkRequest(environment, entrypoint, variables);
|
|
971
|
-
|
|
972
|
-
return [
|
|
973
|
-
{
|
|
974
|
-
kind: 'FragmentReference',
|
|
975
|
-
readerWithRefetchQueries,
|
|
976
|
-
fieldName,
|
|
977
|
-
readerArtifactKind,
|
|
978
|
-
root: { __link: ROOT_ID, __typename: entrypoint.concreteType },
|
|
979
|
-
variables,
|
|
980
|
-
networkRequest,
|
|
981
|
-
},
|
|
982
|
-
() => {
|
|
983
|
-
disposeNetworkRequest();
|
|
984
|
-
},
|
|
985
|
-
];
|
|
986
|
-
}
|