@octanejs/apollo-client 0.1.23 → 0.1.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/apollo-client",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -62,7 +62,7 @@
62
62
  "@apollo/client": ">=4.2.6 <4.3.0",
63
63
  "graphql": "^16.0.0 || ^17.0.0",
64
64
  "rxjs": "^7.3.0",
65
- "octane": "0.1.28"
65
+ "octane": "0.1.30"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@apollo/client": "4.2.6",
@@ -73,7 +73,7 @@
73
73
  "react-dom": "^19.2.7",
74
74
  "rxjs": "^7.8.2",
75
75
  "vitest": "^4.1.10",
76
- "octane": "0.1.28"
76
+ "octane": "0.1.30"
77
77
  },
78
78
  "scripts": {
79
79
  "test": "vitest run --root ../.. --project apollo-client"
@@ -26,6 +26,11 @@ import { isCompilerSite } from './internal/site.js';
26
26
  import { useApolloClient } from './useApolloClient.js';
27
27
  import { useSyncExternalStore } from './useSyncExternalStore.js';
28
28
  const lastWatchOptions = Symbol();
29
+ const linkedQueryStateOptions = {
30
+ sourceEqual(previous, next) {
31
+ return previous.client === next.client && previous.query === next.query;
32
+ },
33
+ };
29
34
  export const useQuery = function useQuery(query, options) {
30
35
  'use no memo';
31
36
  if (isCompilerSite(options, skipToken)) options = undefined;
@@ -54,16 +59,11 @@ function useQuery_(query, options = {}) {
54
59
  },
55
60
  };
56
61
  }
57
- let [state, setState] = React.useState(createState);
58
- if (client !== state.client || query !== state.query) {
59
- // If the client or query have changed, we need to create a new InternalState.
60
- // This will trigger a re-render with the new state, but it will also continue
61
- // to run the current render function to completion.
62
- // Since we sometimes trigger some side-effects in the render function, we
63
- // re-assign `state` to the new state to ensure that those side-effects are
64
- // triggered with the new state.
65
- setState((state = createState(state)));
66
- }
62
+ const [state] = React.useLinkedState(
63
+ { client, query },
64
+ (_source, previous) => createState(previous?.value),
65
+ linkedQueryStateOptions,
66
+ );
67
67
  const { observable, resultData } = state;
68
68
  useInitialFetchPolicyIfNecessary(watchQueryOptions, observable);
69
69
  useResubscribeIfNecessary(