@isograph/react 0.0.0-main-c89c61e8 → 0.0.0-main-0eb53a17
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 +1 -1
- package/dist/core/FragmentReference.d.ts +2 -2
- package/dist/core/FragmentReference.d.ts.map +1 -1
- package/dist/core/IsographEnvironment.d.ts +7 -12
- package/dist/core/IsographEnvironment.d.ts.map +1 -1
- package/dist/core/areEqualWithDeepComparison.d.ts +3 -1
- package/dist/core/areEqualWithDeepComparison.d.ts.map +1 -1
- package/dist/core/areEqualWithDeepComparison.js +2 -0
- package/dist/core/cache.d.ts +4 -4
- package/dist/core/cache.d.ts.map +1 -1
- package/dist/core/cache.js +3 -8
- package/dist/core/check.d.ts +3 -3
- package/dist/core/check.d.ts.map +1 -1
- package/dist/core/garbageCollection.d.ts +2 -2
- package/dist/core/garbageCollection.d.ts.map +1 -1
- package/dist/core/logging.d.ts +4 -13
- package/dist/core/logging.d.ts.map +1 -1
- package/dist/core/makeNetworkRequest.d.ts.map +1 -1
- package/dist/core/read.d.ts +7 -7
- package/dist/core/read.d.ts.map +1 -1
- package/dist/core/reader.d.ts +3 -3
- package/dist/core/reader.d.ts.map +1 -1
- package/dist/core/startUpdate.d.ts.map +1 -1
- package/dist/core/startUpdate.js +0 -9
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/react/FragmentReader.d.ts +10 -4
- package/dist/react/FragmentReader.d.ts.map +1 -1
- package/dist/react/FragmentReader.js +30 -3
- package/dist/react/LoadableFieldReader.d.ts.map +1 -1
- package/dist/react/LoadableFieldReader.js +3 -0
- package/package.json +4 -4
- package/src/core/FragmentReference.ts +2 -2
- package/src/core/IsographEnvironment.ts +7 -13
- package/src/core/areEqualWithDeepComparison.ts +5 -5
- package/src/core/cache.ts +14 -22
- package/src/core/check.ts +4 -4
- package/src/core/garbageCollection.ts +3 -3
- package/src/core/logging.ts +4 -16
- package/src/core/makeNetworkRequest.ts +2 -2
- package/src/core/read.ts +10 -12
- package/src/core/reader.ts +3 -3
- package/src/core/startUpdate.ts +2 -11
- package/src/index.ts +2 -5
- package/src/react/FragmentReader.tsx +36 -17
- package/src/react/LoadableFieldReader.tsx +3 -0
- package/src/tests/__isograph/Node/asEconomist/resolver_reader.ts +1 -1
- package/src/tests/__isograph/Query/linkedUpdate/param_type.ts +4 -4
- package/src/tests/__isograph/iso.ts +1 -1
- package/dist/core/brand.d.ts +0 -2
- package/dist/core/brand.d.ts.map +0 -1
- package/dist/core/brand.js +0 -2
- package/dist/react/FragmentRenderer.d.ts +0 -15
- package/dist/react/FragmentRenderer.d.ts.map +0 -1
- package/dist/react/FragmentRenderer.js +0 -35
- package/dist/react/LoadableFieldRenderer.d.ts +0 -13
- package/dist/react/LoadableFieldRenderer.d.ts.map +0 -1
- package/dist/react/LoadableFieldRenderer.js +0 -37
- package/src/core/brand.ts +0 -18
- package/src/react/FragmentRenderer.tsx +0 -46
- package/src/react/LoadableFieldRenderer.tsx +0 -41
- package/src/tests/__isograph/Economist/link/output_type.ts +0 -2
- package/src/tests/__isograph/Node/link/output_type.ts +0 -3
- package/src/tests/__isograph/tsconfig.json +0 -8
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.FragmentReader = FragmentReader;
|
|
27
|
+
const React = __importStar(require("react"));
|
|
4
28
|
const useResult_1 = require("./useResult");
|
|
5
|
-
function FragmentReader(
|
|
6
|
-
const
|
|
7
|
-
|
|
29
|
+
function FragmentReader(props) {
|
|
30
|
+
const Component = (0, useResult_1.useResult)(props.fragmentReference, props.networkRequestOptions);
|
|
31
|
+
// TypeScript is not understanding that if additionalProps is Record<PropertyKey, never>,
|
|
32
|
+
// it means that TProps === JSX.IntrinsicAttributes.
|
|
33
|
+
// @ts-expect-error
|
|
34
|
+
return React.createElement(Component, Object.assign({}, props.additionalProps));
|
|
8
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadableFieldReader.d.ts","sourceRoot":"","sources":["../../src/react/LoadableFieldReader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,iBAAiB,EACjB,KAAK,qBAAqB,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"LoadableFieldReader.d.ts","sourceRoot":"","sources":["../../src/react/LoadableFieldReader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,iBAAiB,EACjB,KAAK,qBAAqB,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAOpD,wBAAgB,mBAAmB,CACjC,cAAc,SAAS,qBAAqB,EAC5C,OAAO,EACP,aAAa,SAAS,MAAM,EAC5B,eAAe,EACf,KAAK,EAAE;IACP,aAAa,EAAE,aAAa,CAC1B,cAAc,EACd,OAAO,EACP,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,MAAM,aAAa,CAAC,CAC7D,CAAC;IAEF,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,MAAM,aAAa,CAAC,CAAC;IACnE,YAAY,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,qBAAqB,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC7D,QAAQ,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,eAAe,CAAC;CAC7C,GAAG,eAAe,CAalB"}
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LoadableFieldReader = LoadableFieldReader;
|
|
4
4
|
const useClientSideDefer_1 = require("../loadable-hooks/useClientSideDefer");
|
|
5
5
|
const useResult_1 = require("./useResult");
|
|
6
|
+
// TODO
|
|
7
|
+
// - LoadableFieldRenderer, which works for @loadable fields that are components,
|
|
8
|
+
// i.e. just renders the resulting component
|
|
6
9
|
function LoadableFieldReader(props) {
|
|
7
10
|
const { fragmentReference } = (0, useClientSideDefer_1.useClientSideDefer)(props.loadableField, props.args, props.fetchOptions);
|
|
8
11
|
const readOutFragmentData = (0, useResult_1.useResult)(fragmentReference, props.networkRequestOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isograph/react",
|
|
3
|
-
"version": "0.0.0-main-
|
|
3
|
+
"version": "0.0.0-main-0eb53a17",
|
|
4
4
|
"description": "Use Isograph with React",
|
|
5
5
|
"homepage": "https://isograph.dev",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"iso": "cross-env ISO_PRINT_ABSOLUTE_FILEPATH=1 ../../target/debug/isograph_cli --config ./isograph.config.json"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@isograph/disposable-types": "0.0.0-main-
|
|
23
|
-
"@isograph/react-disposable-state": "0.0.0-main-
|
|
24
|
-
"@isograph/reference-counted-pointer": "0.0.0-main-
|
|
22
|
+
"@isograph/disposable-types": "0.0.0-main-0eb53a17",
|
|
23
|
+
"@isograph/react-disposable-state": "0.0.0-main-0eb53a17",
|
|
24
|
+
"@isograph/reference-counted-pointer": "0.0.0-main-0eb53a17"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReaderWithRefetchQueries } from '../core/entrypoint';
|
|
2
2
|
import { stableCopy } from './cache';
|
|
3
|
-
import { type
|
|
3
|
+
import { type Link } from './IsographEnvironment';
|
|
4
4
|
import { PromiseWrapper } from './PromiseWrapper';
|
|
5
5
|
import type { StartUpdate } from './reader';
|
|
6
6
|
|
|
@@ -52,7 +52,7 @@ export type FragmentReference<
|
|
|
52
52
|
readonly readerWithRefetchQueries: PromiseWrapper<
|
|
53
53
|
ReaderWithRefetchQueries<TReadFromStore, TClientFieldValue>
|
|
54
54
|
>;
|
|
55
|
-
readonly root:
|
|
55
|
+
readonly root: Link;
|
|
56
56
|
// TODO we potentially stably copy and stringify variables a lot!
|
|
57
57
|
// So, we should employ interior mutability: pretend that fragent reference
|
|
58
58
|
// is immutable, but actually store something like
|
|
@@ -15,7 +15,6 @@ import { LogFunction, WrappedLogFunction } from './logging';
|
|
|
15
15
|
import { PromiseWrapper, wrapPromise } from './PromiseWrapper';
|
|
16
16
|
import { WithEncounteredRecords } from './read';
|
|
17
17
|
import type { ReaderAst, StartUpdate } from './reader';
|
|
18
|
-
import type { Brand } from './brand';
|
|
19
18
|
|
|
20
19
|
export type ComponentOrFieldName = string;
|
|
21
20
|
export type StringifiedArgs = string;
|
|
@@ -39,7 +38,7 @@ export type FragmentSubscription<TReadFromStore extends UnknownTReadFromStore> =
|
|
|
39
38
|
export type AnyChangesToRecordSubscription = {
|
|
40
39
|
readonly kind: 'AnyChangesToRecord';
|
|
41
40
|
readonly callback: () => void;
|
|
42
|
-
readonly recordLink:
|
|
41
|
+
readonly recordLink: Link;
|
|
43
42
|
};
|
|
44
43
|
|
|
45
44
|
export type AnyRecordSubscription = {
|
|
@@ -78,23 +77,18 @@ export type IsographEnvironment = {
|
|
|
78
77
|
|
|
79
78
|
export type MissingFieldHandler = (
|
|
80
79
|
storeRecord: StoreRecord,
|
|
81
|
-
root:
|
|
80
|
+
root: Link,
|
|
82
81
|
fieldName: string,
|
|
83
82
|
arguments_: { [index: string]: any } | null,
|
|
84
83
|
variables: Variables | null,
|
|
85
|
-
) =>
|
|
84
|
+
) => Link | undefined;
|
|
86
85
|
|
|
87
86
|
export type IsographNetworkFunction = (
|
|
88
87
|
operation: IsographOperation | IsographPersistedOperation,
|
|
89
88
|
variables: Variables,
|
|
90
89
|
) => Promise<any>;
|
|
91
90
|
|
|
92
|
-
export
|
|
93
|
-
readonly __link: Brand<DataId, T>;
|
|
94
|
-
readonly __typename: T;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export type StoreLink = {
|
|
91
|
+
export type Link = {
|
|
98
92
|
readonly __link: DataId;
|
|
99
93
|
readonly __typename: TypeName;
|
|
100
94
|
};
|
|
@@ -109,7 +103,7 @@ export type DataTypeValue =
|
|
|
109
103
|
| string
|
|
110
104
|
| null
|
|
111
105
|
// Singular linked fields:
|
|
112
|
-
|
|
|
106
|
+
| Link
|
|
113
107
|
// Plural scalar and linked fields:
|
|
114
108
|
| DataTypeValue[];
|
|
115
109
|
|
|
@@ -168,7 +162,7 @@ export function createIsographStore(): IsographStore {
|
|
|
168
162
|
};
|
|
169
163
|
}
|
|
170
164
|
|
|
171
|
-
export function assertLink(link: DataTypeValue):
|
|
165
|
+
export function assertLink(link: DataTypeValue): Link | null | undefined {
|
|
172
166
|
if (Array.isArray(link)) {
|
|
173
167
|
throw new Error('Unexpected array');
|
|
174
168
|
}
|
|
@@ -181,7 +175,7 @@ export function assertLink(link: DataTypeValue): StoreLink | null | undefined {
|
|
|
181
175
|
throw new Error('Invalid link');
|
|
182
176
|
}
|
|
183
177
|
|
|
184
|
-
export function getLink(maybeLink: DataTypeValue):
|
|
178
|
+
export function getLink(maybeLink: DataTypeValue): Link | null {
|
|
185
179
|
if (
|
|
186
180
|
maybeLink != null &&
|
|
187
181
|
typeof maybeLink === 'object' &&
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Link } from './IsographEnvironment';
|
|
2
2
|
import type { ReaderAst, ReaderLinkedField, ReaderScalarField } from './reader';
|
|
3
3
|
|
|
4
|
-
function mergeUsingReaderAst(
|
|
4
|
+
export function mergeUsingReaderAst(
|
|
5
5
|
field: ReaderScalarField | ReaderLinkedField,
|
|
6
6
|
oldItem: unknown,
|
|
7
7
|
newItem: unknown,
|
|
@@ -40,7 +40,7 @@ function mergeUsingReaderAst(
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function mergeArraysUsingReaderAst(
|
|
43
|
+
export function mergeArraysUsingReaderAst(
|
|
44
44
|
field: ReaderScalarField | ReaderLinkedField,
|
|
45
45
|
oldItems: ReadonlyArray<unknown>,
|
|
46
46
|
newItems: Array<unknown>,
|
|
@@ -101,9 +101,9 @@ export function mergeObjectsUsingReaderAst(
|
|
|
101
101
|
case 'Link': {
|
|
102
102
|
const key = field.alias;
|
|
103
103
|
// @ts-expect-error
|
|
104
|
-
const oldValue:
|
|
104
|
+
const oldValue: Link = oldItemObject[key];
|
|
105
105
|
// @ts-expect-error
|
|
106
|
-
const newValue:
|
|
106
|
+
const newValue: Link = newItemObject[key];
|
|
107
107
|
|
|
108
108
|
if (
|
|
109
109
|
oldValue.__link !== newValue.__link ||
|
package/src/core/cache.ts
CHANGED
|
@@ -26,8 +26,8 @@ import {
|
|
|
26
26
|
DataTypeValue,
|
|
27
27
|
FragmentSubscription,
|
|
28
28
|
getLink,
|
|
29
|
+
Link,
|
|
29
30
|
ROOT_ID,
|
|
30
|
-
StoreLink,
|
|
31
31
|
StoreRecord,
|
|
32
32
|
type IsographEnvironment,
|
|
33
33
|
type TypeName,
|
|
@@ -157,7 +157,7 @@ export function normalizeData(
|
|
|
157
157
|
normalizationAst: NormalizationAstNodes,
|
|
158
158
|
networkResponse: NetworkResponseObject,
|
|
159
159
|
variables: Variables,
|
|
160
|
-
root:
|
|
160
|
+
root: Link,
|
|
161
161
|
): EncounteredIds {
|
|
162
162
|
const encounteredIds: EncounteredIds = new Map();
|
|
163
163
|
|
|
@@ -205,7 +205,7 @@ export function subscribeToAnyChange(
|
|
|
205
205
|
|
|
206
206
|
export function subscribeToAnyChangesToRecord(
|
|
207
207
|
environment: IsographEnvironment,
|
|
208
|
-
recordLink:
|
|
208
|
+
recordLink: Link,
|
|
209
209
|
callback: () => void,
|
|
210
210
|
): () => void {
|
|
211
211
|
const subscription = {
|
|
@@ -240,7 +240,7 @@ export function subscribe<TReadFromStore extends UnknownTReadFromStore>(
|
|
|
240
240
|
|
|
241
241
|
export function onNextChangeToRecord(
|
|
242
242
|
environment: IsographEnvironment,
|
|
243
|
-
recordLink:
|
|
243
|
+
recordLink: Link,
|
|
244
244
|
): Promise<void> {
|
|
245
245
|
return new Promise((resolve) => {
|
|
246
246
|
const unsubscribe = subscribeToAnyChangesToRecord(
|
|
@@ -259,19 +259,11 @@ export function onNextChangeToRecord(
|
|
|
259
259
|
//
|
|
260
260
|
// That's probably okay to ignore. We don't, however, want to prevent
|
|
261
261
|
// updating other subscriptions if one subscription had missing data.
|
|
262
|
-
function withErrorHandling<T>(
|
|
263
|
-
environment: IsographEnvironment,
|
|
264
|
-
f: (t: T) => void,
|
|
265
|
-
): (t: T) => void {
|
|
262
|
+
function withErrorHandling<T>(f: (t: T) => void): (t: T) => void {
|
|
266
263
|
return (t) => {
|
|
267
264
|
try {
|
|
268
265
|
return f(t);
|
|
269
|
-
} catch
|
|
270
|
-
logMessage(environment, () => ({
|
|
271
|
-
kind: 'ErrorEncounteredInWithErrorHandling',
|
|
272
|
-
error: e,
|
|
273
|
-
}));
|
|
274
|
-
}
|
|
266
|
+
} catch {}
|
|
275
267
|
};
|
|
276
268
|
}
|
|
277
269
|
|
|
@@ -280,7 +272,7 @@ export function callSubscriptions(
|
|
|
280
272
|
recordsEncounteredWhenNormalizing: EncounteredIds,
|
|
281
273
|
) {
|
|
282
274
|
environment.subscriptions.forEach(
|
|
283
|
-
withErrorHandling(
|
|
275
|
+
withErrorHandling((subscription) => {
|
|
284
276
|
switch (subscription.kind) {
|
|
285
277
|
case 'FragmentSubscription': {
|
|
286
278
|
// TODO if there are multiple components subscribed to the same
|
|
@@ -395,7 +387,7 @@ function normalizeDataIntoRecord(
|
|
|
395
387
|
normalizationAst: NormalizationAstNodes,
|
|
396
388
|
networkResponseParentRecord: NetworkResponseObject,
|
|
397
389
|
targetParentRecord: StoreRecord,
|
|
398
|
-
targetParentRecordLink:
|
|
390
|
+
targetParentRecordLink: Link,
|
|
399
391
|
variables: Variables,
|
|
400
392
|
mutableEncounteredIds: EncounteredIds,
|
|
401
393
|
): RecordHasBeenUpdated {
|
|
@@ -500,7 +492,7 @@ function normalizeLinkedField(
|
|
|
500
492
|
astNode: NormalizationLinkedField,
|
|
501
493
|
networkResponseParentRecord: NetworkResponseObject,
|
|
502
494
|
targetParentRecord: StoreRecord,
|
|
503
|
-
targetParentRecordLink:
|
|
495
|
+
targetParentRecordLink: Link,
|
|
504
496
|
variables: Variables,
|
|
505
497
|
mutableEncounteredIds: EncounteredIds,
|
|
506
498
|
): RecordHasBeenUpdated {
|
|
@@ -525,7 +517,7 @@ function normalizeLinkedField(
|
|
|
525
517
|
|
|
526
518
|
if (Array.isArray(networkResponseData)) {
|
|
527
519
|
// TODO check astNode.plural or the like
|
|
528
|
-
const dataIds: (
|
|
520
|
+
const dataIds: (Link | null)[] = [];
|
|
529
521
|
for (let i = 0; i < networkResponseData.length; i++) {
|
|
530
522
|
const networkResponseObject = networkResponseData[i];
|
|
531
523
|
if (networkResponseObject == null) {
|
|
@@ -596,7 +588,7 @@ function normalizeInlineFragment(
|
|
|
596
588
|
astNode: NormalizationInlineFragment,
|
|
597
589
|
networkResponseParentRecord: NetworkResponseObject,
|
|
598
590
|
targetParentRecord: StoreRecord,
|
|
599
|
-
targetParentRecordLink:
|
|
591
|
+
targetParentRecordLink: Link,
|
|
600
592
|
variables: Variables,
|
|
601
593
|
mutableEncounteredIds: EncounteredIds,
|
|
602
594
|
): RecordHasBeenUpdated {
|
|
@@ -618,7 +610,7 @@ function normalizeInlineFragment(
|
|
|
618
610
|
|
|
619
611
|
function dataIdsAreTheSame(
|
|
620
612
|
existingValue: DataTypeValue,
|
|
621
|
-
newDataIds: (
|
|
613
|
+
newDataIds: (Link | null)[],
|
|
622
614
|
): boolean {
|
|
623
615
|
if (Array.isArray(existingValue)) {
|
|
624
616
|
if (newDataIds.length !== existingValue.length) {
|
|
@@ -643,7 +635,7 @@ function normalizeNetworkResponseObject(
|
|
|
643
635
|
environment: IsographEnvironment,
|
|
644
636
|
astNode: NormalizationLinkedField,
|
|
645
637
|
networkResponseData: NetworkResponseObject,
|
|
646
|
-
targetParentRecordLink:
|
|
638
|
+
targetParentRecordLink: Link,
|
|
647
639
|
variables: Variables,
|
|
648
640
|
index: number | null,
|
|
649
641
|
mutableEncounteredIds: EncounteredIds,
|
|
@@ -838,7 +830,7 @@ export const THIRD_SPLIT_KEY = '__';
|
|
|
838
830
|
|
|
839
831
|
// Returns a key to look up an item in the store
|
|
840
832
|
function getDataIdOfNetworkResponse(
|
|
841
|
-
parentRecordLink:
|
|
833
|
+
parentRecordLink: Link,
|
|
842
834
|
dataToNormalize: NetworkResponseObject,
|
|
843
835
|
astNode: NormalizationLinkedField,
|
|
844
836
|
variables: Variables,
|
package/src/core/check.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Variables } from './FragmentReference';
|
|
|
4
4
|
import {
|
|
5
5
|
getLink,
|
|
6
6
|
IsographEnvironment,
|
|
7
|
-
|
|
7
|
+
Link,
|
|
8
8
|
StoreRecord,
|
|
9
9
|
} from './IsographEnvironment';
|
|
10
10
|
import { logMessage } from './logging';
|
|
@@ -30,14 +30,14 @@ export type CheckResult =
|
|
|
30
30
|
}
|
|
31
31
|
| {
|
|
32
32
|
kind: 'MissingData';
|
|
33
|
-
record:
|
|
33
|
+
record: Link;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export function check(
|
|
37
37
|
environment: IsographEnvironment,
|
|
38
38
|
normalizationAst: NormalizationAstNodes,
|
|
39
39
|
variables: Variables,
|
|
40
|
-
root:
|
|
40
|
+
root: Link,
|
|
41
41
|
): CheckResult {
|
|
42
42
|
const recordsById = (environment.store[root.__typename] ??= {});
|
|
43
43
|
const newStoreRecord = (recordsById[root.__link] ??= {});
|
|
@@ -61,7 +61,7 @@ function checkFromRecord(
|
|
|
61
61
|
normalizationAst: NormalizationAstNodes,
|
|
62
62
|
variables: Variables,
|
|
63
63
|
record: StoreRecord,
|
|
64
|
-
recordLink:
|
|
64
|
+
recordLink: Link,
|
|
65
65
|
): CheckResult {
|
|
66
66
|
normalizationAstLoop: for (const normalizationAstNode of normalizationAst) {
|
|
67
67
|
switch (normalizationAstNode.kind) {
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
IsographEnvironment,
|
|
8
8
|
IsographStore,
|
|
9
9
|
StoreRecord,
|
|
10
|
-
type
|
|
10
|
+
type Link,
|
|
11
11
|
type TypeName,
|
|
12
12
|
} from './IsographEnvironment';
|
|
13
13
|
|
|
14
14
|
export type RetainedQuery = {
|
|
15
15
|
readonly normalizationAst: NormalizationAstNodes;
|
|
16
16
|
readonly variables: {};
|
|
17
|
-
readonly root:
|
|
17
|
+
readonly root: Link;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export type DidUnretainSomeQuery = boolean;
|
|
@@ -117,7 +117,7 @@ function recordReachableIdsFromRecord(
|
|
|
117
117
|
const linkKey = getParentRecordKey(selection, variables ?? {});
|
|
118
118
|
const linkedFieldOrFields = currentRecord[linkKey];
|
|
119
119
|
|
|
120
|
-
const links:
|
|
120
|
+
const links: Link[] = [];
|
|
121
121
|
if (Array.isArray(linkedFieldOrFields)) {
|
|
122
122
|
for (const maybeLink of linkedFieldOrFields) {
|
|
123
123
|
const link = assertLink(maybeLink);
|
package/src/core/logging.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
IsographEnvironment,
|
|
12
12
|
IsographStore,
|
|
13
13
|
StoreRecord,
|
|
14
|
-
type
|
|
14
|
+
type Link,
|
|
15
15
|
} from './IsographEnvironment';
|
|
16
16
|
import { ReadDataResult } from './read';
|
|
17
17
|
import { Arguments } from './util';
|
|
@@ -38,7 +38,7 @@ export type LogMessage =
|
|
|
38
38
|
| {
|
|
39
39
|
kind: 'ComponentRerendered';
|
|
40
40
|
componentName: string;
|
|
41
|
-
rootLink:
|
|
41
|
+
rootLink: Link;
|
|
42
42
|
}
|
|
43
43
|
| {
|
|
44
44
|
kind: 'MakeNetworkRequest';
|
|
@@ -61,7 +61,7 @@ export type LogMessage =
|
|
|
61
61
|
}
|
|
62
62
|
| {
|
|
63
63
|
kind: 'MissingFieldHandlerCalled';
|
|
64
|
-
root:
|
|
64
|
+
root: Link;
|
|
65
65
|
storeRecord: StoreRecord;
|
|
66
66
|
fieldName: string;
|
|
67
67
|
arguments: Arguments | null;
|
|
@@ -71,7 +71,7 @@ export type LogMessage =
|
|
|
71
71
|
kind: 'DoneReading';
|
|
72
72
|
response: ReadDataResult<any>;
|
|
73
73
|
fieldName: string;
|
|
74
|
-
root:
|
|
74
|
+
root: Link;
|
|
75
75
|
}
|
|
76
76
|
| {
|
|
77
77
|
kind: 'NonEntrypointReceived';
|
|
@@ -83,18 +83,6 @@ export type LogMessage =
|
|
|
83
83
|
}
|
|
84
84
|
| {
|
|
85
85
|
kind: 'EnvironmentCreated';
|
|
86
|
-
}
|
|
87
|
-
| {
|
|
88
|
-
kind: 'StartUpdateError';
|
|
89
|
-
error: any;
|
|
90
|
-
}
|
|
91
|
-
| {
|
|
92
|
-
kind: 'StartUpdateComplete';
|
|
93
|
-
updatedIds: EncounteredIds;
|
|
94
|
-
}
|
|
95
|
-
| {
|
|
96
|
-
kind: 'ErrorEncounteredInWithErrorHandling';
|
|
97
|
-
error: any;
|
|
98
86
|
};
|
|
99
87
|
|
|
100
88
|
export type LogFunction = (logMessage: LogMessage) => void;
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
retainQuery,
|
|
21
21
|
unretainQuery,
|
|
22
22
|
} from './garbageCollection';
|
|
23
|
-
import { IsographEnvironment,
|
|
23
|
+
import { IsographEnvironment, Link, ROOT_ID } from './IsographEnvironment';
|
|
24
24
|
import { logMessage } from './logging';
|
|
25
25
|
import {
|
|
26
26
|
AnyError,
|
|
@@ -260,7 +260,7 @@ function readDataForOnComplete<
|
|
|
260
260
|
>(
|
|
261
261
|
artifact: TArtifact,
|
|
262
262
|
environment: IsographEnvironment,
|
|
263
|
-
root:
|
|
263
|
+
root: Link,
|
|
264
264
|
variables: ExtractParameters<TReadFromStore>,
|
|
265
265
|
readerWithRefetchQueries:
|
|
266
266
|
| ReaderWithRefetchQueries<TReadFromStore, TClientFieldValue>
|
package/src/core/read.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
getOrLoadIsographArtifact,
|
|
24
24
|
IsographEnvironment,
|
|
25
25
|
type DataTypeValue,
|
|
26
|
-
type
|
|
26
|
+
type Link,
|
|
27
27
|
type StoreRecord,
|
|
28
28
|
} from './IsographEnvironment';
|
|
29
29
|
import { logMessage } from './logging';
|
|
@@ -134,13 +134,13 @@ export type ReadDataResult<Data> =
|
|
|
134
134
|
readonly kind: 'MissingData';
|
|
135
135
|
readonly reason: string;
|
|
136
136
|
readonly nestedReason?: ReadDataResult<unknown>;
|
|
137
|
-
readonly recordLink:
|
|
137
|
+
readonly recordLink: Link;
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
function readData<TReadFromStore>(
|
|
141
141
|
environment: IsographEnvironment,
|
|
142
142
|
ast: ReaderAst<TReadFromStore>,
|
|
143
|
-
root:
|
|
143
|
+
root: Link,
|
|
144
144
|
variables: Variables,
|
|
145
145
|
nestedRefetchQueries: RefetchQueryNormalizationArtifactWrapper[],
|
|
146
146
|
networkRequest: PromiseWrapper<void, any>,
|
|
@@ -281,7 +281,7 @@ function readData<TReadFromStore>(
|
|
|
281
281
|
export function readLoadablySelectedFieldData(
|
|
282
282
|
environment: IsographEnvironment,
|
|
283
283
|
field: LoadablySelectedField,
|
|
284
|
-
root:
|
|
284
|
+
root: Link,
|
|
285
285
|
variables: Variables,
|
|
286
286
|
networkRequest: PromiseWrapper<void, any>,
|
|
287
287
|
networkRequestOptions: NetworkRequestReaderOptions,
|
|
@@ -534,7 +534,7 @@ function writeQueryArgsToVariables(
|
|
|
534
534
|
export function readResolverFieldData(
|
|
535
535
|
environment: IsographEnvironment,
|
|
536
536
|
field: ReaderNonLoadableResolverField,
|
|
537
|
-
root:
|
|
537
|
+
root: Link,
|
|
538
538
|
variables: Variables,
|
|
539
539
|
nestedRefetchQueries: RefetchQueryNormalizationArtifactWrapper[],
|
|
540
540
|
networkRequest: PromiseWrapper<void, any>,
|
|
@@ -625,11 +625,9 @@ export function readResolverFieldData(
|
|
|
625
625
|
export function readScalarFieldData(
|
|
626
626
|
field: ReaderScalarField,
|
|
627
627
|
storeRecord: StoreRecord,
|
|
628
|
-
root:
|
|
628
|
+
root: Link,
|
|
629
629
|
variables: Variables,
|
|
630
|
-
): ReadDataResult<
|
|
631
|
-
string | number | boolean | StoreLink | DataTypeValue[] | null
|
|
632
|
-
> {
|
|
630
|
+
): ReadDataResult<string | number | boolean | Link | DataTypeValue[] | null> {
|
|
633
631
|
const storeRecordName = getParentRecordKey(field, variables);
|
|
634
632
|
const value = storeRecord[storeRecordName];
|
|
635
633
|
// TODO consider making scalars into discriminated unions. This probably has
|
|
@@ -648,14 +646,14 @@ export function readLinkedFieldData(
|
|
|
648
646
|
environment: IsographEnvironment,
|
|
649
647
|
field: ReaderLinkedField,
|
|
650
648
|
storeRecord: StoreRecord,
|
|
651
|
-
root:
|
|
649
|
+
root: Link,
|
|
652
650
|
variables: Variables,
|
|
653
651
|
nestedRefetchQueries: RefetchQueryNormalizationArtifactWrapper[],
|
|
654
652
|
networkRequest: PromiseWrapper<void, any>,
|
|
655
653
|
networkRequestOptions: NetworkRequestReaderOptions,
|
|
656
654
|
readData: <TReadFromStore>(
|
|
657
655
|
ast: ReaderAst<TReadFromStore>,
|
|
658
|
-
root:
|
|
656
|
+
root: Link,
|
|
659
657
|
) => ReadDataResult<object>,
|
|
660
658
|
): ReadDataResult<unknown> {
|
|
661
659
|
const storeRecordName = getParentRecordKey(field, variables);
|
|
@@ -946,7 +944,7 @@ function stableStringifyArgs(args: object) {
|
|
|
946
944
|
export function readImperativelyLoadedField(
|
|
947
945
|
environment: IsographEnvironment,
|
|
948
946
|
field: ReaderImperativelyLoadedField,
|
|
949
|
-
root:
|
|
947
|
+
root: Link,
|
|
950
948
|
variables: Variables,
|
|
951
949
|
nestedRefetchQueries: RefetchQueryNormalizationArtifactWrapper[],
|
|
952
950
|
networkRequest: PromiseWrapper<void, any>,
|
package/src/core/reader.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
ComponentOrFieldName,
|
|
16
16
|
IsographEnvironment,
|
|
17
|
-
type
|
|
17
|
+
type Link,
|
|
18
18
|
} from './IsographEnvironment';
|
|
19
19
|
import { Arguments } from './util';
|
|
20
20
|
|
|
@@ -71,7 +71,7 @@ export type RefetchReaderArtifact = {
|
|
|
71
71
|
variables: any,
|
|
72
72
|
// TODO type this better
|
|
73
73
|
filteredVariables: any,
|
|
74
|
-
rootLink:
|
|
74
|
+
rootLink: Link,
|
|
75
75
|
readerArtifact: TopLevelReaderArtifact<any, any, any> | null,
|
|
76
76
|
// TODO type this better
|
|
77
77
|
nestedRefetchQueries: RefetchQueryNormalizationArtifactWrapper[],
|
|
@@ -110,7 +110,7 @@ export type ReaderLinkedField = {
|
|
|
110
110
|
readonly arguments: Arguments | null;
|
|
111
111
|
readonly condition: EagerReaderArtifact<
|
|
112
112
|
{ data: any; parameters: any; startUpdate?: StartUpdate<any> },
|
|
113
|
-
|
|
113
|
+
Link | null
|
|
114
114
|
> | null;
|
|
115
115
|
readonly isUpdatable: boolean;
|
|
116
116
|
/**
|
package/src/core/startUpdate.ts
CHANGED
|
@@ -16,9 +16,8 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
assertLink,
|
|
18
18
|
type IsographEnvironment,
|
|
19
|
-
type
|
|
19
|
+
type Link,
|
|
20
20
|
} from './IsographEnvironment';
|
|
21
|
-
import { logMessage } from './logging';
|
|
22
21
|
import { readPromise, type PromiseWrapper } from './PromiseWrapper';
|
|
23
22
|
import {
|
|
24
23
|
readImperativelyLoadedField,
|
|
@@ -66,16 +65,8 @@ export function createStartUpdate<TReadFromStore extends UnknownTReadFromStore>(
|
|
|
66
65
|
try {
|
|
67
66
|
updater(data);
|
|
68
67
|
} catch (e) {
|
|
69
|
-
logMessage(environment, () => ({
|
|
70
|
-
kind: 'StartUpdateError',
|
|
71
|
-
error: e,
|
|
72
|
-
}));
|
|
73
68
|
throw e;
|
|
74
69
|
} finally {
|
|
75
|
-
logMessage(environment, () => ({
|
|
76
|
-
kind: 'StartUpdateComplete',
|
|
77
|
-
updatedIds: mutableUpdatedIds,
|
|
78
|
-
}));
|
|
79
70
|
callSubscriptions(environment, mutableUpdatedIds);
|
|
80
71
|
}
|
|
81
72
|
};
|
|
@@ -155,7 +146,7 @@ function defineCachedProperty<T>(
|
|
|
155
146
|
function readUpdatableData<TReadFromStore extends UnknownTReadFromStore>(
|
|
156
147
|
environment: IsographEnvironment,
|
|
157
148
|
ast: ReaderAst<TReadFromStore>,
|
|
158
|
-
root:
|
|
149
|
+
root: Link,
|
|
159
150
|
variables: ExtractParameters<TReadFromStore>,
|
|
160
151
|
nestedRefetchQueries: RefetchQueryNormalizationArtifactWrapper[],
|
|
161
152
|
networkRequest: PromiseWrapper<void, any>,
|
package/src/index.ts
CHANGED
|
@@ -35,7 +35,6 @@ export {
|
|
|
35
35
|
type IsographNetworkFunction,
|
|
36
36
|
type IsographStore,
|
|
37
37
|
type MissingFieldHandler,
|
|
38
|
-
type StoreLink,
|
|
39
38
|
type Link,
|
|
40
39
|
type StoreRecord,
|
|
41
40
|
type CacheMap,
|
|
@@ -142,12 +141,10 @@ export {
|
|
|
142
141
|
type UseImperativeReferenceResult,
|
|
143
142
|
} from './react/useImperativeReference';
|
|
144
143
|
export {
|
|
145
|
-
|
|
144
|
+
FragmentReader,
|
|
146
145
|
type IsExactlyIntrinsicAttributes,
|
|
147
|
-
} from './react/
|
|
148
|
-
export { FragmentReader } from './react/FragmentReader';
|
|
146
|
+
} from './react/FragmentReader';
|
|
149
147
|
export { LoadableFieldReader } from './react/LoadableFieldReader';
|
|
150
|
-
export { LoadableFieldRenderer } from './react/LoadableFieldRenderer';
|
|
151
148
|
export { useResult } from './react/useResult';
|
|
152
149
|
export {
|
|
153
150
|
useReadAndSubscribe,
|