@isograph/react 0.0.0-main-b397289c → 0.0.0-main-2ed40dec
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/cache.d.ts.map +1 -1
- package/dist/core/cache.js +6 -3
- package/package.json +4 -4
- package/src/core/cache.ts +7 -5
- package/src/tests/__isograph/Query/normalizeUndefinedField/entrypoint.ts +31 -0
- package/src/tests/__isograph/Query/normalizeUndefinedField/normalization_ast.ts +25 -0
- package/src/tests/__isograph/Query/normalizeUndefinedField/output_type.ts +3 -0
- package/src/tests/__isograph/Query/normalizeUndefinedField/param_type.ts +9 -0
- package/src/tests/__isograph/Query/normalizeUndefinedField/query_text.ts +6 -0
- package/src/tests/__isograph/Query/normalizeUndefinedField/raw_response_type.ts +7 -0
- package/src/tests/__isograph/Query/normalizeUndefinedField/resolver_reader.ts +38 -0
- package/src/tests/__isograph/iso.ts +10 -0
- package/src/tests/normalizeData.test.ts +82 -12
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
../.. | WARN Unsupported engine: wanted: {"node":"22.9.0"} (current: {"node":"v22.21.1","pnpm":"10.15.0"})
|
|
2
2
|
|
|
3
|
-
> @isograph/react@0.0.0-main-
|
|
3
|
+
> @isograph/react@0.0.0-main-2ed40dec compile-libs /home/runner/work/isograph/isograph/libs/isograph-react
|
|
4
4
|
> rimraf dist && tsc -p tsconfig.pkg.json
|
|
5
5
|
|
package/dist/core/cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/core/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,WAAW,EACZ,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAElB,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EA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,eAAO,MAAM,eAAe,SAAS,CAAC;AACtC,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AACtC,eAAO,MAAM,eAAe,OAAO,CAAC"}
|
package/dist/core/cache.js
CHANGED
|
@@ -289,9 +289,12 @@ function normalizeScalarField(astNode, networkResponseParentRecord, targetStoreR
|
|
|
289
289
|
const networkResponseKey = getNetworkResponseKey(astNode);
|
|
290
290
|
const networkResponseData = networkResponseParentRecord[networkResponseKey];
|
|
291
291
|
const parentRecordKey = getParentRecordKey(astNode, variables);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
292
|
+
const existingValue = targetStoreRecord[parentRecordKey];
|
|
293
|
+
if (networkResponseData == null) {
|
|
294
|
+
targetStoreRecord[parentRecordKey] = null;
|
|
295
|
+
return existingValue !== null;
|
|
296
|
+
}
|
|
297
|
+
if (isScalarOrEmptyArray(networkResponseData)) {
|
|
295
298
|
targetStoreRecord[parentRecordKey] = networkResponseData;
|
|
296
299
|
return existingValue !== networkResponseData;
|
|
297
300
|
}
|
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-2ed40dec",
|
|
4
4
|
"description": "Use Isograph with React",
|
|
5
5
|
"homepage": "https://isograph.dev",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"author": "Isograph Labs",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@isograph/disposable-types": "0.0.0-main-
|
|
12
|
-
"@isograph/reference-counted-pointer": "0.0.0-main-
|
|
13
|
-
"@isograph/react-disposable-state": "0.0.0-main-
|
|
11
|
+
"@isograph/disposable-types": "0.0.0-main-2ed40dec",
|
|
12
|
+
"@isograph/reference-counted-pointer": "0.0.0-main-2ed40dec",
|
|
13
|
+
"@isograph/react-disposable-state": "0.0.0-main-2ed40dec"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"react": "^18.0.0 || ^19.0.0"
|
package/src/core/cache.ts
CHANGED
|
@@ -508,12 +508,14 @@ function normalizeScalarField(
|
|
|
508
508
|
const networkResponseKey = getNetworkResponseKey(astNode);
|
|
509
509
|
const networkResponseData = networkResponseParentRecord[networkResponseKey];
|
|
510
510
|
const parentRecordKey = getParentRecordKey(astNode, variables);
|
|
511
|
+
const existingValue = targetStoreRecord[parentRecordKey];
|
|
511
512
|
|
|
512
|
-
if (
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
513
|
+
if (networkResponseData == null) {
|
|
514
|
+
targetStoreRecord[parentRecordKey] = null;
|
|
515
|
+
return existingValue !== null;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (isScalarOrEmptyArray(networkResponseData)) {
|
|
517
519
|
targetStoreRecord[parentRecordKey] = networkResponseData;
|
|
518
520
|
return existingValue !== networkResponseData;
|
|
519
521
|
} else {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type {IsographEntrypoint, NormalizationAst, RefetchQueryNormalizationArtifactWrapper} from '@isograph/react';
|
|
2
|
+
import {Query__normalizeUndefinedField__param} from './param_type';
|
|
3
|
+
import {Query__normalizeUndefinedField__output_type} from './output_type';
|
|
4
|
+
import readerResolver from './resolver_reader';
|
|
5
|
+
import queryText from './query_text';
|
|
6
|
+
import normalizationAst from './normalization_ast';
|
|
7
|
+
const nestedRefetchQueries: RefetchQueryNormalizationArtifactWrapper[] = [];
|
|
8
|
+
|
|
9
|
+
const artifact: IsographEntrypoint<
|
|
10
|
+
Query__normalizeUndefinedField__param,
|
|
11
|
+
Query__normalizeUndefinedField__output_type,
|
|
12
|
+
NormalizationAst
|
|
13
|
+
> = {
|
|
14
|
+
kind: "Entrypoint",
|
|
15
|
+
networkRequestInfo: {
|
|
16
|
+
kind: "NetworkRequestInfo",
|
|
17
|
+
operation: {
|
|
18
|
+
kind: "Operation",
|
|
19
|
+
text: queryText,
|
|
20
|
+
},
|
|
21
|
+
normalizationAst,
|
|
22
|
+
},
|
|
23
|
+
concreteType: "Query",
|
|
24
|
+
readerWithRefetchQueries: {
|
|
25
|
+
kind: "ReaderWithRefetchQueries",
|
|
26
|
+
nestedRefetchQueries,
|
|
27
|
+
readerArtifact: readerResolver,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default artifact;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type {NormalizationAst} from '@isograph/react';
|
|
2
|
+
const normalizationAst: NormalizationAst = {
|
|
3
|
+
kind: "NormalizationAst",
|
|
4
|
+
selections: [
|
|
5
|
+
{
|
|
6
|
+
kind: "Linked",
|
|
7
|
+
fieldName: "me",
|
|
8
|
+
arguments: null,
|
|
9
|
+
concreteType: "Economist",
|
|
10
|
+
selections: [
|
|
11
|
+
{
|
|
12
|
+
kind: "Scalar",
|
|
13
|
+
fieldName: "id",
|
|
14
|
+
arguments: null,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
kind: "Scalar",
|
|
18
|
+
fieldName: "name",
|
|
19
|
+
arguments: null,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
export default normalizationAst;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { EagerReaderArtifact, ReaderAst } from '@isograph/react';
|
|
2
|
+
import { Query__normalizeUndefinedField__param } from './param_type';
|
|
3
|
+
import { Query__normalizeUndefinedField__output_type } from './output_type';
|
|
4
|
+
import { normalizeUndefinedField as resolver } from '../../../normalizeData.test';
|
|
5
|
+
|
|
6
|
+
const readerAst: ReaderAst<Query__normalizeUndefinedField__param> = [
|
|
7
|
+
{
|
|
8
|
+
kind: "Linked",
|
|
9
|
+
fieldName: "me",
|
|
10
|
+
alias: null,
|
|
11
|
+
arguments: null,
|
|
12
|
+
condition: null,
|
|
13
|
+
isUpdatable: false,
|
|
14
|
+
refetchQueryIndex: null,
|
|
15
|
+
selections: [
|
|
16
|
+
{
|
|
17
|
+
kind: "Scalar",
|
|
18
|
+
fieldName: "name",
|
|
19
|
+
alias: null,
|
|
20
|
+
arguments: null,
|
|
21
|
+
isUpdatable: false,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const artifact: EagerReaderArtifact<
|
|
28
|
+
Query__normalizeUndefinedField__param,
|
|
29
|
+
Query__normalizeUndefinedField__output_type
|
|
30
|
+
> = {
|
|
31
|
+
kind: "EagerReaderArtifact",
|
|
32
|
+
fieldName: "Query.normalizeUndefinedField",
|
|
33
|
+
resolver,
|
|
34
|
+
readerAst,
|
|
35
|
+
hasUpdatable: false,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default artifact;
|
|
@@ -3,12 +3,14 @@ import { type Query__linkedUpdate__param } from './Query/linkedUpdate/param_type
|
|
|
3
3
|
import { type Query__meNameSuccessor__param } from './Query/meNameSuccessor/param_type';
|
|
4
4
|
import { type Query__meName__param } from './Query/meName/param_type';
|
|
5
5
|
import { type Query__nodeField__param } from './Query/nodeField/param_type';
|
|
6
|
+
import { type Query__normalizeUndefinedField__param } from './Query/normalizeUndefinedField/param_type';
|
|
6
7
|
import { type Query__startUpdate__param } from './Query/startUpdate/param_type';
|
|
7
8
|
import { type Query__subquery__param } from './Query/subquery/param_type';
|
|
8
9
|
import entrypoint_Query__linkedUpdate from '../__isograph/Query/linkedUpdate/entrypoint';
|
|
9
10
|
import entrypoint_Query__meNameSuccessor from '../__isograph/Query/meNameSuccessor/entrypoint';
|
|
10
11
|
import entrypoint_Query__meName from '../__isograph/Query/meName/entrypoint';
|
|
11
12
|
import entrypoint_Query__nodeField from '../__isograph/Query/nodeField/entrypoint';
|
|
13
|
+
import entrypoint_Query__normalizeUndefinedField from '../__isograph/Query/normalizeUndefinedField/entrypoint';
|
|
12
14
|
import entrypoint_Query__startUpdate from '../__isograph/Query/startUpdate/entrypoint';
|
|
13
15
|
import entrypoint_Query__subquery from '../__isograph/Query/subquery/entrypoint';
|
|
14
16
|
|
|
@@ -76,6 +78,10 @@ export function iso<T>(
|
|
|
76
78
|
param: T & MatchesWhitespaceAndString<'field Query.nodeField', T>
|
|
77
79
|
): IdentityWithParam<Query__nodeField__param>;
|
|
78
80
|
|
|
81
|
+
export function iso<T>(
|
|
82
|
+
param: T & MatchesWhitespaceAndString<'field Query.normalizeUndefinedField', T>
|
|
83
|
+
): IdentityWithParam<Query__normalizeUndefinedField__param>;
|
|
84
|
+
|
|
79
85
|
export function iso<T>(
|
|
80
86
|
param: T & MatchesWhitespaceAndString<'field Query.startUpdate', T>
|
|
81
87
|
): IdentityWithParam<Query__startUpdate__param>;
|
|
@@ -100,6 +106,10 @@ export function iso<T>(
|
|
|
100
106
|
param: T & MatchesWhitespaceAndString<'entrypoint Query.nodeField', T>
|
|
101
107
|
): typeof entrypoint_Query__nodeField;
|
|
102
108
|
|
|
109
|
+
export function iso<T>(
|
|
110
|
+
param: T & MatchesWhitespaceAndString<'entrypoint Query.normalizeUndefinedField', T>
|
|
111
|
+
): typeof entrypoint_Query__normalizeUndefinedField;
|
|
112
|
+
|
|
103
113
|
export function iso<T>(
|
|
104
114
|
param: T & MatchesWhitespaceAndString<'entrypoint Query.startUpdate', T>
|
|
105
115
|
): typeof entrypoint_Query__startUpdate;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, expect, test, vi } from 'vitest';
|
|
1
|
+
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
|
2
2
|
import { getOrCreateCacheForArtifact, normalizeData } from '../core/cache';
|
|
3
3
|
import {
|
|
4
4
|
createIsographEnvironment,
|
|
@@ -13,6 +13,84 @@ import {
|
|
|
13
13
|
import { iso } from './__isograph/iso';
|
|
14
14
|
import type { Query__subquery__param } from './__isograph/Query/subquery/param_type';
|
|
15
15
|
|
|
16
|
+
let store: ReturnType<typeof createIsographStore>;
|
|
17
|
+
let environment: ReturnType<typeof createIsographEnvironment>;
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
store = createIsographStore();
|
|
21
|
+
const networkFunction = vi.fn().mockRejectedValue(new Error('Fetch failed'));
|
|
22
|
+
environment = createIsographEnvironment(store, networkFunction);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const normalizeUndefinedField = iso(`
|
|
26
|
+
field Query.normalizeUndefinedField {
|
|
27
|
+
me {
|
|
28
|
+
name
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`)(() => {});
|
|
32
|
+
// prettier-ignore
|
|
33
|
+
const normalizeUndefinedFieldEntrypoint = iso(`entrypoint Query.normalizeUndefinedField`);
|
|
34
|
+
|
|
35
|
+
describe('normalize undefined field', () => {
|
|
36
|
+
test('should normalize scalar field to null', () => {
|
|
37
|
+
normalizeData(
|
|
38
|
+
environment,
|
|
39
|
+
environment.store,
|
|
40
|
+
normalizeUndefinedFieldEntrypoint.networkRequestInfo.normalizationAst
|
|
41
|
+
.selections,
|
|
42
|
+
{
|
|
43
|
+
me: { __typename: 'Economist', id: '1' },
|
|
44
|
+
},
|
|
45
|
+
{},
|
|
46
|
+
{
|
|
47
|
+
__link: ROOT_ID,
|
|
48
|
+
__typename: normalizeUndefinedFieldEntrypoint.concreteType,
|
|
49
|
+
},
|
|
50
|
+
new Map(),
|
|
51
|
+
);
|
|
52
|
+
expect(store).toStrictEqual({
|
|
53
|
+
Economist: {
|
|
54
|
+
'1': {
|
|
55
|
+
id: '1',
|
|
56
|
+
name: null,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
Query: {
|
|
60
|
+
[ROOT_ID]: {
|
|
61
|
+
me: {
|
|
62
|
+
__typename: 'Economist',
|
|
63
|
+
__link: '1',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('should normalize linked field to null', () => {
|
|
71
|
+
normalizeData(
|
|
72
|
+
environment,
|
|
73
|
+
environment.store,
|
|
74
|
+
normalizeUndefinedFieldEntrypoint.networkRequestInfo.normalizationAst
|
|
75
|
+
.selections,
|
|
76
|
+
{},
|
|
77
|
+
{},
|
|
78
|
+
{
|
|
79
|
+
__link: ROOT_ID,
|
|
80
|
+
__typename: normalizeUndefinedFieldEntrypoint.concreteType,
|
|
81
|
+
},
|
|
82
|
+
new Map(),
|
|
83
|
+
);
|
|
84
|
+
expect(store).toStrictEqual({
|
|
85
|
+
Query: {
|
|
86
|
+
[ROOT_ID]: {
|
|
87
|
+
me: null,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
16
94
|
export const subquery = iso(`
|
|
17
95
|
field Query.subquery($id: ID!) {
|
|
18
96
|
query {
|
|
@@ -25,14 +103,8 @@ export const subquery = iso(`
|
|
|
25
103
|
|
|
26
104
|
const entrypoint = iso(`entrypoint Query.subquery`);
|
|
27
105
|
|
|
28
|
-
describe('
|
|
29
|
-
test('
|
|
30
|
-
const store = createIsographStore();
|
|
31
|
-
const networkFunction = vi
|
|
32
|
-
.fn()
|
|
33
|
-
.mockRejectedValue(new Error('Fetch failed'));
|
|
34
|
-
const environment = createIsographEnvironment(store, networkFunction);
|
|
35
|
-
|
|
106
|
+
describe('nested Query', () => {
|
|
107
|
+
test('should be normalized', () => {
|
|
36
108
|
normalizeData(
|
|
37
109
|
environment,
|
|
38
110
|
environment.store,
|
|
@@ -66,10 +138,8 @@ describe('normalizeData', () => {
|
|
|
66
138
|
},
|
|
67
139
|
} satisfies BaseStoreLayerData);
|
|
68
140
|
});
|
|
69
|
-
});
|
|
70
141
|
|
|
71
|
-
|
|
72
|
-
test('nested Query should be read', () => {
|
|
142
|
+
test('should be read', () => {
|
|
73
143
|
const store: BaseStoreLayerData = {
|
|
74
144
|
Economist: {
|
|
75
145
|
'1': {
|