@isograph/react 0.2.0 → 0.3.0

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 (134) hide show
  1. package/dist/core/FragmentReference.d.ts +14 -4
  2. package/dist/core/FragmentReference.d.ts.map +1 -0
  3. package/dist/core/FragmentReference.js +2 -3
  4. package/dist/core/IsographEnvironment.d.ts +28 -10
  5. package/dist/core/IsographEnvironment.d.ts.map +1 -0
  6. package/dist/core/IsographEnvironment.js +15 -22
  7. package/dist/core/PromiseWrapper.d.ts +1 -0
  8. package/dist/core/PromiseWrapper.d.ts.map +1 -0
  9. package/dist/core/PromiseWrapper.js +4 -5
  10. package/dist/core/areEqualWithDeepComparison.d.ts +5 -3
  11. package/dist/core/areEqualWithDeepComparison.d.ts.map +1 -0
  12. package/dist/core/areEqualWithDeepComparison.js +73 -39
  13. package/dist/core/cache.d.ts +26 -10
  14. package/dist/core/cache.d.ts.map +1 -0
  15. package/dist/core/cache.js +160 -98
  16. package/dist/core/check.d.ts +18 -0
  17. package/dist/core/check.d.ts.map +1 -0
  18. package/dist/core/check.js +127 -0
  19. package/dist/core/componentCache.d.ts +1 -1
  20. package/dist/core/componentCache.d.ts.map +1 -0
  21. package/dist/core/componentCache.js +14 -14
  22. package/dist/core/entrypoint.d.ts +27 -8
  23. package/dist/core/entrypoint.d.ts.map +1 -0
  24. package/dist/core/entrypoint.js +1 -2
  25. package/dist/core/garbageCollection.d.ts +3 -1
  26. package/dist/core/garbageCollection.d.ts.map +1 -0
  27. package/dist/core/garbageCollection.js +48 -15
  28. package/dist/core/logging.d.ts +69 -0
  29. package/dist/core/logging.d.ts.map +1 -0
  30. package/dist/core/logging.js +19 -0
  31. package/dist/core/makeNetworkRequest.d.ts +4 -1
  32. package/dist/core/makeNetworkRequest.d.ts.map +1 -0
  33. package/dist/core/makeNetworkRequest.js +71 -15
  34. package/dist/core/read.d.ts +20 -5
  35. package/dist/core/read.d.ts.map +1 -0
  36. package/dist/core/read.js +104 -41
  37. package/dist/core/reader.d.ts +34 -10
  38. package/dist/core/reader.d.ts.map +1 -0
  39. package/dist/core/util.d.ts +2 -0
  40. package/dist/core/util.d.ts.map +1 -0
  41. package/dist/index.d.ts +10 -5
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +10 -2
  44. package/dist/loadable-hooks/useClientSideDefer.d.ts +15 -3
  45. package/dist/loadable-hooks/useClientSideDefer.d.ts.map +1 -0
  46. package/dist/loadable-hooks/useClientSideDefer.js +4 -6
  47. package/dist/loadable-hooks/useConnectionSpecPagination.d.ts +34 -0
  48. package/dist/loadable-hooks/useConnectionSpecPagination.d.ts.map +1 -0
  49. package/dist/loadable-hooks/useConnectionSpecPagination.js +160 -0
  50. package/dist/loadable-hooks/useImperativeExposedMutationField.d.ts +1 -0
  51. package/dist/loadable-hooks/useImperativeExposedMutationField.d.ts.map +1 -0
  52. package/dist/loadable-hooks/useImperativeExposedMutationField.js +1 -2
  53. package/dist/loadable-hooks/useImperativeLoadableField.d.ts +13 -5
  54. package/dist/loadable-hooks/useImperativeLoadableField.d.ts.map +1 -0
  55. package/dist/loadable-hooks/useImperativeLoadableField.js +3 -4
  56. package/dist/loadable-hooks/useSkipLimitPagination.d.ts +18 -24
  57. package/dist/loadable-hooks/useSkipLimitPagination.d.ts.map +1 -0
  58. package/dist/loadable-hooks/useSkipLimitPagination.js +88 -44
  59. package/dist/react/FragmentReader.d.ts +7 -4
  60. package/dist/react/FragmentReader.d.ts.map +1 -0
  61. package/dist/react/FragmentReader.js +4 -2
  62. package/dist/react/IsographEnvironmentProvider.d.ts +1 -0
  63. package/dist/react/IsographEnvironmentProvider.d.ts.map +1 -0
  64. package/dist/react/IsographEnvironmentProvider.js +3 -3
  65. package/dist/react/RenderAfterCommit__DO_NOT_USE.d.ts +10 -0
  66. package/dist/react/RenderAfterCommit__DO_NOT_USE.d.ts.map +1 -0
  67. package/dist/react/RenderAfterCommit__DO_NOT_USE.js +15 -0
  68. package/dist/react/useImperativeReference.d.ts +8 -3
  69. package/dist/react/useImperativeReference.d.ts.map +1 -0
  70. package/dist/react/useImperativeReference.js +4 -5
  71. package/dist/react/useLazyReference.d.ts +7 -2
  72. package/dist/react/useLazyReference.d.ts.map +1 -0
  73. package/dist/react/useLazyReference.js +11 -4
  74. package/dist/react/useReadAndSubscribe.d.ts +12 -3
  75. package/dist/react/useReadAndSubscribe.d.ts.map +1 -0
  76. package/dist/react/useReadAndSubscribe.js +6 -7
  77. package/dist/react/useRerenderOnChange.d.ts +6 -1
  78. package/dist/react/useRerenderOnChange.d.ts.map +1 -0
  79. package/dist/react/useRerenderOnChange.js +3 -4
  80. package/dist/react/useResult.d.ts +5 -1
  81. package/dist/react/useResult.d.ts.map +1 -0
  82. package/dist/react/useResult.js +8 -5
  83. package/{src/tests/isograph.config.json → isograph.config.json} +1 -1
  84. package/package.json +12 -8
  85. package/{src/tests/schema.graphql → schema.graphql} +1 -0
  86. package/src/core/FragmentReference.ts +17 -5
  87. package/src/core/IsographEnvironment.ts +38 -29
  88. package/src/core/areEqualWithDeepComparison.ts +76 -42
  89. package/src/core/cache.ts +237 -123
  90. package/src/core/check.ts +207 -0
  91. package/src/core/componentCache.ts +18 -17
  92. package/src/core/entrypoint.ts +15 -8
  93. package/src/core/garbageCollection.ts +71 -20
  94. package/src/core/logging.ts +116 -0
  95. package/src/core/makeNetworkRequest.ts +89 -13
  96. package/src/core/read.ts +162 -55
  97. package/src/core/reader.ts +40 -13
  98. package/src/core/util.ts +4 -0
  99. package/src/index.ts +14 -1
  100. package/src/loadable-hooks/useClientSideDefer.ts +45 -15
  101. package/src/loadable-hooks/useConnectionSpecPagination.ts +331 -0
  102. package/src/loadable-hooks/useImperativeLoadableField.ts +36 -10
  103. package/src/loadable-hooks/useSkipLimitPagination.ts +231 -90
  104. package/src/react/FragmentReader.tsx +13 -4
  105. package/src/react/RenderAfterCommit__DO_NOT_USE.tsx +17 -0
  106. package/src/react/useImperativeReference.ts +18 -7
  107. package/src/react/useLazyReference.ts +24 -4
  108. package/src/react/useReadAndSubscribe.ts +20 -5
  109. package/src/react/useRerenderOnChange.ts +6 -1
  110. package/src/react/useResult.ts +10 -2
  111. package/src/tests/__isograph/Query/meName/entrypoint.ts +7 -2
  112. package/src/tests/__isograph/Query/meName/param_type.ts +5 -2
  113. package/src/tests/__isograph/Query/meName/resolver_reader.ts +1 -0
  114. package/src/tests/__isograph/Query/meNameSuccessor/entrypoint.ts +9 -2
  115. package/src/tests/__isograph/Query/meNameSuccessor/param_type.ts +9 -6
  116. package/src/tests/__isograph/Query/meNameSuccessor/resolver_reader.ts +3 -0
  117. package/src/tests/__isograph/Query/nodeField/entrypoint.ts +13 -2
  118. package/src/tests/__isograph/Query/nodeField/param_type.ts +7 -3
  119. package/src/tests/__isograph/Query/nodeField/parameters_type.ts +3 -0
  120. package/src/tests/__isograph/Query/nodeField/resolver_reader.ts +1 -0
  121. package/src/tests/__isograph/Query/subquery/entrypoint.ts +67 -0
  122. package/src/tests/__isograph/Query/subquery/output_type.ts +3 -0
  123. package/src/tests/__isograph/Query/subquery/param_type.ts +12 -0
  124. package/src/tests/__isograph/Query/subquery/parameters_type.ts +3 -0
  125. package/src/tests/__isograph/Query/subquery/resolver_reader.ts +47 -0
  126. package/src/tests/__isograph/iso.ts +22 -11
  127. package/src/tests/garbageCollection.test.ts +45 -39
  128. package/src/tests/meNameSuccessor.ts +8 -3
  129. package/src/tests/nodeQuery.ts +6 -4
  130. package/src/tests/normalizeData.test.ts +120 -0
  131. package/src/tests/tsconfig.json +3 -3
  132. package/tsconfig.json +2 -2
  133. package/tsconfig.pkg.json +6 -1
  134. package/vitest.config.ts +20 -0
@@ -1,38 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrCreateCachedComponent = void 0;
3
+ exports.getOrCreateCachedComponent = getOrCreateCachedComponent;
4
4
  const cache_1 = require("./cache");
5
5
  const useReadAndSubscribe_1 = require("../react/useReadAndSubscribe");
6
6
  const PromiseWrapper_1 = require("./PromiseWrapper");
7
+ const logging_1 = require("./logging");
7
8
  function getOrCreateCachedComponent(environment, componentName, fragmentReference, networkRequestOptions) {
8
9
  var _a, _b, _c;
9
10
  // cachedComponentsById is a three layer cache: id, then component name, then
10
11
  // stringified args. These three, together, uniquely identify a read at a given
11
12
  // time.
12
13
  const cachedComponentsById = environment.componentCache;
13
- cachedComponentsById[fragmentReference.root] =
14
- (_a = cachedComponentsById[fragmentReference.root]) !== null && _a !== void 0 ? _a : {};
15
- const componentsByName = cachedComponentsById[fragmentReference.root];
14
+ const recordLink = fragmentReference.root.__link;
15
+ const componentsByName = ((_a = cachedComponentsById[recordLink]) !== null && _a !== void 0 ? _a : (cachedComponentsById[recordLink] = {}));
16
16
  componentsByName[componentName] = (_b = componentsByName[componentName]) !== null && _b !== void 0 ? _b : {};
17
17
  const byArgs = componentsByName[componentName];
18
18
  const stringifiedArgs = JSON.stringify((0, cache_1.stableCopy)(fragmentReference.variables));
19
19
  byArgs[stringifiedArgs] =
20
20
  (_c = byArgs[stringifiedArgs]) !== null && _c !== void 0 ? _c : (() => {
21
21
  function Component(additionalRuntimeProps) {
22
- const data = (0, useReadAndSubscribe_1.useReadAndSubscribe)(fragmentReference, networkRequestOptions);
23
- // @ts-expect-error
24
- if (typeof window !== 'undefined' && window.__LOG) {
25
- console.log('Component re-rendered: ' +
26
- componentName +
27
- ' ' +
28
- fragmentReference.root);
29
- }
30
22
  const readerWithRefetchQueries = (0, PromiseWrapper_1.readPromise)(fragmentReference.readerWithRefetchQueries);
31
- return readerWithRefetchQueries.readerArtifact.resolver(data, additionalRuntimeProps);
23
+ const data = (0, useReadAndSubscribe_1.useReadAndSubscribe)(fragmentReference, networkRequestOptions, readerWithRefetchQueries.readerArtifact.readerAst);
24
+ (0, logging_1.logMessage)(environment, {
25
+ kind: 'ComponentRerendered',
26
+ componentName,
27
+ rootLink: fragmentReference.root,
28
+ });
29
+ return readerWithRefetchQueries.readerArtifact.resolver({
30
+ data,
31
+ parameters: fragmentReference.variables,
32
+ }, additionalRuntimeProps);
32
33
  }
33
34
  Component.displayName = `${componentName} (id: ${fragmentReference.root}) @component`;
34
35
  return Component;
35
36
  })();
36
37
  return byArgs[stringifiedArgs];
37
38
  }
38
- exports.getOrCreateCachedComponent = getOrCreateCachedComponent;
@@ -1,18 +1,32 @@
1
- /// <reference types="react" />
1
+ import type { TypeName } from './IsographEnvironment';
2
2
  import { TopLevelReaderArtifact } from './reader';
3
3
  import { Arguments } from './util';
4
- export type ReaderWithRefetchQueries<TReadFromStore extends Object, TClientFieldValue> = {
4
+ export type ReaderWithRefetchQueries<TReadFromStore extends {
5
+ parameters: object;
6
+ data: object;
7
+ }, TClientFieldValue> = {
5
8
  readonly kind: 'ReaderWithRefetchQueries';
6
9
  readonly readerArtifact: TopLevelReaderArtifact<TReadFromStore, TClientFieldValue, any>;
7
10
  readonly nestedRefetchQueries: RefetchQueryNormalizationArtifactWrapper[];
8
11
  };
9
- export type IsographEntrypoint<TReadFromStore extends Object, TClientFieldValue> = {
10
- readonly kind: 'Entrypoint';
12
+ export type NetworkRequestInfo = {
13
+ readonly kind: 'NetworkRequestInfo';
11
14
  readonly queryText: string;
12
15
  readonly normalizationAst: NormalizationAst;
16
+ };
17
+ export type IsographEntrypoint<TReadFromStore extends {
18
+ parameters: object;
19
+ data: object;
20
+ }, TClientFieldValue> = {
21
+ readonly kind: 'Entrypoint';
22
+ readonly networkRequestInfo: NetworkRequestInfo;
13
23
  readonly readerWithRefetchQueries: ReaderWithRefetchQueries<TReadFromStore, TClientFieldValue>;
24
+ readonly concreteType: TypeName;
14
25
  };
15
- export type IsographEntrypointLoader<TReadFromStore extends Object, TClientFieldValue> = {
26
+ export type IsographEntrypointLoader<TReadFromStore extends {
27
+ parameters: object;
28
+ data: object;
29
+ }, TClientFieldValue> = {
16
30
  readonly kind: 'EntrypointLoader';
17
31
  readonly typeAndField: string;
18
32
  readonly loader: () => Promise<IsographEntrypoint<TReadFromStore, TClientFieldValue>>;
@@ -29,6 +43,7 @@ export type NormalizationLinkedField = {
29
43
  readonly fieldName: string;
30
44
  readonly arguments: Arguments | null;
31
45
  readonly selections: NormalizationAst;
46
+ readonly concreteType: TypeName | null;
32
47
  };
33
48
  export type NormalizationInlineFragment = {
34
49
  readonly kind: 'InlineFragment';
@@ -37,14 +52,18 @@ export type NormalizationInlineFragment = {
37
52
  };
38
53
  export type RefetchQueryNormalizationArtifact = {
39
54
  readonly kind: 'RefetchQuery';
40
- readonly queryText: string;
41
- readonly normalizationAst: NormalizationAst;
55
+ readonly networkRequestInfo: NetworkRequestInfo;
56
+ readonly concreteType: TypeName;
42
57
  };
43
58
  export type RefetchQueryNormalizationArtifactWrapper = {
44
59
  readonly artifact: RefetchQueryNormalizationArtifact;
45
60
  readonly allowedVariables: string[];
46
61
  };
47
- export declare function assertIsEntrypoint<TReadFromStore extends Object, TClientFieldValue>(value: IsographEntrypoint<TReadFromStore, TClientFieldValue> | ((_: any) => any) | any): asserts value is IsographEntrypoint<TReadFromStore, TClientFieldValue>;
62
+ export declare function assertIsEntrypoint<TReadFromStore extends {
63
+ parameters: object;
64
+ data: object;
65
+ }, TClientFieldValue>(value: IsographEntrypoint<TReadFromStore, TClientFieldValue> | ((_: any) => any) | any): asserts value is IsographEntrypoint<TReadFromStore, TClientFieldValue>;
48
66
  export type ExtractReadFromStore<Type> = Type extends IsographEntrypoint<infer X, any> ? X : never;
49
67
  export type ExtractResolverResult<Type> = Type extends IsographEntrypoint<any, infer X> ? X : never;
50
68
  export type ExtractProps<Type> = Type extends React.FC<infer X> ? X : never;
69
+ //# sourceMappingURL=entrypoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../../src/core/entrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACl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,IAAI,EAAE,MAAM,CAAA;CAAE,EAC3D,iBAAiB,EAEjB,KAAK,EACD,kBAAkB,CAAC,cAAc,EAAE,iBAAiB,CAAC,GACrD,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC,GAGjB,GAAG,GACN,OAAO,CAAC,KAAK,IAAI,kBAAkB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAExE;AAED,MAAM,MAAM,oBAAoB,CAAC,IAAI,IACnC,IAAI,SAAS,kBAAkB,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC5D,MAAM,MAAM,qBAAqB,CAAC,IAAI,IACpC,IAAI,SAAS,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC5D,MAAM,MAAM,YAAY,CAAC,IAAI,IAAI,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertIsEntrypoint = void 0;
3
+ exports.assertIsEntrypoint = assertIsEntrypoint;
4
4
  function assertIsEntrypoint(value) {
5
5
  if (typeof value === 'function')
6
6
  throw new Error('Not a string');
7
7
  }
8
- exports.assertIsEntrypoint = assertIsEntrypoint;
@@ -1,11 +1,13 @@
1
- import { IsographEnvironment } from './IsographEnvironment';
1
+ import { IsographEnvironment, type Link } from './IsographEnvironment';
2
2
  import { NormalizationAst } from './entrypoint';
3
3
  export type RetainedQuery = {
4
4
  readonly normalizationAst: NormalizationAst;
5
5
  readonly variables: {};
6
+ readonly root: Link;
6
7
  };
7
8
  type DidUnretainSomeQuery = boolean;
8
9
  export declare function unretainQuery(environment: IsographEnvironment, retainedQuery: RetainedQuery): DidUnretainSomeQuery;
9
10
  export declare function retainQuery(environment: IsographEnvironment, queryToRetain: RetainedQuery): void;
10
11
  export declare function garbageCollectEnvironment(environment: IsographEnvironment): void;
11
12
  export {};
13
+ //# sourceMappingURL=garbageCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"garbageCollection.d.ts","sourceRoot":"","sources":["../../src/core/garbageCollection.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,mBAAmB,EAInB,KAAK,IAAI,EAEV,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB,CAAC;AAEF,KAAK,oBAAoB,GAAG,OAAO,CAAC;AACpC,wBAAgB,aAAa,CAC3B,WAAW,EAAE,mBAAmB,EAChC,aAAa,EAAE,aAAa,GAC3B,oBAAoB,CAUtB;AAED,wBAAgB,WAAW,CACzB,WAAW,EAAE,mBAAmB,EAChC,aAAa,EAAE,aAAa,QAM7B;AAED,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,mBAAmB,QA+BzE"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.garbageCollectEnvironment = exports.retainQuery = exports.unretainQuery = void 0;
3
+ exports.unretainQuery = unretainQuery;
4
+ exports.retainQuery = retainQuery;
5
+ exports.garbageCollectEnvironment = garbageCollectEnvironment;
4
6
  const IsographEnvironment_1 = require("./IsographEnvironment");
5
7
  const cache_1 = require("./cache");
6
8
  function unretainQuery(environment, retainedQuery) {
@@ -12,57 +14,88 @@ function unretainQuery(environment, retainedQuery) {
12
14
  }
13
15
  return false;
14
16
  }
15
- exports.unretainQuery = unretainQuery;
16
17
  function retainQuery(environment, queryToRetain) {
17
18
  environment.retainedQueries.add(queryToRetain);
18
19
  // TODO can we remove this query from the buffer somehow?
19
20
  // We are relying on === equality, but we really should be comparing
20
21
  // id + variables
21
22
  }
22
- exports.retainQuery = retainQuery;
23
23
  function garbageCollectEnvironment(environment) {
24
- const retainedIds = new Set([IsographEnvironment_1.ROOT_ID]);
24
+ const retainedIds = {};
25
25
  for (const query of environment.retainedQueries) {
26
26
  recordReachableIds(environment.store, query, retainedIds);
27
27
  }
28
28
  for (const query of environment.gcBuffer) {
29
29
  recordReachableIds(environment.store, query, retainedIds);
30
30
  }
31
- for (const dataId in environment.store) {
32
- if (!retainedIds.has(dataId)) {
33
- delete environment.store[dataId];
31
+ for (const typeName in environment.store) {
32
+ const dataById = environment.store[typeName];
33
+ if (dataById == null)
34
+ continue;
35
+ const retainedTypeIds = retainedIds[typeName];
36
+ // delete all objects
37
+ if (retainedTypeIds == undefined || retainedTypeIds.size == 0) {
38
+ delete environment.store[typeName];
39
+ continue;
40
+ }
41
+ for (const dataId in dataById) {
42
+ if (!retainedTypeIds.has(dataId)) {
43
+ delete dataById[dataId];
44
+ }
45
+ }
46
+ if (Object.keys(dataById).length === 0) {
47
+ delete environment.store[typeName];
34
48
  }
35
49
  }
36
50
  }
37
- exports.garbageCollectEnvironment = garbageCollectEnvironment;
38
51
  function recordReachableIds(store, retainedQuery, mutableRetainedIds) {
39
- recordReachableIdsFromRecord(store, store[IsographEnvironment_1.ROOT_ID], mutableRetainedIds, retainedQuery.normalizationAst, retainedQuery.variables);
52
+ var _a, _b;
53
+ var _c;
54
+ const record = (_a = store[retainedQuery.root.__typename]) === null || _a === void 0 ? void 0 : _a[retainedQuery.root.__link];
55
+ const retainedRecordsIds = ((_b = mutableRetainedIds[_c = retainedQuery.root.__typename]) !== null && _b !== void 0 ? _b : (mutableRetainedIds[_c] = new Set()));
56
+ retainedRecordsIds.add(retainedQuery.root.__link);
57
+ if (record) {
58
+ recordReachableIdsFromRecord(store, record, mutableRetainedIds, retainedQuery.normalizationAst, retainedQuery.variables);
59
+ }
40
60
  }
41
61
  function recordReachableIdsFromRecord(store, currentRecord, mutableRetainedIds, selections, variables) {
62
+ var _a;
42
63
  for (const selection of selections) {
43
64
  switch (selection.kind) {
44
65
  case 'Linked':
45
66
  const linkKey = (0, cache_1.getParentRecordKey)(selection, variables !== null && variables !== void 0 ? variables : {});
46
67
  const linkedFieldOrFields = currentRecord[linkKey];
47
- const ids = [];
68
+ const links = [];
48
69
  if (Array.isArray(linkedFieldOrFields)) {
49
70
  for (const maybeLink of linkedFieldOrFields) {
50
71
  const link = (0, IsographEnvironment_1.assertLink)(maybeLink);
51
72
  if (link != null) {
52
- ids.push(link.__link);
73
+ links.push(link);
53
74
  }
54
75
  }
55
76
  }
56
77
  else {
57
78
  const link = (0, IsographEnvironment_1.assertLink)(linkedFieldOrFields);
58
79
  if (link != null) {
59
- ids.push(link.__link);
80
+ links.push(link);
60
81
  }
61
82
  }
62
- for (const nextRecordId of ids) {
63
- const nextRecord = store[nextRecordId];
83
+ let typeStore = selection.concreteType !== null
84
+ ? store[selection.concreteType]
85
+ : null;
86
+ if (typeStore == null && selection.concreteType !== null) {
87
+ continue;
88
+ }
89
+ for (const nextRecordLink of links) {
90
+ let __typename = nextRecordLink.__typename;
91
+ const resolvedTypeStore = typeStore !== null && typeStore !== void 0 ? typeStore : store[__typename];
92
+ if (resolvedTypeStore == null) {
93
+ continue;
94
+ }
95
+ const nextRecord = resolvedTypeStore[nextRecordLink.__link];
64
96
  if (nextRecord != null) {
65
- mutableRetainedIds.add(nextRecordId);
97
+ const retainedRecordsIds = ((_a = mutableRetainedIds[__typename]) !== null && _a !== void 0 ? _a : (mutableRetainedIds[__typename] = new Set()));
98
+ retainedRecordsIds.add(nextRecordLink.__link);
66
99
  recordReachableIdsFromRecord(store, nextRecord, mutableRetainedIds, selection.selections, variables);
67
100
  }
68
101
  }
@@ -0,0 +1,69 @@
1
+ import { CleanupFn } from '@isograph/disposable-types';
2
+ import { IsographEnvironment, IsographStore, StoreRecord, type Link } from './IsographEnvironment';
3
+ import { IsographEntrypoint, NormalizationAst, RefetchQueryNormalizationArtifact } from './entrypoint';
4
+ import { FragmentReference, Variables } from './FragmentReference';
5
+ import { NetworkResponseObject, type EncounteredIds } from './cache';
6
+ import { Arguments } from './util';
7
+ import { ReadDataResult } from './read';
8
+ import { CheckResult } from './check';
9
+ export type LogMessage = {
10
+ kind: 'GettingSuspenseCacheItem';
11
+ index: string;
12
+ availableCacheItems: ReadonlyArray<string>;
13
+ found: boolean;
14
+ } | {
15
+ kind: 'AboutToNormalize';
16
+ normalizationAst: NormalizationAst;
17
+ networkResponse: NetworkResponseObject;
18
+ variables: Variables;
19
+ } | {
20
+ kind: 'AfterNormalization';
21
+ store: IsographStore;
22
+ encounteredIds: EncounteredIds;
23
+ } | {
24
+ kind: 'DeepEqualityCheck';
25
+ fragmentReference: FragmentReference<any, any>;
26
+ old: object;
27
+ new: object;
28
+ deeplyEqual: boolean;
29
+ } | {
30
+ kind: 'ComponentRerendered';
31
+ componentName: string;
32
+ rootLink: Link;
33
+ } | {
34
+ kind: 'MakeNetworkRequest';
35
+ artifact: RefetchQueryNormalizationArtifact | IsographEntrypoint<any, any>;
36
+ variables: Variables;
37
+ networkRequestId: string;
38
+ } | {
39
+ kind: 'ReceivedNetworkResponse';
40
+ networkResponse: any;
41
+ networkRequestId: string;
42
+ } | {
43
+ kind: 'ReceivedNetworkError';
44
+ error: any;
45
+ networkRequestId: string;
46
+ } | {
47
+ kind: 'MissingFieldHandlerCalled';
48
+ root: Link;
49
+ storeRecord: StoreRecord;
50
+ fieldName: string;
51
+ arguments: Arguments | null;
52
+ variables: Variables;
53
+ } | {
54
+ kind: 'DoneReading';
55
+ response: ReadDataResult<any>;
56
+ } | {
57
+ kind: 'NonEntrypointReceived';
58
+ entrypoint: any;
59
+ } | {
60
+ kind: 'EnvironmentCheck';
61
+ result: CheckResult;
62
+ };
63
+ export type LogFunction = (logMessage: LogMessage) => void;
64
+ export type WrappedLogFunction = {
65
+ log: LogFunction;
66
+ };
67
+ export declare function logMessage(environment: IsographEnvironment, message: LogMessage): void;
68
+ export declare function registerLogger(environment: IsographEnvironment, log: LogFunction): CleanupFn;
69
+ //# sourceMappingURL=logging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/core/logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,KAAK,IAAI,EACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,iCAAiC,EAClC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,MAAM,UAAU,GAClB;IACE,IAAI,EAAE,0BAA0B,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3C,KAAK,EAAE,OAAO,CAAC;CAChB,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,eAAe,EAAE,qBAAqB,CAAC;IACvC,SAAS,EAAE,SAAS,CAAC;CACtB,GACD;IACE,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,aAAa,CAAC;IACrB,cAAc,EAAE,cAAc,CAAC;CAChC,GACD;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC/C,GAA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EAChC,OAAO,EAAE,UAAU,QAOpB;AAED,wBAAgB,cAAc,CAC5B,WAAW,EAAE,mBAAmB,EAChC,GAAG,EAAE,WAAW,GACf,SAAS,CAMX"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logMessage = logMessage;
4
+ exports.registerLogger = registerLogger;
5
+ function logMessage(environment, message) {
6
+ for (const logger of environment.loggers) {
7
+ try {
8
+ logger.log(message);
9
+ }
10
+ catch (_a) { }
11
+ }
12
+ }
13
+ function registerLogger(environment, log) {
14
+ const wrapped = { log };
15
+ environment.loggers.add(wrapped);
16
+ return () => {
17
+ environment.loggers.delete(wrapped);
18
+ };
19
+ }
@@ -3,4 +3,7 @@ import { IsographEntrypoint, RefetchQueryNormalizationArtifact } from './entrypo
3
3
  import { Variables } from './FragmentReference';
4
4
  import { IsographEnvironment } from './IsographEnvironment';
5
5
  import { AnyError, PromiseWrapper } from './PromiseWrapper';
6
- export declare function makeNetworkRequest(environment: IsographEnvironment, artifact: RefetchQueryNormalizationArtifact | IsographEntrypoint<any, any>, variables: Variables): ItemCleanupPair<PromiseWrapper<void, AnyError>>;
6
+ import { FetchOptions } from './check';
7
+ export declare function maybeMakeNetworkRequest(environment: IsographEnvironment, artifact: RefetchQueryNormalizationArtifact | IsographEntrypoint<any, any>, variables: Variables, fetchOptions?: FetchOptions): ItemCleanupPair<PromiseWrapper<void, AnyError>>;
8
+ export declare function makeNetworkRequest(environment: IsographEnvironment, artifact: RefetchQueryNormalizationArtifact | IsographEntrypoint<any, any>, variables: Variables, fetchOptions?: FetchOptions): ItemCleanupPair<PromiseWrapper<void, AnyError>>;
9
+ //# sourceMappingURL=makeNetworkRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeNetworkRequest.d.ts","sourceRoot":"","sources":["../../src/core/makeNetworkRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EACL,kBAAkB,EAClB,iCAAiC,EAClC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAOhD,OAAO,EAAE,mBAAmB,EAAW,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACL,QAAQ,EACR,cAAc,EAGf,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAqC,YAAY,EAAE,MAAM,SAAS,CAAC;AAI1E,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,mBAAmB,EAChC,QAAQ,EAAE,iCAAiC,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,EAC1E,SAAS,EAAE,SAAS,EACpB,YAAY,CAAC,EAAE,YAAY,GAC1B,eAAe,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CA8BjD;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,mBAAmB,EAChC,QAAQ,EAAE,iCAAiC,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,EAC1E,SAAS,EAAE,SAAS,EACpB,YAAY,CAAC,EAAE,YAAY,GAC1B,eAAe,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CA+FjD"}
@@ -1,39 +1,79 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeNetworkRequest = void 0;
3
+ exports.maybeMakeNetworkRequest = maybeMakeNetworkRequest;
4
+ exports.makeNetworkRequest = makeNetworkRequest;
4
5
  const garbageCollection_1 = require("./garbageCollection");
6
+ const IsographEnvironment_1 = require("./IsographEnvironment");
5
7
  const PromiseWrapper_1 = require("./PromiseWrapper");
6
8
  const cache_1 = require("./cache");
7
- function makeNetworkRequest(environment, artifact, variables) {
8
- // @ts-expect-error
9
- if (typeof window !== 'undefined' && window.__LOG) {
10
- console.log('make network request', artifact, variables);
9
+ const logging_1 = require("./logging");
10
+ const check_1 = require("./check");
11
+ let networkRequestId = 0;
12
+ function maybeMakeNetworkRequest(environment, artifact, variables, fetchOptions) {
13
+ var _a;
14
+ switch ((_a = fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.shouldFetch) !== null && _a !== void 0 ? _a : check_1.DEFAULT_SHOULD_FETCH_VALUE) {
15
+ case 'Yes': {
16
+ return makeNetworkRequest(environment, artifact, variables, fetchOptions);
17
+ }
18
+ case 'No': {
19
+ return [(0, PromiseWrapper_1.wrapResolvedValue)(undefined), () => { }];
20
+ }
21
+ case 'IfNecessary': {
22
+ const result = (0, check_1.check)(environment, artifact.networkRequestInfo.normalizationAst, variables, {
23
+ __link: IsographEnvironment_1.ROOT_ID,
24
+ __typename: artifact.concreteType,
25
+ });
26
+ if (result.kind === 'EnoughData') {
27
+ return [(0, PromiseWrapper_1.wrapResolvedValue)(undefined), () => { }];
28
+ }
29
+ else {
30
+ return makeNetworkRequest(environment, artifact, variables, fetchOptions);
31
+ }
32
+ }
11
33
  }
34
+ }
35
+ function makeNetworkRequest(environment, artifact, variables, fetchOptions) {
36
+ // TODO this should be a DataId and stored in the store
37
+ const myNetworkRequestId = networkRequestId + '';
38
+ networkRequestId++;
39
+ (0, logging_1.logMessage)(environment, {
40
+ kind: 'MakeNetworkRequest',
41
+ artifact,
42
+ variables,
43
+ networkRequestId: myNetworkRequestId,
44
+ });
12
45
  let status = {
13
46
  kind: 'UndisposedIncomplete',
14
47
  };
15
48
  // This should be an observable, not a promise
16
49
  const promise = environment
17
- .networkFunction(artifact.queryText, variables)
50
+ .networkFunction(artifact.networkRequestInfo.queryText, variables)
18
51
  .then((networkResponse) => {
19
- var _a;
20
- // @ts-expect-error
21
- if (typeof window !== 'undefined' && window.__LOG) {
22
- console.log('network response', artifact, networkResponse);
23
- }
52
+ var _a, _b, _c;
53
+ (0, logging_1.logMessage)(environment, {
54
+ kind: 'ReceivedNetworkResponse',
55
+ networkResponse,
56
+ networkRequestId: myNetworkRequestId,
57
+ });
24
58
  if (networkResponse.errors != null) {
59
+ try {
60
+ (_a = fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.onError) === null || _a === void 0 ? void 0 : _a.call(fetchOptions);
61
+ }
62
+ catch (_d) { }
25
63
  // @ts-expect-error Why are we getting the wrong constructor here?
26
64
  throw new Error('GraphQL network response had errors', {
27
65
  cause: networkResponse,
28
66
  });
29
67
  }
30
68
  if (status.kind === 'UndisposedIncomplete') {
31
- (0, cache_1.normalizeData)(environment, artifact.normalizationAst, (_a = networkResponse.data) !== null && _a !== void 0 ? _a : {}, variables, artifact.kind === 'Entrypoint'
69
+ const root = { __link: IsographEnvironment_1.ROOT_ID, __typename: artifact.concreteType };
70
+ (0, cache_1.normalizeData)(environment, artifact.networkRequestInfo.normalizationAst, (_b = networkResponse.data) !== null && _b !== void 0 ? _b : {}, variables, artifact.kind === 'Entrypoint'
32
71
  ? artifact.readerWithRefetchQueries.nestedRefetchQueries
33
- : []);
72
+ : [], root);
34
73
  const retainedQuery = {
35
- normalizationAst: artifact.normalizationAst,
74
+ normalizationAst: artifact.networkRequestInfo.normalizationAst,
36
75
  variables,
76
+ root,
37
77
  };
38
78
  status = {
39
79
  kind: 'UndisposedComplete',
@@ -41,6 +81,23 @@ function makeNetworkRequest(environment, artifact, variables) {
41
81
  };
42
82
  (0, garbageCollection_1.retainQuery)(environment, retainedQuery);
43
83
  }
84
+ try {
85
+ (_c = fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.onComplete) === null || _c === void 0 ? void 0 : _c.call(fetchOptions);
86
+ }
87
+ catch (_e) { }
88
+ })
89
+ .catch((e) => {
90
+ var _a;
91
+ (0, logging_1.logMessage)(environment, {
92
+ kind: 'ReceivedNetworkError',
93
+ networkRequestId: myNetworkRequestId,
94
+ error: e,
95
+ });
96
+ try {
97
+ (_a = fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.onError) === null || _a === void 0 ? void 0 : _a.call(fetchOptions);
98
+ }
99
+ catch (_b) { }
100
+ throw e;
44
101
  });
45
102
  const wrapper = (0, PromiseWrapper_1.wrapPromise)(promise);
46
103
  const response = [
@@ -59,4 +116,3 @@ function makeNetworkRequest(environment, artifact, variables) {
59
116
  ];
60
117
  return response;
61
118
  }
62
- exports.makeNetworkRequest = makeNetworkRequest;
@@ -1,12 +1,27 @@
1
- import { FragmentReference } from './FragmentReference';
2
- import { DataId, IsographEnvironment } from './IsographEnvironment';
1
+ import { type EncounteredIds } from './cache';
2
+ import { FragmentReference, ExtractData } from './FragmentReference';
3
+ import { IsographEnvironment, type Link } from './IsographEnvironment';
3
4
  export type WithEncounteredRecords<T> = {
4
- readonly encounteredRecords: Set<DataId>;
5
- readonly item: T;
5
+ readonly encounteredRecords: EncounteredIds;
6
+ readonly item: ExtractData<T>;
7
+ };
8
+ export declare function readButDoNotEvaluate<TReadFromStore extends {
9
+ parameters: object;
10
+ data: object;
11
+ }>(environment: IsographEnvironment, fragmentReference: FragmentReference<TReadFromStore, unknown>, networkRequestOptions: NetworkRequestReaderOptions): WithEncounteredRecords<TReadFromStore>;
12
+ export type ReadDataResult<TReadFromStore> = {
13
+ readonly kind: 'Success';
14
+ readonly data: ExtractData<TReadFromStore>;
15
+ readonly encounteredRecords: EncounteredIds;
16
+ } | {
17
+ readonly kind: 'MissingData';
18
+ readonly reason: string;
19
+ readonly nestedReason?: ReadDataResult<unknown>;
20
+ readonly recordLink: Link;
6
21
  };
7
- export declare function readButDoNotEvaluate<TReadFromStore extends Object>(environment: IsographEnvironment, fragmentReference: FragmentReference<TReadFromStore, unknown>, networkRequestOptions: NetworkRequestReaderOptions): WithEncounteredRecords<TReadFromStore>;
8
22
  export type NetworkRequestReaderOptions = {
9
23
  suspendIfInFlight: boolean;
10
24
  throwOnNetworkError: boolean;
11
25
  };
12
26
  export declare function getNetworkRequestOptionsWithDefaults(networkRequestOptions?: Partial<NetworkRequestReaderOptions> | void): NetworkRequestReaderOptions;
27
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d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