@isograph/react 0.3.0 → 0.3.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-typescript.log +4 -0
- package/dist/core/FragmentReference.d.ts +16 -7
- package/dist/core/FragmentReference.d.ts.map +1 -1
- package/dist/core/FragmentReference.js +3 -12
- package/dist/core/IsographEnvironment.d.ts +17 -27
- package/dist/core/IsographEnvironment.d.ts.map +1 -1
- package/dist/core/IsographEnvironment.js +4 -0
- package/dist/core/PromiseWrapper.d.ts +3 -4
- package/dist/core/PromiseWrapper.d.ts.map +1 -1
- package/dist/core/PromiseWrapper.js +5 -4
- package/dist/core/areEqualWithDeepComparison.d.ts.map +1 -1
- package/dist/core/areEqualWithDeepComparison.js +16 -0
- package/dist/core/cache.d.ts +11 -20
- package/dist/core/cache.d.ts.map +1 -1
- package/dist/core/cache.js +60 -45
- package/dist/core/check.d.ts +9 -5
- package/dist/core/check.d.ts.map +1 -1
- package/dist/core/check.js +2 -2
- package/dist/core/componentCache.d.ts +1 -1
- package/dist/core/componentCache.d.ts.map +1 -1
- package/dist/core/componentCache.js +27 -31
- package/dist/core/entrypoint.d.ts +23 -26
- package/dist/core/entrypoint.d.ts.map +1 -1
- package/dist/core/garbageCollection.d.ts +3 -4
- package/dist/core/garbageCollection.d.ts.map +1 -1
- package/dist/core/garbageCollection.js +1 -1
- package/dist/core/logging.d.ts +12 -13
- package/dist/core/logging.d.ts.map +1 -1
- package/dist/core/logging.js +8 -5
- package/dist/core/makeNetworkRequest.d.ts +5 -5
- package/dist/core/makeNetworkRequest.d.ts.map +1 -1
- package/dist/core/makeNetworkRequest.js +107 -22
- package/dist/core/read.d.ts +15 -10
- package/dist/core/read.d.ts.map +1 -1
- package/dist/core/read.js +398 -304
- package/dist/core/reader.d.ts +24 -32
- package/dist/core/reader.d.ts.map +1 -1
- package/dist/core/startUpdate.d.ts +5 -0
- package/dist/core/startUpdate.d.ts.map +1 -0
- package/dist/core/startUpdate.js +15 -0
- package/dist/core/util.d.ts +3 -0
- package/dist/core/util.d.ts.map +1 -1
- package/dist/index.d.ts +16 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/loadable-hooks/useClientSideDefer.d.ts +4 -10
- package/dist/loadable-hooks/useClientSideDefer.d.ts.map +1 -1
- package/dist/loadable-hooks/useClientSideDefer.js +2 -2
- package/dist/loadable-hooks/useConnectionSpecPagination.d.ts +8 -15
- package/dist/loadable-hooks/useConnectionSpecPagination.d.ts.map +1 -1
- package/dist/loadable-hooks/useConnectionSpecPagination.js +6 -4
- package/dist/loadable-hooks/useImperativeExposedMutationField.d.ts +1 -2
- package/dist/loadable-hooks/useImperativeExposedMutationField.d.ts.map +1 -1
- package/dist/loadable-hooks/useImperativeLoadableField.d.ts +4 -6
- package/dist/loadable-hooks/useImperativeLoadableField.d.ts.map +1 -1
- package/dist/loadable-hooks/useImperativeLoadableField.js +1 -1
- package/dist/loadable-hooks/useSkipLimitPagination.d.ts +6 -13
- package/dist/loadable-hooks/useSkipLimitPagination.d.ts.map +1 -1
- package/dist/loadable-hooks/useSkipLimitPagination.js +11 -9
- package/dist/react/FragmentReader.d.ts +2 -3
- package/dist/react/FragmentReader.d.ts.map +1 -1
- package/dist/react/IsographEnvironmentProvider.d.ts.map +1 -1
- package/dist/react/useImperativeReference.d.ts +7 -10
- package/dist/react/useImperativeReference.d.ts.map +1 -1
- package/dist/react/useImperativeReference.js +2 -3
- package/dist/react/useLazyReference.d.ts +4 -7
- package/dist/react/useLazyReference.d.ts.map +1 -1
- package/dist/react/useLazyReference.js +26 -5
- package/dist/react/useReadAndSubscribe.d.ts +3 -9
- package/dist/react/useReadAndSubscribe.d.ts.map +1 -1
- package/dist/react/useReadAndSubscribe.js +7 -3
- package/dist/react/useRerenderOnChange.d.ts +1 -1
- package/dist/react/useRerenderOnChange.d.ts.map +1 -1
- package/dist/react/useResult.d.ts +3 -6
- package/dist/react/useResult.d.ts.map +1 -1
- package/dist/react/useResult.js +10 -8
- package/isograph.config.json +1 -0
- package/package.json +7 -6
- package/src/core/FragmentReference.ts +30 -15
- package/src/core/IsographEnvironment.ts +39 -31
- package/src/core/PromiseWrapper.ts +3 -3
- package/src/core/areEqualWithDeepComparison.ts +20 -0
- package/src/core/cache.ts +105 -72
- package/src/core/check.ts +13 -8
- package/src/core/componentCache.ts +45 -52
- package/src/core/entrypoint.ts +34 -16
- package/src/core/garbageCollection.ts +6 -6
- package/src/core/logging.ts +24 -22
- package/src/core/makeNetworkRequest.ts +183 -30
- package/src/core/read.ts +618 -435
- package/src/core/reader.ts +37 -24
- package/src/core/startUpdate.ts +28 -0
- package/src/core/util.ts +4 -0
- package/src/index.ts +82 -9
- package/src/loadable-hooks/useClientSideDefer.ts +11 -10
- package/src/loadable-hooks/useConnectionSpecPagination.ts +26 -13
- package/src/loadable-hooks/useImperativeExposedMutationField.ts +1 -1
- package/src/loadable-hooks/useImperativeLoadableField.ts +10 -12
- package/src/loadable-hooks/useSkipLimitPagination.ts +37 -19
- package/src/react/FragmentReader.tsx +3 -3
- package/src/react/IsographEnvironmentProvider.tsx +1 -1
- package/src/react/useImperativeReference.ts +40 -19
- package/src/react/useLazyReference.ts +62 -14
- package/src/react/useReadAndSubscribe.ts +17 -9
- package/src/react/useRerenderOnChange.ts +2 -2
- package/src/react/useResult.ts +21 -8
- package/src/tests/__isograph/Query/meName/entrypoint.ts +4 -28
- package/src/tests/__isograph/Query/meName/normalization_ast.ts +25 -0
- package/src/tests/__isograph/Query/meName/query_text.ts +6 -0
- package/src/tests/__isograph/Query/meName/resolver_reader.ts +4 -0
- package/src/tests/__isograph/Query/meNameSuccessor/entrypoint.ts +4 -66
- package/src/tests/__isograph/Query/meNameSuccessor/normalization_ast.ts +56 -0
- package/src/tests/__isograph/Query/meNameSuccessor/query_text.ts +13 -0
- package/src/tests/__isograph/Query/meNameSuccessor/resolver_reader.ts +7 -0
- package/src/tests/__isograph/Query/nodeField/entrypoint.ts +4 -33
- package/src/tests/__isograph/Query/nodeField/normalization_ast.ts +30 -0
- package/src/tests/__isograph/Query/nodeField/query_text.ts +6 -0
- package/src/tests/__isograph/Query/nodeField/resolver_reader.ts +4 -0
- package/src/tests/__isograph/Query/subquery/entrypoint.ts +4 -43
- package/src/tests/__isograph/Query/subquery/normalization_ast.ts +38 -0
- package/src/tests/__isograph/Query/subquery/query_text.ts +8 -0
- package/src/tests/__isograph/Query/subquery/resolver_reader.ts +5 -0
- package/src/tests/__isograph/iso.ts +3 -2
- package/src/tests/garbageCollection.test.ts +10 -8
- package/src/tests/meNameSuccessor.ts +1 -1
- package/src/tests/nodeQuery.ts +2 -1
- package/src/tests/normalizeData.test.ts +1 -1
- package/tsconfig.pkg.json +1 -2
@@ -2,43 +2,14 @@ import type {IsographEntrypoint, NormalizationAst, RefetchQueryNormalizationArti
|
|
2
2
|
import {Query__nodeField__param} from './param_type';
|
3
3
|
import {Query__nodeField__output_type} from './output_type';
|
4
4
|
import readerResolver from './resolver_reader';
|
5
|
+
import queryText from './query_text';
|
6
|
+
import normalizationAst from './normalization_ast';
|
5
7
|
const nestedRefetchQueries: RefetchQueryNormalizationArtifactWrapper[] = [];
|
6
8
|
|
7
|
-
const queryText = 'query nodeField ($id: ID!) {\
|
8
|
-
node____id___v_id: node(id: $id) {\
|
9
|
-
__typename,\
|
10
|
-
id,\
|
11
|
-
},\
|
12
|
-
}';
|
13
|
-
|
14
|
-
const normalizationAst: NormalizationAst = [
|
15
|
-
{
|
16
|
-
kind: "Linked",
|
17
|
-
fieldName: "node",
|
18
|
-
arguments: [
|
19
|
-
[
|
20
|
-
"id",
|
21
|
-
{ kind: "Variable", name: "id" },
|
22
|
-
],
|
23
|
-
],
|
24
|
-
concreteType: null,
|
25
|
-
selections: [
|
26
|
-
{
|
27
|
-
kind: "Scalar",
|
28
|
-
fieldName: "__typename",
|
29
|
-
arguments: null,
|
30
|
-
},
|
31
|
-
{
|
32
|
-
kind: "Scalar",
|
33
|
-
fieldName: "id",
|
34
|
-
arguments: null,
|
35
|
-
},
|
36
|
-
],
|
37
|
-
},
|
38
|
-
];
|
39
9
|
const artifact: IsographEntrypoint<
|
40
10
|
Query__nodeField__param,
|
41
|
-
Query__nodeField__output_type
|
11
|
+
Query__nodeField__output_type,
|
12
|
+
NormalizationAst
|
42
13
|
> = {
|
43
14
|
kind: "Entrypoint",
|
44
15
|
networkRequestInfo: {
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import type {NormalizationAst} from '@isograph/react';
|
2
|
+
const normalizationAst: NormalizationAst = {
|
3
|
+
kind: "NormalizationAst",
|
4
|
+
selections: [
|
5
|
+
{
|
6
|
+
kind: "Linked",
|
7
|
+
fieldName: "node",
|
8
|
+
arguments: [
|
9
|
+
[
|
10
|
+
"id",
|
11
|
+
{ kind: "Variable", name: "id" },
|
12
|
+
],
|
13
|
+
],
|
14
|
+
concreteType: null,
|
15
|
+
selections: [
|
16
|
+
{
|
17
|
+
kind: "Scalar",
|
18
|
+
fieldName: "__typename",
|
19
|
+
arguments: null,
|
20
|
+
},
|
21
|
+
{
|
22
|
+
kind: "Scalar",
|
23
|
+
fieldName: "id",
|
24
|
+
arguments: null,
|
25
|
+
},
|
26
|
+
],
|
27
|
+
},
|
28
|
+
],
|
29
|
+
};
|
30
|
+
export default normalizationAst;
|
@@ -15,12 +15,14 @@ const readerAst: ReaderAst<Query__nodeField__param> = [
|
|
15
15
|
],
|
16
16
|
],
|
17
17
|
condition: null,
|
18
|
+
isUpdatable: false,
|
18
19
|
selections: [
|
19
20
|
{
|
20
21
|
kind: "Scalar",
|
21
22
|
fieldName: "id",
|
22
23
|
alias: null,
|
23
24
|
arguments: null,
|
25
|
+
isUpdatable: false,
|
24
26
|
},
|
25
27
|
],
|
26
28
|
},
|
@@ -31,8 +33,10 @@ const artifact: EagerReaderArtifact<
|
|
31
33
|
Query__nodeField__output_type
|
32
34
|
> = {
|
33
35
|
kind: "EagerReaderArtifact",
|
36
|
+
fieldName: "Query.nodeField",
|
34
37
|
resolver,
|
35
38
|
readerAst,
|
39
|
+
hasUpdatable: false,
|
36
40
|
};
|
37
41
|
|
38
42
|
export default artifact;
|
@@ -2,53 +2,14 @@ import type {IsographEntrypoint, NormalizationAst, RefetchQueryNormalizationArti
|
|
2
2
|
import {Query__subquery__param} from './param_type';
|
3
3
|
import {Query__subquery__output_type} from './output_type';
|
4
4
|
import readerResolver from './resolver_reader';
|
5
|
+
import queryText from './query_text';
|
6
|
+
import normalizationAst from './normalization_ast';
|
5
7
|
const nestedRefetchQueries: RefetchQueryNormalizationArtifactWrapper[] = [];
|
6
8
|
|
7
|
-
const queryText = 'query subquery ($id: ID!) {\
|
8
|
-
query {\
|
9
|
-
node____id___v_id: node(id: $id) {\
|
10
|
-
__typename,\
|
11
|
-
id,\
|
12
|
-
},\
|
13
|
-
},\
|
14
|
-
}';
|
15
|
-
|
16
|
-
const normalizationAst: NormalizationAst = [
|
17
|
-
{
|
18
|
-
kind: "Linked",
|
19
|
-
fieldName: "query",
|
20
|
-
arguments: null,
|
21
|
-
concreteType: "Query",
|
22
|
-
selections: [
|
23
|
-
{
|
24
|
-
kind: "Linked",
|
25
|
-
fieldName: "node",
|
26
|
-
arguments: [
|
27
|
-
[
|
28
|
-
"id",
|
29
|
-
{ kind: "Variable", name: "id" },
|
30
|
-
],
|
31
|
-
],
|
32
|
-
concreteType: null,
|
33
|
-
selections: [
|
34
|
-
{
|
35
|
-
kind: "Scalar",
|
36
|
-
fieldName: "__typename",
|
37
|
-
arguments: null,
|
38
|
-
},
|
39
|
-
{
|
40
|
-
kind: "Scalar",
|
41
|
-
fieldName: "id",
|
42
|
-
arguments: null,
|
43
|
-
},
|
44
|
-
],
|
45
|
-
},
|
46
|
-
],
|
47
|
-
},
|
48
|
-
];
|
49
9
|
const artifact: IsographEntrypoint<
|
50
10
|
Query__subquery__param,
|
51
|
-
Query__subquery__output_type
|
11
|
+
Query__subquery__output_type,
|
12
|
+
NormalizationAst
|
52
13
|
> = {
|
53
14
|
kind: "Entrypoint",
|
54
15
|
networkRequestInfo: {
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import type {NormalizationAst} from '@isograph/react';
|
2
|
+
const normalizationAst: NormalizationAst = {
|
3
|
+
kind: "NormalizationAst",
|
4
|
+
selections: [
|
5
|
+
{
|
6
|
+
kind: "Linked",
|
7
|
+
fieldName: "query",
|
8
|
+
arguments: null,
|
9
|
+
concreteType: "Query",
|
10
|
+
selections: [
|
11
|
+
{
|
12
|
+
kind: "Linked",
|
13
|
+
fieldName: "node",
|
14
|
+
arguments: [
|
15
|
+
[
|
16
|
+
"id",
|
17
|
+
{ kind: "Variable", name: "id" },
|
18
|
+
],
|
19
|
+
],
|
20
|
+
concreteType: null,
|
21
|
+
selections: [
|
22
|
+
{
|
23
|
+
kind: "Scalar",
|
24
|
+
fieldName: "__typename",
|
25
|
+
arguments: null,
|
26
|
+
},
|
27
|
+
{
|
28
|
+
kind: "Scalar",
|
29
|
+
fieldName: "id",
|
30
|
+
arguments: null,
|
31
|
+
},
|
32
|
+
],
|
33
|
+
},
|
34
|
+
],
|
35
|
+
},
|
36
|
+
],
|
37
|
+
};
|
38
|
+
export default normalizationAst;
|
@@ -10,6 +10,7 @@ const readerAst: ReaderAst<Query__subquery__param> = [
|
|
10
10
|
alias: null,
|
11
11
|
arguments: null,
|
12
12
|
condition: null,
|
13
|
+
isUpdatable: false,
|
13
14
|
selections: [
|
14
15
|
{
|
15
16
|
kind: "Linked",
|
@@ -22,12 +23,14 @@ const readerAst: ReaderAst<Query__subquery__param> = [
|
|
22
23
|
],
|
23
24
|
],
|
24
25
|
condition: null,
|
26
|
+
isUpdatable: false,
|
25
27
|
selections: [
|
26
28
|
{
|
27
29
|
kind: "Scalar",
|
28
30
|
fieldName: "id",
|
29
31
|
alias: null,
|
30
32
|
arguments: null,
|
33
|
+
isUpdatable: false,
|
31
34
|
},
|
32
35
|
],
|
33
36
|
},
|
@@ -40,8 +43,10 @@ const artifact: EagerReaderArtifact<
|
|
40
43
|
Query__subquery__output_type
|
41
44
|
> = {
|
42
45
|
kind: "EagerReaderArtifact",
|
46
|
+
fieldName: "Query.subquery",
|
43
47
|
resolver,
|
44
48
|
readerAst,
|
49
|
+
hasUpdatable: false,
|
45
50
|
};
|
46
51
|
|
47
52
|
export default artifact;
|
@@ -91,9 +91,10 @@ export function iso<T>(
|
|
91
91
|
export function iso(_isographLiteralText: string):
|
92
92
|
| IdentityWithParam<any>
|
93
93
|
| IdentityWithParamComponent<any>
|
94
|
-
| IsographEntrypoint<any, any>
|
94
|
+
| IsographEntrypoint<any, any, any>
|
95
95
|
{
|
96
96
|
throw new Error('iso: Unexpected invocation at runtime. Either the Babel transform ' +
|
97
97
|
'was not set up, or it failed to identify this call site. Make sure it ' +
|
98
|
-
'is being used verbatim as `iso`.'
|
98
|
+
'is being used verbatim as `iso`. If you cannot use the babel transform, ' +
|
99
|
+
'set options.no_babel_transform to true in your Isograph config. ');
|
99
100
|
}
|
@@ -1,14 +1,15 @@
|
|
1
|
-
import { describe,
|
2
|
-
import {
|
3
|
-
ROOT_ID,
|
4
|
-
createIsographEnvironment,
|
5
|
-
type IsographStore,
|
6
|
-
} from '../core/IsographEnvironment';
|
1
|
+
import { describe, expect, test } from 'vitest';
|
7
2
|
import {
|
8
3
|
garbageCollectEnvironment,
|
9
4
|
retainQuery,
|
10
5
|
} from '../core/garbageCollection';
|
6
|
+
import {
|
7
|
+
createIsographEnvironment,
|
8
|
+
ROOT_ID,
|
9
|
+
type IsographStore,
|
10
|
+
} from '../core/IsographEnvironment';
|
11
11
|
import { iso } from './__isograph/iso';
|
12
|
+
import { meNameSuccessorRetainedQuery } from './meNameSuccessor';
|
12
13
|
import { nodeFieldRetainedQuery } from './nodeQuery';
|
13
14
|
|
14
15
|
const getDefaultStore = (): IsographStore => ({
|
@@ -52,10 +53,11 @@ export const meNameField = iso(`
|
|
52
53
|
}
|
53
54
|
}
|
54
55
|
`)(() => {});
|
55
|
-
|
56
|
+
|
56
57
|
const meNameEntrypoint = iso(`entrypoint Query.meName`);
|
57
58
|
const meNameRetainedQuery = {
|
58
|
-
normalizationAst:
|
59
|
+
normalizationAst:
|
60
|
+
meNameEntrypoint.networkRequestInfo.normalizationAst.selections,
|
59
61
|
variables: {},
|
60
62
|
root: { __link: ROOT_ID, __typename: 'Query' },
|
61
63
|
};
|
@@ -16,7 +16,7 @@ export const meNameField = iso(`
|
|
16
16
|
const meNameSuccessorEntrypoint = iso(`entrypoint Query.meNameSuccessor`);
|
17
17
|
export const meNameSuccessorRetainedQuery = {
|
18
18
|
normalizationAst:
|
19
|
-
meNameSuccessorEntrypoint.networkRequestInfo.normalizationAst,
|
19
|
+
meNameSuccessorEntrypoint.networkRequestInfo.normalizationAst.selections,
|
20
20
|
variables: {},
|
21
21
|
root: {
|
22
22
|
__link: ROOT_ID,
|
package/src/tests/nodeQuery.ts
CHANGED
@@ -13,7 +13,8 @@ export const nodeField = iso(`
|
|
13
13
|
`)(() => {});
|
14
14
|
const nodeFieldEntrypoint = iso(`entrypoint Query.nodeField`);
|
15
15
|
export const nodeFieldRetainedQuery: RetainedQuery = {
|
16
|
-
normalizationAst:
|
16
|
+
normalizationAst:
|
17
|
+
nodeFieldEntrypoint.networkRequestInfo.normalizationAst.selections,
|
17
18
|
variables: { id: 0 },
|
18
19
|
root: { __link: ROOT_ID, __typename: 'Query' },
|
19
20
|
};
|
@@ -35,7 +35,7 @@ describe('normalizeData', () => {
|
|
35
35
|
|
36
36
|
normalizeData(
|
37
37
|
environment,
|
38
|
-
entrypoint.networkRequestInfo.normalizationAst,
|
38
|
+
entrypoint.networkRequestInfo.normalizationAst.selections,
|
39
39
|
{
|
40
40
|
query: { node____id___v_id: { __typename: 'Economist', id: '1' } },
|
41
41
|
},
|