@isograph/react 0.2.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 +25 -6
- package/dist/core/FragmentReference.d.ts.map +1 -0
- package/dist/core/FragmentReference.js +3 -13
- package/dist/core/IsographEnvironment.d.ts +34 -26
- package/dist/core/IsographEnvironment.d.ts.map +1 -0
- package/dist/core/IsographEnvironment.js +19 -22
- package/dist/core/PromiseWrapper.d.ts +4 -4
- package/dist/core/PromiseWrapper.d.ts.map +1 -0
- package/dist/core/PromiseWrapper.js +9 -9
- package/dist/core/areEqualWithDeepComparison.d.ts +5 -3
- package/dist/core/areEqualWithDeepComparison.d.ts.map +1 -0
- package/dist/core/areEqualWithDeepComparison.js +89 -39
- package/dist/core/cache.d.ts +20 -13
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/cache.js +205 -128
- package/dist/core/check.d.ts +22 -0
- package/dist/core/check.d.ts.map +1 -0
- package/dist/core/check.js +127 -0
- package/dist/core/componentCache.d.ts +2 -2
- package/dist/core/componentCache.d.ts.map +1 -0
- package/dist/core/componentCache.js +28 -32
- package/dist/core/entrypoint.d.ts +31 -15
- package/dist/core/entrypoint.d.ts.map +1 -0
- package/dist/core/entrypoint.js +1 -2
- package/dist/core/garbageCollection.d.ts +6 -5
- package/dist/core/garbageCollection.d.ts.map +1 -0
- package/dist/core/garbageCollection.js +49 -16
- package/dist/core/logging.d.ts +68 -0
- package/dist/core/logging.d.ts.map +1 -0
- package/dist/core/logging.js +22 -0
- package/dist/core/makeNetworkRequest.d.ts +6 -3
- package/dist/core/makeNetworkRequest.d.ts.map +1 -0
- package/dist/core/makeNetworkRequest.js +160 -19
- package/dist/core/read.d.ts +25 -5
- package/dist/core/read.d.ts.map +1 -0
- package/dist/core/read.js +416 -259
- package/dist/core/reader.d.ts +31 -15
- package/dist/core/reader.d.ts.map +1 -0
- 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 +5 -0
- package/dist/core/util.d.ts.map +1 -0
- package/dist/index.d.ts +19 -14
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -2
- package/dist/loadable-hooks/useClientSideDefer.d.ts +9 -3
- package/dist/loadable-hooks/useClientSideDefer.d.ts.map +1 -0
- package/dist/loadable-hooks/useClientSideDefer.js +6 -8
- package/dist/loadable-hooks/useConnectionSpecPagination.d.ts +27 -0
- package/dist/loadable-hooks/useConnectionSpecPagination.d.ts.map +1 -0
- package/dist/loadable-hooks/useConnectionSpecPagination.js +162 -0
- package/dist/loadable-hooks/useImperativeExposedMutationField.d.ts +2 -2
- package/dist/loadable-hooks/useImperativeExposedMutationField.d.ts.map +1 -0
- package/dist/loadable-hooks/useImperativeExposedMutationField.js +1 -2
- package/dist/loadable-hooks/useImperativeLoadableField.d.ts +13 -7
- package/dist/loadable-hooks/useImperativeLoadableField.d.ts.map +1 -0
- package/dist/loadable-hooks/useImperativeLoadableField.js +4 -5
- package/dist/loadable-hooks/useSkipLimitPagination.d.ts +13 -26
- package/dist/loadable-hooks/useSkipLimitPagination.d.ts.map +1 -0
- package/dist/loadable-hooks/useSkipLimitPagination.js +93 -47
- package/dist/react/FragmentReader.d.ts +6 -4
- package/dist/react/FragmentReader.d.ts.map +1 -0
- package/dist/react/FragmentReader.js +4 -2
- package/dist/react/IsographEnvironmentProvider.d.ts +1 -0
- package/dist/react/IsographEnvironmentProvider.d.ts.map +1 -0
- package/dist/react/IsographEnvironmentProvider.js +3 -3
- package/dist/react/RenderAfterCommit__DO_NOT_USE.d.ts +10 -0
- package/dist/react/RenderAfterCommit__DO_NOT_USE.d.ts.map +1 -0
- package/dist/react/RenderAfterCommit__DO_NOT_USE.js +15 -0
- package/dist/react/useImperativeReference.d.ts +8 -6
- package/dist/react/useImperativeReference.d.ts.map +1 -0
- package/dist/react/useImperativeReference.js +6 -8
- package/dist/react/useLazyReference.d.ts +5 -3
- package/dist/react/useLazyReference.d.ts.map +1 -0
- package/dist/react/useLazyReference.js +34 -6
- package/dist/react/useReadAndSubscribe.d.ts +6 -3
- package/dist/react/useReadAndSubscribe.d.ts.map +1 -0
- package/dist/react/useReadAndSubscribe.js +13 -10
- package/dist/react/useRerenderOnChange.d.ts +7 -2
- package/dist/react/useRerenderOnChange.d.ts.map +1 -0
- package/dist/react/useRerenderOnChange.js +3 -4
- package/dist/react/useResult.d.ts +4 -3
- package/dist/react/useResult.d.ts.map +1 -0
- package/dist/react/useResult.js +14 -9
- package/isograph.config.json +8 -0
- package/package.json +14 -9
- package/{src/tests/schema.graphql → schema.graphql} +1 -0
- package/src/core/FragmentReference.ts +44 -17
- package/src/core/IsographEnvironment.ts +67 -50
- package/src/core/PromiseWrapper.ts +3 -3
- package/src/core/areEqualWithDeepComparison.ts +95 -41
- package/src/core/cache.ts +316 -169
- package/src/core/check.ts +212 -0
- package/src/core/componentCache.ts +40 -46
- package/src/core/entrypoint.ts +41 -16
- package/src/core/garbageCollection.ts +77 -26
- package/src/core/logging.ts +118 -0
- package/src/core/makeNetworkRequest.ts +249 -20
- package/src/core/read.ts +658 -368
- package/src/core/reader.ts +61 -21
- package/src/core/startUpdate.ts +28 -0
- package/src/core/util.ts +8 -0
- package/src/index.ts +94 -8
- package/src/loadable-hooks/useClientSideDefer.ts +48 -17
- package/src/loadable-hooks/useConnectionSpecPagination.ts +344 -0
- package/src/loadable-hooks/useImperativeExposedMutationField.ts +1 -1
- package/src/loadable-hooks/useImperativeLoadableField.ts +36 -12
- package/src/loadable-hooks/useSkipLimitPagination.ts +253 -94
- package/src/react/FragmentReader.tsx +15 -6
- package/src/react/IsographEnvironmentProvider.tsx +1 -1
- package/src/react/RenderAfterCommit__DO_NOT_USE.tsx +17 -0
- package/src/react/useImperativeReference.ts +50 -18
- package/src/react/useLazyReference.ts +79 -11
- package/src/react/useReadAndSubscribe.ts +33 -10
- package/src/react/useRerenderOnChange.ts +7 -2
- package/src/react/useResult.ts +30 -9
- package/src/tests/__isograph/Query/meName/entrypoint.ts +10 -29
- package/src/tests/__isograph/Query/meName/normalization_ast.ts +25 -0
- package/src/tests/__isograph/Query/meName/param_type.ts +5 -2
- package/src/tests/__isograph/Query/meName/query_text.ts +6 -0
- package/src/tests/__isograph/Query/meName/resolver_reader.ts +5 -0
- package/src/tests/__isograph/Query/meNameSuccessor/entrypoint.ts +10 -65
- package/src/tests/__isograph/Query/meNameSuccessor/normalization_ast.ts +56 -0
- package/src/tests/__isograph/Query/meNameSuccessor/param_type.ts +9 -6
- package/src/tests/__isograph/Query/meNameSuccessor/query_text.ts +13 -0
- package/src/tests/__isograph/Query/meNameSuccessor/resolver_reader.ts +10 -0
- package/src/tests/__isograph/Query/nodeField/entrypoint.ts +10 -28
- package/src/tests/__isograph/Query/nodeField/normalization_ast.ts +30 -0
- package/src/tests/__isograph/Query/nodeField/param_type.ts +7 -3
- package/src/tests/__isograph/Query/nodeField/parameters_type.ts +3 -0
- package/src/tests/__isograph/Query/nodeField/query_text.ts +6 -0
- package/src/tests/__isograph/Query/nodeField/resolver_reader.ts +5 -0
- package/src/tests/__isograph/Query/subquery/entrypoint.ts +28 -0
- package/src/tests/__isograph/Query/subquery/normalization_ast.ts +38 -0
- package/src/tests/__isograph/Query/subquery/output_type.ts +3 -0
- package/src/tests/__isograph/Query/subquery/param_type.ts +12 -0
- package/src/tests/__isograph/Query/subquery/parameters_type.ts +3 -0
- package/src/tests/__isograph/Query/subquery/query_text.ts +8 -0
- package/src/tests/__isograph/Query/subquery/resolver_reader.ts +52 -0
- package/src/tests/__isograph/iso.ts +24 -12
- package/src/tests/garbageCollection.test.ts +53 -45
- package/src/tests/meNameSuccessor.ts +8 -3
- package/src/tests/nodeQuery.ts +7 -4
- package/src/tests/normalizeData.test.ts +120 -0
- package/src/tests/tsconfig.json +3 -3
- package/tsconfig.json +2 -2
- package/tsconfig.pkg.json +7 -3
- package/vitest.config.ts +20 -0
- package/src/tests/isograph.config.json +0 -7
@@ -2,40 +2,22 @@ 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
|
-
id,\
|
10
|
-
},\
|
11
|
-
}';
|
12
|
-
|
13
|
-
const normalizationAst: NormalizationAst = [
|
14
|
-
{
|
15
|
-
kind: "Linked",
|
16
|
-
fieldName: "node",
|
17
|
-
arguments: [
|
18
|
-
[
|
19
|
-
"id",
|
20
|
-
{ kind: "Variable", name: "id" },
|
21
|
-
],
|
22
|
-
],
|
23
|
-
selections: [
|
24
|
-
{
|
25
|
-
kind: "Scalar",
|
26
|
-
fieldName: "id",
|
27
|
-
arguments: null,
|
28
|
-
},
|
29
|
-
],
|
30
|
-
},
|
31
|
-
];
|
32
9
|
const artifact: IsographEntrypoint<
|
33
10
|
Query__nodeField__param,
|
34
|
-
Query__nodeField__output_type
|
11
|
+
Query__nodeField__output_type,
|
12
|
+
NormalizationAst
|
35
13
|
> = {
|
36
14
|
kind: "Entrypoint",
|
37
|
-
|
38
|
-
|
15
|
+
networkRequestInfo: {
|
16
|
+
kind: "NetworkRequestInfo",
|
17
|
+
queryText,
|
18
|
+
normalizationAst,
|
19
|
+
},
|
20
|
+
concreteType: "Query",
|
39
21
|
readerWithRefetchQueries: {
|
40
22
|
kind: "ReaderWithRefetchQueries",
|
41
23
|
nestedRefetchQueries,
|
@@ -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;
|
@@ -1,6 +1,10 @@
|
|
1
|
+
import type { Query__nodeField__parameters } from './parameters_type';
|
1
2
|
|
2
3
|
export type Query__nodeField__param = {
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
readonly data: {
|
5
|
+
readonly node: ({
|
6
|
+
readonly id: string,
|
7
|
+
} | null),
|
8
|
+
},
|
9
|
+
readonly parameters: Query__nodeField__parameters,
|
6
10
|
};
|
@@ -14,12 +14,15 @@ const readerAst: ReaderAst<Query__nodeField__param> = [
|
|
14
14
|
{ kind: "Variable", name: "id" },
|
15
15
|
],
|
16
16
|
],
|
17
|
+
condition: null,
|
18
|
+
isUpdatable: false,
|
17
19
|
selections: [
|
18
20
|
{
|
19
21
|
kind: "Scalar",
|
20
22
|
fieldName: "id",
|
21
23
|
alias: null,
|
22
24
|
arguments: null,
|
25
|
+
isUpdatable: false,
|
23
26
|
},
|
24
27
|
],
|
25
28
|
},
|
@@ -30,8 +33,10 @@ const artifact: EagerReaderArtifact<
|
|
30
33
|
Query__nodeField__output_type
|
31
34
|
> = {
|
32
35
|
kind: "EagerReaderArtifact",
|
36
|
+
fieldName: "Query.nodeField",
|
33
37
|
resolver,
|
34
38
|
readerAst,
|
39
|
+
hasUpdatable: false,
|
35
40
|
};
|
36
41
|
|
37
42
|
export default artifact;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import type {IsographEntrypoint, NormalizationAst, RefetchQueryNormalizationArtifactWrapper} from '@isograph/react';
|
2
|
+
import {Query__subquery__param} from './param_type';
|
3
|
+
import {Query__subquery__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__subquery__param,
|
11
|
+
Query__subquery__output_type,
|
12
|
+
NormalizationAst
|
13
|
+
> = {
|
14
|
+
kind: "Entrypoint",
|
15
|
+
networkRequestInfo: {
|
16
|
+
kind: "NetworkRequestInfo",
|
17
|
+
queryText,
|
18
|
+
normalizationAst,
|
19
|
+
},
|
20
|
+
concreteType: "Query",
|
21
|
+
readerWithRefetchQueries: {
|
22
|
+
kind: "ReaderWithRefetchQueries",
|
23
|
+
nestedRefetchQueries,
|
24
|
+
readerArtifact: readerResolver,
|
25
|
+
},
|
26
|
+
};
|
27
|
+
|
28
|
+
export default artifact;
|
@@ -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;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { Query__subquery__parameters } from './parameters_type';
|
2
|
+
|
3
|
+
export type Query__subquery__param = {
|
4
|
+
readonly data: {
|
5
|
+
readonly query: {
|
6
|
+
readonly node: ({
|
7
|
+
readonly id: string,
|
8
|
+
} | null),
|
9
|
+
},
|
10
|
+
},
|
11
|
+
readonly parameters: Query__subquery__parameters,
|
12
|
+
};
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import type { EagerReaderArtifact, ReaderAst } from '@isograph/react';
|
2
|
+
import { Query__subquery__param } from './param_type';
|
3
|
+
import { Query__subquery__output_type } from './output_type';
|
4
|
+
import { subquery as resolver } from '../../../normalizeData.test';
|
5
|
+
|
6
|
+
const readerAst: ReaderAst<Query__subquery__param> = [
|
7
|
+
{
|
8
|
+
kind: "Linked",
|
9
|
+
fieldName: "query",
|
10
|
+
alias: null,
|
11
|
+
arguments: null,
|
12
|
+
condition: null,
|
13
|
+
isUpdatable: false,
|
14
|
+
selections: [
|
15
|
+
{
|
16
|
+
kind: "Linked",
|
17
|
+
fieldName: "node",
|
18
|
+
alias: null,
|
19
|
+
arguments: [
|
20
|
+
[
|
21
|
+
"id",
|
22
|
+
{ kind: "Variable", name: "id" },
|
23
|
+
],
|
24
|
+
],
|
25
|
+
condition: null,
|
26
|
+
isUpdatable: false,
|
27
|
+
selections: [
|
28
|
+
{
|
29
|
+
kind: "Scalar",
|
30
|
+
fieldName: "id",
|
31
|
+
alias: null,
|
32
|
+
arguments: null,
|
33
|
+
isUpdatable: false,
|
34
|
+
},
|
35
|
+
],
|
36
|
+
},
|
37
|
+
],
|
38
|
+
},
|
39
|
+
];
|
40
|
+
|
41
|
+
const artifact: EagerReaderArtifact<
|
42
|
+
Query__subquery__param,
|
43
|
+
Query__subquery__output_type
|
44
|
+
> = {
|
45
|
+
kind: "EagerReaderArtifact",
|
46
|
+
fieldName: "Query.subquery",
|
47
|
+
resolver,
|
48
|
+
readerAst,
|
49
|
+
hasUpdatable: false,
|
50
|
+
};
|
51
|
+
|
52
|
+
export default artifact;
|
@@ -1,16 +1,18 @@
|
|
1
|
-
import type {IsographEntrypoint} from '@isograph/react';
|
2
|
-
import { Query__meNameSuccessor__param } from './Query/meNameSuccessor/param_type';
|
3
|
-
import { Query__meName__param } from './Query/meName/param_type';
|
4
|
-
import { Query__nodeField__param } from './Query/nodeField/param_type';
|
1
|
+
import type { IsographEntrypoint } from '@isograph/react';
|
2
|
+
import { type Query__meNameSuccessor__param } from './Query/meNameSuccessor/param_type';
|
3
|
+
import { type Query__meName__param } from './Query/meName/param_type';
|
4
|
+
import { type Query__nodeField__param } from './Query/nodeField/param_type';
|
5
|
+
import { type Query__subquery__param } from './Query/subquery/param_type';
|
5
6
|
import entrypoint_Query__meNameSuccessor from '../__isograph/Query/meNameSuccessor/entrypoint';
|
6
7
|
import entrypoint_Query__meName from '../__isograph/Query/meName/entrypoint';
|
7
8
|
import entrypoint_Query__nodeField from '../__isograph/Query/nodeField/entrypoint';
|
9
|
+
import entrypoint_Query__subquery from '../__isograph/Query/subquery/entrypoint';
|
8
10
|
|
9
11
|
// This is the type given to regular client fields.
|
10
12
|
// This means that the type of the exported iso literal is exactly
|
11
13
|
// the type of the passed-in function, which takes one parameter
|
12
14
|
// of type TParam.
|
13
|
-
type IdentityWithParam<TParam> = <TClientFieldReturn>(
|
15
|
+
type IdentityWithParam<TParam extends object> = <TClientFieldReturn>(
|
14
16
|
clientField: (param: TParam) => TClientFieldReturn
|
15
17
|
) => (param: TParam) => TClientFieldReturn;
|
16
18
|
|
@@ -21,7 +23,10 @@ type IdentityWithParam<TParam> = <TClientFieldReturn>(
|
|
21
23
|
//
|
22
24
|
// TComponentProps becomes the types of the props you must pass
|
23
25
|
// whenever the @component field is rendered.
|
24
|
-
type IdentityWithParamComponent<TParam
|
26
|
+
type IdentityWithParamComponent<TParam extends object> = <
|
27
|
+
TClientFieldReturn,
|
28
|
+
TComponentProps = Record<PropertyKey, never>,
|
29
|
+
>(
|
25
30
|
clientComponentField: (data: TParam, componentProps: TComponentProps) => TClientFieldReturn
|
26
31
|
) => (data: TParam, componentProps: TComponentProps) => TClientFieldReturn;
|
27
32
|
|
@@ -63,6 +68,10 @@ export function iso<T>(
|
|
63
68
|
param: T & MatchesWhitespaceAndString<'field Query.nodeField', T>
|
64
69
|
): IdentityWithParam<Query__nodeField__param>;
|
65
70
|
|
71
|
+
export function iso<T>(
|
72
|
+
param: T & MatchesWhitespaceAndString<'field Query.subquery', T>
|
73
|
+
): IdentityWithParam<Query__subquery__param>;
|
74
|
+
|
66
75
|
export function iso<T>(
|
67
76
|
param: T & MatchesWhitespaceAndString<'entrypoint Query.meNameSuccessor', T>
|
68
77
|
): typeof entrypoint_Query__meNameSuccessor;
|
@@ -75,14 +84,17 @@ export function iso<T>(
|
|
75
84
|
param: T & MatchesWhitespaceAndString<'entrypoint Query.nodeField', T>
|
76
85
|
): typeof entrypoint_Query__nodeField;
|
77
86
|
|
87
|
+
export function iso<T>(
|
88
|
+
param: T & MatchesWhitespaceAndString<'entrypoint Query.subquery', T>
|
89
|
+
): typeof entrypoint_Query__subquery;
|
90
|
+
|
78
91
|
export function iso(_isographLiteralText: string):
|
79
92
|
| IdentityWithParam<any>
|
80
93
|
| IdentityWithParamComponent<any>
|
81
|
-
| IsographEntrypoint<any, any>
|
94
|
+
| IsographEntrypoint<any, any, any>
|
82
95
|
{
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
};
|
96
|
+
throw new Error('iso: Unexpected invocation at runtime. Either the Babel transform ' +
|
97
|
+
'was not set up, or it failed to identify this call site. Make sure it ' +
|
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. ');
|
88
100
|
}
|
@@ -1,41 +1,48 @@
|
|
1
|
-
import { describe,
|
2
|
-
import {
|
3
|
-
ROOT_ID,
|
4
|
-
createIsographEnvironment,
|
5
|
-
} from '../core/IsographEnvironment';
|
1
|
+
import { describe, expect, test } from 'vitest';
|
6
2
|
import {
|
7
3
|
garbageCollectEnvironment,
|
8
4
|
retainQuery,
|
9
5
|
} from '../core/garbageCollection';
|
6
|
+
import {
|
7
|
+
createIsographEnvironment,
|
8
|
+
ROOT_ID,
|
9
|
+
type IsographStore,
|
10
|
+
} from '../core/IsographEnvironment';
|
10
11
|
import { iso } from './__isograph/iso';
|
12
|
+
import { meNameSuccessorRetainedQuery } from './meNameSuccessor';
|
11
13
|
import { nodeFieldRetainedQuery } from './nodeQuery';
|
12
14
|
|
13
|
-
const getDefaultStore = () => ({
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
const getDefaultStore = (): IsographStore => ({
|
16
|
+
Query: {
|
17
|
+
[ROOT_ID]: {
|
18
|
+
me: { __link: '0', __typename: 'Economist' },
|
19
|
+
you: { __link: '1', __typename: 'Economist' },
|
20
|
+
node____id___0: {
|
21
|
+
__link: '0',
|
22
|
+
__typename: 'Economist',
|
23
|
+
},
|
19
24
|
},
|
20
25
|
},
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
26
|
+
Economist: {
|
27
|
+
0: {
|
28
|
+
__typename: 'Economist',
|
29
|
+
id: '0',
|
30
|
+
name: 'Jeremy Bentham',
|
31
|
+
successor: { __link: '1', __typename: 'Economist' },
|
32
|
+
},
|
33
|
+
1: {
|
34
|
+
__typename: 'Economist',
|
35
|
+
id: '1',
|
36
|
+
name: 'John Stuart Mill',
|
37
|
+
predecessor: { __link: '0', __typename: 'Economist' },
|
38
|
+
successor: { __link: '2', __typename: 'Economist' },
|
39
|
+
},
|
40
|
+
2: {
|
41
|
+
__typename: 'Economist',
|
42
|
+
id: '2',
|
43
|
+
name: 'Henry Sidgwick',
|
44
|
+
predecessor: { __link: '1', __typename: 'Economist' },
|
45
|
+
},
|
39
46
|
},
|
40
47
|
});
|
41
48
|
|
@@ -46,12 +53,13 @@ export const meNameField = iso(`
|
|
46
53
|
}
|
47
54
|
}
|
48
55
|
`)(() => {});
|
49
|
-
|
50
|
-
|
51
|
-
iso(`entrypoint Query.meName`);
|
56
|
+
|
57
|
+
const meNameEntrypoint = iso(`entrypoint Query.meName`);
|
52
58
|
const meNameRetainedQuery = {
|
53
|
-
normalizationAst:
|
59
|
+
normalizationAst:
|
60
|
+
meNameEntrypoint.networkRequestInfo.normalizationAst.selections,
|
54
61
|
variables: {},
|
62
|
+
root: { __link: ROOT_ID, __typename: 'Query' },
|
55
63
|
};
|
56
64
|
|
57
65
|
describe('garbage collection', () => {
|
@@ -63,13 +71,13 @@ describe('garbage collection', () => {
|
|
63
71
|
null as any,
|
64
72
|
);
|
65
73
|
|
66
|
-
expect(store[1]).not.toBe(undefined);
|
74
|
+
expect(store.Economist?.[1]).not.toBe(undefined);
|
67
75
|
|
68
76
|
// TODO enable babel so we don't have to do this
|
69
77
|
retainQuery(environment, meNameRetainedQuery);
|
70
78
|
garbageCollectEnvironment(environment);
|
71
79
|
|
72
|
-
expect(store[1]).toBe(undefined);
|
80
|
+
expect(store.Economist?.[1]).toBe(undefined);
|
73
81
|
});
|
74
82
|
|
75
83
|
test('Referenced records should not be garbage collected', () => {
|
@@ -80,13 +88,13 @@ describe('garbage collection', () => {
|
|
80
88
|
null as any,
|
81
89
|
);
|
82
90
|
|
83
|
-
expect(store[0]).not.toBe(undefined);
|
91
|
+
expect(store.Economist?.[0]).not.toBe(undefined);
|
84
92
|
|
85
93
|
// TODO enable babel so we don't have to do this
|
86
94
|
retainQuery(environment, meNameRetainedQuery);
|
87
95
|
garbageCollectEnvironment(environment);
|
88
96
|
|
89
|
-
expect(store[0]).not.toBe(undefined);
|
97
|
+
expect(store.Economist?.[0]).not.toBe(undefined);
|
90
98
|
});
|
91
99
|
|
92
100
|
test('Referenced records should not be garbage collected, and this should work with variables', () => {
|
@@ -97,12 +105,12 @@ describe('garbage collection', () => {
|
|
97
105
|
null as any,
|
98
106
|
);
|
99
107
|
|
100
|
-
expect(store[0]).not.toBe(undefined);
|
108
|
+
expect(store.Economist?.[0]).not.toBe(undefined);
|
101
109
|
|
102
110
|
retainQuery(environment, nodeFieldRetainedQuery);
|
103
111
|
garbageCollectEnvironment(environment);
|
104
112
|
|
105
|
-
expect(store[0]).not.toBe(undefined);
|
113
|
+
expect(store.Economist?.[0]).not.toBe(undefined);
|
106
114
|
});
|
107
115
|
|
108
116
|
test('Referenced records should not be garbage collected, and this should work through multiple levels', () => {
|
@@ -116,12 +124,12 @@ describe('garbage collection', () => {
|
|
116
124
|
retainQuery(environment, meNameSuccessorRetainedQuery);
|
117
125
|
garbageCollectEnvironment(environment);
|
118
126
|
|
119
|
-
expect(store[0]).not.toBe(undefined);
|
120
|
-
expect(store[1]).not.toBe(undefined);
|
121
|
-
expect(store[2]).not.toBe(undefined);
|
127
|
+
expect(store.Economist?.[0]).not.toBe(undefined);
|
128
|
+
expect(store.Economist?.[1]).not.toBe(undefined);
|
129
|
+
expect(store.Economist?.[2]).not.toBe(undefined);
|
122
130
|
});
|
123
131
|
|
124
|
-
test('ROOT_ID should
|
132
|
+
test('ROOT_ID should be garbage collected, if there are no retained queries', () => {
|
125
133
|
const store = getDefaultStore();
|
126
134
|
const environment = createIsographEnvironment(
|
127
135
|
store,
|
@@ -130,7 +138,7 @@ describe('garbage collection', () => {
|
|
130
138
|
);
|
131
139
|
garbageCollectEnvironment(environment);
|
132
140
|
|
133
|
-
expect(store[ROOT_ID]).
|
134
|
-
expect(store[0]).toBe(undefined);
|
141
|
+
expect(store.Query?.[ROOT_ID]).toBe(undefined);
|
142
|
+
expect(store.Economist?.[0]).toBe(undefined);
|
135
143
|
});
|
136
144
|
});
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { ROOT_ID } from '../core/IsographEnvironment';
|
1
2
|
import { iso } from './__isograph/iso';
|
2
3
|
|
3
4
|
export const meNameField = iso(`
|
@@ -12,9 +13,13 @@ export const meNameField = iso(`
|
|
12
13
|
}
|
13
14
|
}
|
14
15
|
`)(() => {});
|
15
|
-
|
16
|
-
iso(`entrypoint Query.meNameSuccessor`);
|
16
|
+
const meNameSuccessorEntrypoint = iso(`entrypoint Query.meNameSuccessor`);
|
17
17
|
export const meNameSuccessorRetainedQuery = {
|
18
|
-
normalizationAst:
|
18
|
+
normalizationAst:
|
19
|
+
meNameSuccessorEntrypoint.networkRequestInfo.normalizationAst.selections,
|
19
20
|
variables: {},
|
21
|
+
root: {
|
22
|
+
__link: ROOT_ID,
|
23
|
+
__typename: 'Query',
|
24
|
+
},
|
20
25
|
};
|
package/src/tests/nodeQuery.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import { RetainedQuery } from '../core/garbageCollection';
|
2
|
+
import { ROOT_ID } from '../core/IsographEnvironment';
|
1
3
|
import { iso } from './__isograph/iso';
|
2
4
|
|
3
5
|
// TODO investigate why this can't be in garbageCollection.test.ts without
|
@@ -9,9 +11,10 @@ export const nodeField = iso(`
|
|
9
11
|
}
|
10
12
|
}
|
11
13
|
`)(() => {});
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
const nodeFieldEntrypoint = iso(`entrypoint Query.nodeField`);
|
15
|
+
export const nodeFieldRetainedQuery: RetainedQuery = {
|
16
|
+
normalizationAst:
|
17
|
+
nodeFieldEntrypoint.networkRequestInfo.normalizationAst.selections,
|
16
18
|
variables: { id: 0 },
|
19
|
+
root: { __link: ROOT_ID, __typename: 'Query' },
|
17
20
|
};
|