@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.
Files changed (128) hide show
  1. package/.turbo/turbo-compile-typescript.log +4 -0
  2. package/dist/core/FragmentReference.d.ts +16 -7
  3. package/dist/core/FragmentReference.d.ts.map +1 -1
  4. package/dist/core/FragmentReference.js +3 -12
  5. package/dist/core/IsographEnvironment.d.ts +17 -27
  6. package/dist/core/IsographEnvironment.d.ts.map +1 -1
  7. package/dist/core/IsographEnvironment.js +4 -0
  8. package/dist/core/PromiseWrapper.d.ts +3 -4
  9. package/dist/core/PromiseWrapper.d.ts.map +1 -1
  10. package/dist/core/PromiseWrapper.js +5 -4
  11. package/dist/core/areEqualWithDeepComparison.d.ts.map +1 -1
  12. package/dist/core/areEqualWithDeepComparison.js +16 -0
  13. package/dist/core/cache.d.ts +11 -20
  14. package/dist/core/cache.d.ts.map +1 -1
  15. package/dist/core/cache.js +60 -45
  16. package/dist/core/check.d.ts +9 -5
  17. package/dist/core/check.d.ts.map +1 -1
  18. package/dist/core/check.js +2 -2
  19. package/dist/core/componentCache.d.ts +1 -1
  20. package/dist/core/componentCache.d.ts.map +1 -1
  21. package/dist/core/componentCache.js +27 -31
  22. package/dist/core/entrypoint.d.ts +23 -26
  23. package/dist/core/entrypoint.d.ts.map +1 -1
  24. package/dist/core/garbageCollection.d.ts +3 -4
  25. package/dist/core/garbageCollection.d.ts.map +1 -1
  26. package/dist/core/garbageCollection.js +1 -1
  27. package/dist/core/logging.d.ts +12 -13
  28. package/dist/core/logging.d.ts.map +1 -1
  29. package/dist/core/logging.js +8 -5
  30. package/dist/core/makeNetworkRequest.d.ts +5 -5
  31. package/dist/core/makeNetworkRequest.d.ts.map +1 -1
  32. package/dist/core/makeNetworkRequest.js +107 -22
  33. package/dist/core/read.d.ts +15 -10
  34. package/dist/core/read.d.ts.map +1 -1
  35. package/dist/core/read.js +398 -304
  36. package/dist/core/reader.d.ts +24 -32
  37. package/dist/core/reader.d.ts.map +1 -1
  38. package/dist/core/startUpdate.d.ts +5 -0
  39. package/dist/core/startUpdate.d.ts.map +1 -0
  40. package/dist/core/startUpdate.js +15 -0
  41. package/dist/core/util.d.ts +3 -0
  42. package/dist/core/util.d.ts.map +1 -1
  43. package/dist/index.d.ts +16 -16
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +2 -1
  46. package/dist/loadable-hooks/useClientSideDefer.d.ts +4 -10
  47. package/dist/loadable-hooks/useClientSideDefer.d.ts.map +1 -1
  48. package/dist/loadable-hooks/useClientSideDefer.js +2 -2
  49. package/dist/loadable-hooks/useConnectionSpecPagination.d.ts +8 -15
  50. package/dist/loadable-hooks/useConnectionSpecPagination.d.ts.map +1 -1
  51. package/dist/loadable-hooks/useConnectionSpecPagination.js +6 -4
  52. package/dist/loadable-hooks/useImperativeExposedMutationField.d.ts +1 -2
  53. package/dist/loadable-hooks/useImperativeExposedMutationField.d.ts.map +1 -1
  54. package/dist/loadable-hooks/useImperativeLoadableField.d.ts +4 -6
  55. package/dist/loadable-hooks/useImperativeLoadableField.d.ts.map +1 -1
  56. package/dist/loadable-hooks/useImperativeLoadableField.js +1 -1
  57. package/dist/loadable-hooks/useSkipLimitPagination.d.ts +6 -13
  58. package/dist/loadable-hooks/useSkipLimitPagination.d.ts.map +1 -1
  59. package/dist/loadable-hooks/useSkipLimitPagination.js +11 -9
  60. package/dist/react/FragmentReader.d.ts +2 -3
  61. package/dist/react/FragmentReader.d.ts.map +1 -1
  62. package/dist/react/IsographEnvironmentProvider.d.ts.map +1 -1
  63. package/dist/react/useImperativeReference.d.ts +7 -10
  64. package/dist/react/useImperativeReference.d.ts.map +1 -1
  65. package/dist/react/useImperativeReference.js +2 -3
  66. package/dist/react/useLazyReference.d.ts +4 -7
  67. package/dist/react/useLazyReference.d.ts.map +1 -1
  68. package/dist/react/useLazyReference.js +26 -5
  69. package/dist/react/useReadAndSubscribe.d.ts +3 -9
  70. package/dist/react/useReadAndSubscribe.d.ts.map +1 -1
  71. package/dist/react/useReadAndSubscribe.js +7 -3
  72. package/dist/react/useRerenderOnChange.d.ts +1 -1
  73. package/dist/react/useRerenderOnChange.d.ts.map +1 -1
  74. package/dist/react/useResult.d.ts +3 -6
  75. package/dist/react/useResult.d.ts.map +1 -1
  76. package/dist/react/useResult.js +10 -8
  77. package/isograph.config.json +1 -0
  78. package/package.json +7 -6
  79. package/src/core/FragmentReference.ts +30 -15
  80. package/src/core/IsographEnvironment.ts +39 -31
  81. package/src/core/PromiseWrapper.ts +3 -3
  82. package/src/core/areEqualWithDeepComparison.ts +20 -0
  83. package/src/core/cache.ts +105 -72
  84. package/src/core/check.ts +13 -8
  85. package/src/core/componentCache.ts +45 -52
  86. package/src/core/entrypoint.ts +34 -16
  87. package/src/core/garbageCollection.ts +6 -6
  88. package/src/core/logging.ts +24 -22
  89. package/src/core/makeNetworkRequest.ts +183 -30
  90. package/src/core/read.ts +618 -435
  91. package/src/core/reader.ts +37 -24
  92. package/src/core/startUpdate.ts +28 -0
  93. package/src/core/util.ts +4 -0
  94. package/src/index.ts +82 -9
  95. package/src/loadable-hooks/useClientSideDefer.ts +11 -10
  96. package/src/loadable-hooks/useConnectionSpecPagination.ts +26 -13
  97. package/src/loadable-hooks/useImperativeExposedMutationField.ts +1 -1
  98. package/src/loadable-hooks/useImperativeLoadableField.ts +10 -12
  99. package/src/loadable-hooks/useSkipLimitPagination.ts +37 -19
  100. package/src/react/FragmentReader.tsx +3 -3
  101. package/src/react/IsographEnvironmentProvider.tsx +1 -1
  102. package/src/react/useImperativeReference.ts +40 -19
  103. package/src/react/useLazyReference.ts +62 -14
  104. package/src/react/useReadAndSubscribe.ts +17 -9
  105. package/src/react/useRerenderOnChange.ts +2 -2
  106. package/src/react/useResult.ts +21 -8
  107. package/src/tests/__isograph/Query/meName/entrypoint.ts +4 -28
  108. package/src/tests/__isograph/Query/meName/normalization_ast.ts +25 -0
  109. package/src/tests/__isograph/Query/meName/query_text.ts +6 -0
  110. package/src/tests/__isograph/Query/meName/resolver_reader.ts +4 -0
  111. package/src/tests/__isograph/Query/meNameSuccessor/entrypoint.ts +4 -66
  112. package/src/tests/__isograph/Query/meNameSuccessor/normalization_ast.ts +56 -0
  113. package/src/tests/__isograph/Query/meNameSuccessor/query_text.ts +13 -0
  114. package/src/tests/__isograph/Query/meNameSuccessor/resolver_reader.ts +7 -0
  115. package/src/tests/__isograph/Query/nodeField/entrypoint.ts +4 -33
  116. package/src/tests/__isograph/Query/nodeField/normalization_ast.ts +30 -0
  117. package/src/tests/__isograph/Query/nodeField/query_text.ts +6 -0
  118. package/src/tests/__isograph/Query/nodeField/resolver_reader.ts +4 -0
  119. package/src/tests/__isograph/Query/subquery/entrypoint.ts +4 -43
  120. package/src/tests/__isograph/Query/subquery/normalization_ast.ts +38 -0
  121. package/src/tests/__isograph/Query/subquery/query_text.ts +8 -0
  122. package/src/tests/__isograph/Query/subquery/resolver_reader.ts +5 -0
  123. package/src/tests/__isograph/iso.ts +3 -2
  124. package/src/tests/garbageCollection.test.ts +10 -8
  125. package/src/tests/meNameSuccessor.ts +1 -1
  126. package/src/tests/nodeQuery.ts +2 -1
  127. package/src/tests/normalizeData.test.ts +1 -1
  128. 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;
@@ -0,0 +1,6 @@
1
+ export default 'query nodeField ($id: ID!) {\
2
+ node____id___v_id: node(id: $id) {\
3
+ __typename,\
4
+ id,\
5
+ },\
6
+ }';
@@ -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;
@@ -0,0 +1,8 @@
1
+ export default 'query subquery ($id: ID!) {\
2
+ query {\
3
+ node____id___v_id: node(id: $id) {\
4
+ __typename,\
5
+ id,\
6
+ },\
7
+ },\
8
+ }';
@@ -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, test, expect } from 'vitest';
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
- import { meNameSuccessorRetainedQuery } from './meNameSuccessor';
56
+
56
57
  const meNameEntrypoint = iso(`entrypoint Query.meName`);
57
58
  const meNameRetainedQuery = {
58
- normalizationAst: meNameEntrypoint.networkRequestInfo.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,
@@ -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: nodeFieldEntrypoint.networkRequestInfo.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
  },
package/tsconfig.pkg.json CHANGED
@@ -4,8 +4,7 @@
4
4
  "outDir": "./dist/",
5
5
  "rootDir": "./src/",
6
6
  "declaration": true,
7
- "jsx": "react",
8
- "lib": ["es2017", "DOM"]
7
+ "jsx": "react"
9
8
  },
10
9
  "include": ["./**/*.ts", "./**/*.tsx"],
11
10
  "exclude": [