@graphiql/plugin-history 0.3.0-rc.1 → 0.3.0-rc.3

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/dist/context.d.ts CHANGED
@@ -16,6 +16,10 @@ declare type HistoryStoreProps = {
16
16
  */
17
17
  export declare const HistoryStore: FC<HistoryStoreProps>;
18
18
  export declare const useHistory: () => QueryStoreItem[];
19
+ /**
20
+ * Actions are functions used to update values in your store. They are static and never change.
21
+ * @see https://tkdodo.eu/blog/working-with-zustand#separate-actions-from-state
22
+ */
19
23
  export declare const useHistoryActions: () => {
20
24
  /**
21
25
  * Add an operation to the history.
package/dist/context.js CHANGED
@@ -10,21 +10,21 @@ const historyStore = createStore((set, get) => ({
10
10
  const {
11
11
  historyStorage
12
12
  } = get();
13
- historyStorage.updateHistory(operation);
13
+ historyStorage == null ? void 0 : historyStorage.updateHistory(operation);
14
14
  set({});
15
15
  },
16
16
  editLabel(operation, index) {
17
17
  const {
18
18
  historyStorage
19
19
  } = get();
20
- historyStorage.editLabel(operation, index);
20
+ historyStorage == null ? void 0 : historyStorage.editLabel(operation, index);
21
21
  set({});
22
22
  },
23
23
  toggleFavorite(operation) {
24
24
  const {
25
25
  historyStorage
26
26
  } = get();
27
- historyStorage.toggleFavorite(operation);
27
+ historyStorage == null ? void 0 : historyStorage.toggleFavorite(operation);
28
28
  set({});
29
29
  },
30
30
  setActive: (item) => item,
@@ -32,7 +32,7 @@ const historyStore = createStore((set, get) => ({
32
32
  const {
33
33
  historyStorage
34
34
  } = get();
35
- historyStorage.deleteHistory(item, clearFavorites);
35
+ historyStorage == null ? void 0 : historyStorage.deleteHistory(item, clearFavorites);
36
36
  set({});
37
37
  }
38
38
  }
@@ -115,6 +115,7 @@ const HistoryStore = (t0) => {
115
115
  return children;
116
116
  };
117
117
  const useHistoryStore = createBoundedUseStore(historyStore);
118
+ const EMPTY_ARRAY = [];
118
119
  const useHistory = () => {
119
120
  return useHistoryStore(_temp);
120
121
  };
@@ -122,7 +123,8 @@ const useHistoryActions = () => {
122
123
  return useHistoryStore(_temp2);
123
124
  };
124
125
  function _temp(state) {
125
- return state.historyStorage.queries;
126
+ var _a;
127
+ return ((_a = state.historyStorage) == null ? void 0 : _a.queries) ?? EMPTY_ARRAY;
126
128
  }
127
129
  function _temp2(state) {
128
130
  return state.actions;
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sources":["../src/context.tsx"],"sourcesContent":["// eslint-disable-next-line react/jsx-filename-extension -- TODO\nimport { FC, ReactElement, ReactNode, useEffect } from 'react';\nimport { createStore } from 'zustand';\nimport {\n HistoryStore as ToolkitHistoryStore,\n QueryStoreItem,\n} from '@graphiql/toolkit';\nimport {\n useGraphiQL,\n pick,\n useStorage,\n createBoundedUseStore,\n} from '@graphiql/react';\n\nconst historyStore = createStore<HistoryStoreType>((set, get) => ({\n historyStorage: null!,\n actions: {\n addToHistory(operation) {\n const { historyStorage } = get();\n historyStorage.updateHistory(operation);\n set({}); // trigger rerender\n },\n editLabel(operation, index) {\n const { historyStorage } = get();\n historyStorage.editLabel(operation, index);\n set({}); // trigger rerender\n },\n toggleFavorite(operation) {\n const { historyStorage } = get();\n historyStorage.toggleFavorite(operation);\n set({}); // trigger rerender\n },\n setActive: item => item,\n deleteFromHistory(item, clearFavorites) {\n const { historyStorage } = get();\n historyStorage.deleteHistory(item, clearFavorites);\n set({}); // trigger rerender\n },\n },\n}));\n\ntype HistoryStoreType = {\n historyStorage: ToolkitHistoryStore;\n actions: {\n /**\n * Add an operation to the history.\n * @param operation The operation that was executed, consisting of the query,\n * variables, headers, and operation name.\n */\n addToHistory(operation: {\n query?: string;\n variables?: string;\n headers?: string;\n operationName?: string;\n }): void;\n /**\n * Change the custom label of an item from the history.\n * @param args An object containing the label (`undefined` if it should be\n * unset) and properties that identify the history item that the label should\n * be applied to. (This can result in the label being applied to multiple\n * history items.)\n * @param index Index to edit. Without it, will look for the first index matching the\n * operation, which may lead to misleading results if multiple items have the same label\n */\n editLabel(\n args: {\n query?: string;\n variables?: string;\n headers?: string;\n operationName?: string;\n label?: string;\n favorite?: boolean;\n },\n index?: number,\n ): void;\n /**\n * Toggle the favorite state of an item from the history.\n * @param args An object containing the favorite state (`undefined` if it\n * should be unset) and properties that identify the history item that the\n * label should be applied to. (This can result in the label being applied\n * to multiple history items.)\n */\n toggleFavorite(args: {\n query?: string;\n variables?: string;\n headers?: string;\n operationName?: string;\n label?: string;\n favorite?: boolean;\n }): void;\n /**\n * Delete an operation from the history.\n * @param args The operation that was executed, consisting of the query,\n * variables, headers, and operation name.\n * @param clearFavorites This is only if you press the 'clear' button\n */\n deleteFromHistory(args: QueryStoreItem, clearFavorites?: boolean): void;\n /**\n * If you need to know when an item in history is set as active to customize\n * your application.\n */\n setActive(args: QueryStoreItem): void;\n };\n};\n\ntype HistoryStoreProps = {\n children: ReactNode;\n /**\n * The maximum number of executed operations to store.\n * @default 20\n */\n maxHistoryLength?: number;\n};\n\n/**\n * The functions send the entire operation so users can customize their own application and get\n * access to the operation plus any additional props they added for their needs (i.e., build their\n * own functions that may save to a backend instead of localStorage and might need an id property\n * added to the `QueryStoreItem`)\n */\nexport const HistoryStore: FC<HistoryStoreProps> = ({\n maxHistoryLength = 20,\n children,\n}) => {\n const { isFetching, tabs, activeTabIndex } = useGraphiQL(\n pick('isFetching', 'tabs', 'activeTabIndex'),\n );\n const activeTab = tabs[activeTabIndex]!;\n const storage = useStorage();\n\n const historyStorage = // eslint-disable-line react-hooks/exhaustive-deps -- false positive, code is optimized by React Compiler\n new ToolkitHistoryStore(storage, maxHistoryLength);\n\n useEffect(() => {\n historyStore.setState({ historyStorage });\n }, [historyStorage]);\n\n useEffect(() => {\n if (!isFetching) {\n return;\n }\n const { addToHistory } = historyStore.getState().actions;\n addToHistory({\n query: activeTab.query ?? undefined,\n variables: activeTab.variables ?? undefined,\n headers: activeTab.headers ?? undefined,\n operationName: activeTab.operationName ?? undefined,\n });\n }, [isFetching, activeTab]);\n\n return children as ReactElement;\n};\n\nconst useHistoryStore = createBoundedUseStore(historyStore);\n\nexport const useHistory = () =>\n useHistoryStore(state => state.historyStorage.queries);\nexport const useHistoryActions = () => useHistoryStore(state => state.actions);\n"],"names":["historyStore","createStore","set","get","historyStorage","actions","addToHistory","operation","updateHistory","editLabel","index","toggleFavorite","setActive","item","deleteFromHistory","clearFavorites","deleteHistory","HistoryStore","t0","$","_c","maxHistoryLength","t1","children","undefined","t2","Symbol","for","pick","isFetching","tabs","activeTabIndex","useGraphiQL","activeTab","storage","useStorage","t3","ToolkitHistoryStore","t4","t5","setState","useEffect","t6","t7","getState","query","variables","headers","operationName","useHistoryStore","createBoundedUseStore","useHistory","_temp","useHistoryActions","_temp2","state","queries"],"mappings":";;;;;AAcA,MAAMA,eAAeC,YAA8B,CAACC,KAAKC,SAAS;AAAA,EAChEC,gBAAgB;AAAA,EAChBC,SAAS;AAAA,IACPC,aAAaC,WAAW;AAChB,YAAA;AAAA,QAAEH;AAAAA,UAAmBD,IAAI;AAC/BC,qBAAeI,cAAcD,SAAS;AACtCL,UAAI,CAAA,CAAE;AAAA,IACR;AAAA,IACAO,UAAUF,WAAWG,OAAO;AACpB,YAAA;AAAA,QAAEN;AAAAA,UAAmBD,IAAI;AAChBM,qBAAAA,UAAUF,WAAWG,KAAK;AACzCR,UAAI,CAAA,CAAE;AAAA,IACR;AAAA,IACAS,eAAeJ,WAAW;AAClB,YAAA;AAAA,QAAEH;AAAAA,UAAmBD,IAAI;AAC/BC,qBAAeO,eAAeJ,SAAS;AACvCL,UAAI,CAAA,CAAE;AAAA,IACR;AAAA,IACAU,WAAWC,CAAQA,SAAAA;AAAAA,IACnBC,kBAAkBD,MAAME,gBAAgB;AAChC,YAAA;AAAA,QAAEX;AAAAA,UAAmBD,IAAI;AAChBa,qBAAAA,cAAcH,MAAME,cAAc;AACjDb,UAAI,CAAA,CAAE;AAAA,IAAA;AAAA,EACR;AAEJ,EAAE;AAiFK,MAAMe,eAAsCC,CAAA,OAAA;AAA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AvB;AAAAA,MAAAA,IAAyBN,aAAA4C,SAAAA,EAAuBvC;AACpC,mBAAA;AAAA,QAAAwC,OACHZ,UAASY,SAAArB;AAAAA,QAAmBsB,WACxBb,UAASa,aAAAtB;AAAAA,QAAuBuB,SAClCd,UAASc,WAAAvB;AAAAA,QAAqBwB,eACxBf,UAASe,iBAAAxB;AAAAA,MAAAA,CACzB;AAAA,IAAC;AACD,SAAA,CAACK,YAAYI,SAAS;AAACd,WAAAc;AAAAd,WAAAU;AAAAV,WAAAuB;AAAAvB,YAAAwB;AAAAA,EAAAA,OAAA;AAAAD,SAAAvB,EAAA,CAAA;AAAAwB,SAAAxB,EAAA,EAAA;AAAA,EAAA;AAX1BsB,YAAUC,IAWPC,EAAuB;AAEnBpB,SAAAA;AAAwB;AAGjC,MAAM0B,kBAAkBC,sBAAsBlD,YAAY;AAEnD,MAAMmD,aAAaA,MAAA;AAAA,SACxBF,gBAAAG,KAAqD;AAAC;AACjD,MAAMC,oBAAoBA,MAAA;AAAA,SAAMJ,gBAAAK,MAAsC;AAAC;AAFpD,SAAAF,MAAAG,OAAA;AAAA,SACCA,MAAKnD,eAAAoD;AAAA;AACC,SAAAF,OAAAC,OAAA;AAAA,SAA+BA,MAAKlD;AAAA;"}
1
+ {"version":3,"file":"context.js","sources":["../src/context.ts"],"sourcesContent":["import { FC, ReactElement, ReactNode, useEffect } from 'react';\nimport { createStore } from 'zustand';\nimport {\n HistoryStore as ToolkitHistoryStore,\n QueryStoreItem,\n} from '@graphiql/toolkit';\nimport {\n useGraphiQL,\n pick,\n useStorage,\n createBoundedUseStore,\n} from '@graphiql/react';\n\nconst historyStore = createStore<HistoryStoreType>((set, get) => ({\n historyStorage: null,\n actions: {\n addToHistory(operation) {\n const { historyStorage } = get();\n historyStorage?.updateHistory(operation);\n set({}); // trigger rerender\n },\n editLabel(operation, index) {\n const { historyStorage } = get();\n historyStorage?.editLabel(operation, index);\n set({}); // trigger rerender\n },\n toggleFavorite(operation) {\n const { historyStorage } = get();\n historyStorage?.toggleFavorite(operation);\n set({}); // trigger rerender\n },\n setActive: item => item,\n deleteFromHistory(item, clearFavorites) {\n const { historyStorage } = get();\n historyStorage?.deleteHistory(item, clearFavorites);\n set({}); // trigger rerender\n },\n },\n}));\n\ntype HistoryStoreType = {\n // Can be `null` if History plugin saved in `localStorage` as `visiblePlugin`\n historyStorage: ToolkitHistoryStore | null;\n actions: {\n /**\n * Add an operation to the history.\n * @param operation The operation that was executed, consisting of the query,\n * variables, headers, and operation name.\n */\n addToHistory(operation: {\n query?: string;\n variables?: string;\n headers?: string;\n operationName?: string;\n }): void;\n /**\n * Change the custom label of an item from the history.\n * @param args An object containing the label (`undefined` if it should be\n * unset) and properties that identify the history item that the label should\n * be applied to. (This can result in the label being applied to multiple\n * history items.)\n * @param index Index to edit. Without it, will look for the first index matching the\n * operation, which may lead to misleading results if multiple items have the same label\n */\n editLabel(\n args: {\n query?: string;\n variables?: string;\n headers?: string;\n operationName?: string;\n label?: string;\n favorite?: boolean;\n },\n index?: number,\n ): void;\n /**\n * Toggle the favorite state of an item from the history.\n * @param args An object containing the favorite state (`undefined` if it\n * should be unset) and properties that identify the history item that the\n * label should be applied to. (This can result in the label being applied\n * to multiple history items.)\n */\n toggleFavorite(args: {\n query?: string;\n variables?: string;\n headers?: string;\n operationName?: string;\n label?: string;\n favorite?: boolean;\n }): void;\n /**\n * Delete an operation from the history.\n * @param args The operation that was executed, consisting of the query,\n * variables, headers, and operation name.\n * @param clearFavorites This is only if you press the 'clear' button\n */\n deleteFromHistory(args: QueryStoreItem, clearFavorites?: boolean): void;\n /**\n * If you need to know when an item in history is set as active to customize\n * your application.\n */\n setActive(args: QueryStoreItem): void;\n };\n};\n\ntype HistoryStoreProps = {\n children: ReactNode;\n /**\n * The maximum number of executed operations to store.\n * @default 20\n */\n maxHistoryLength?: number;\n};\n\n/**\n * The functions send the entire operation so users can customize their own application and get\n * access to the operation plus any additional props they added for their needs (i.e., build their\n * own functions that may save to a backend instead of localStorage and might need an id property\n * added to the `QueryStoreItem`)\n */\nexport const HistoryStore: FC<HistoryStoreProps> = ({\n maxHistoryLength = 20,\n children,\n}) => {\n const { isFetching, tabs, activeTabIndex } = useGraphiQL(\n pick('isFetching', 'tabs', 'activeTabIndex'),\n );\n const activeTab = tabs[activeTabIndex]!;\n const storage = useStorage();\n\n const historyStorage = // eslint-disable-line react-hooks/exhaustive-deps -- false positive, code is optimized by React Compiler\n new ToolkitHistoryStore(storage, maxHistoryLength);\n\n useEffect(() => {\n historyStore.setState({ historyStorage });\n }, [historyStorage]);\n\n useEffect(() => {\n if (!isFetching) {\n return;\n }\n const { addToHistory } = historyStore.getState().actions;\n addToHistory({\n query: activeTab.query ?? undefined,\n variables: activeTab.variables ?? undefined,\n headers: activeTab.headers ?? undefined,\n operationName: activeTab.operationName ?? undefined,\n });\n }, [isFetching, activeTab]);\n\n return children as ReactElement;\n};\n\nconst useHistoryStore = createBoundedUseStore(historyStore);\n\nconst EMPTY_ARRAY: QueryStoreItem[] = [];\n\nexport const useHistory = () =>\n useHistoryStore(state => state.historyStorage?.queries ?? EMPTY_ARRAY);\n\n/**\n * Actions are functions used to update values in your store. They are static and never change.\n * @see https://tkdodo.eu/blog/working-with-zustand#separate-actions-from-state\n */\nexport const useHistoryActions = () => useHistoryStore(state => state.actions);\n"],"names":["historyStore","createStore","set","get","historyStorage","actions","addToHistory","operation","updateHistory","editLabel","index","toggleFavorite","setActive","item","deleteFromHistory","clearFavorites","deleteHistory","HistoryStore","t0","$","_c","maxHistoryLength","t1","children","undefined","t2","Symbol","for","pick","isFetching","tabs","activeTabIndex","useGraphiQL","activeTab","storage","useStorage","t3","ToolkitHistoryStore","t4","t5","setState","useEffect","t6","t7","getState","query","variables","headers","operationName","useHistoryStore","createBoundedUseStore","EMPTY_ARRAY","useHistory","_temp","useHistoryActions","_temp2","state","queries"],"mappings":";;;;;AAaA,MAAMA,eAAeC,YAA8B,CAACC,KAAKC,SAAS;AAAA,EAChEC,gBAAgB;AAA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E;AAEjC,MAAMC,aAAaA,MAAA;AAAA,SACxBH,gBAAAI,KAAqE;AAAC;AAMjE,MAAMC,oBAAoBA,MAAA;AAAA,SAAML,gBAAAM,MAAsC;AAAC;AAPpD,SAAAF,MAAAG,OAAA;;AACCA,WAAAA,WAAKpD,mBAALoD,mBAAKC,YAAAN;AAAuC;AAMtC,SAAAI,OAAAC,OAAA;AAAA,SAA+BA,MAAKnD;AAAA;"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @deprecated Use `useHistoryActions` and `useHistory` hooks instead.
3
+ */
4
+ export declare function useHistoryContext(): {
5
+ items: import('@graphiql/toolkit/dist/esm/storage/query.mjs').QueryStoreItem[];
6
+ addToHistory(operation: {
7
+ query?: string | undefined;
8
+ variables?: string | undefined;
9
+ headers?: string | undefined;
10
+ operationName?: string | undefined;
11
+ }): void;
12
+ editLabel(args: {
13
+ query?: string | undefined;
14
+ variables?: string | undefined;
15
+ headers?: string | undefined;
16
+ operationName?: string | undefined;
17
+ label?: string | undefined;
18
+ favorite?: boolean | undefined;
19
+ }, index?: number | undefined): void;
20
+ toggleFavorite(args: {
21
+ query?: string | undefined;
22
+ variables?: string | undefined;
23
+ headers?: string | undefined;
24
+ operationName?: string | undefined;
25
+ label?: string | undefined;
26
+ favorite?: boolean | undefined;
27
+ }): void;
28
+ deleteFromHistory(args: import('@graphiql/toolkit/dist/esm/storage/query.mjs').QueryStoreItem, clearFavorites?: boolean | undefined): void;
29
+ setActive(args: import('@graphiql/toolkit/dist/esm/storage/query.mjs').QueryStoreItem): void;
30
+ };
@@ -0,0 +1,24 @@
1
+ import { c } from "react-compiler-runtime";
2
+ import { useHistoryActions, useHistory } from "./context.js";
3
+ function useHistoryContext() {
4
+ const $ = c(3);
5
+ const actions = useHistoryActions();
6
+ const items = useHistory();
7
+ let t0;
8
+ if ($[0] !== actions || $[1] !== items) {
9
+ t0 = {
10
+ ...actions,
11
+ items
12
+ };
13
+ $[0] = actions;
14
+ $[1] = items;
15
+ $[2] = t0;
16
+ } else {
17
+ t0 = $[2];
18
+ }
19
+ return t0;
20
+ }
21
+ export {
22
+ useHistoryContext
23
+ };
24
+ //# sourceMappingURL=deprecated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecated.js","sources":["../src/deprecated.ts"],"sourcesContent":["import { useHistory, useHistoryActions } from './context';\n\n/**\n * @deprecated Use `useHistoryActions` and `useHistory` hooks instead.\n */\nexport function useHistoryContext() {\n const actions = useHistoryActions();\n const items = useHistory();\n return { ...actions, items };\n}\n"],"names":["useHistoryContext","$","_c","actions","useHistoryActions","items","useHistory","t0"],"mappings":";;AAKO,SAAAA,oBAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA;AACL,QAAAC,UAAgBC,kBAAkB;AAClC,QAAAC,QAAcC,WAAW;AAAEC,MAAAA;AAAA,MAAAN,EAAAE,CAAAA,MAAAA,WAAAF,SAAAI,OAAA;AACpB,SAAA;AAAA,MAAA,GAAKF;AAAAA,MAAOE;AAAAA,IAAA;AAASJ,WAAAE;AAAAF,WAAAI;AAAAJ,WAAAM;AAAAA,EAAAA,OAAA;AAAAA,SAAAN,EAAA,CAAA;AAAA,EAAA;AAArBM,SAAAA;AAAqB;"}
package/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ import { History } from './components';
3
3
  export declare const HISTORY_PLUGIN: GraphiQLPlugin;
4
4
  export { History };
5
5
  export { HistoryStore, useHistory, useHistoryActions } from './context';
6
+ export * from './deprecated';
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import { HistoryIcon } from "@graphiql/react";
2
2
  /* empty css */
3
3
  import { History } from "./components.js";
4
4
  import { HistoryStore, useHistory, useHistoryActions } from "./context.js";
5
+ import { useHistoryContext } from "./deprecated.js";
5
6
  const HISTORY_PLUGIN = {
6
7
  title: "History",
7
8
  icon: HistoryIcon,
@@ -12,6 +13,7 @@ export {
12
13
  History,
13
14
  HistoryStore,
14
15
  useHistory,
15
- useHistoryActions
16
+ useHistoryActions,
17
+ useHistoryContext
16
18
  };
17
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { GraphiQLPlugin, HistoryIcon } from '@graphiql/react';\nimport './style.css';\n\nimport { History } from './components';\n\nexport const HISTORY_PLUGIN: GraphiQLPlugin = {\n title: 'History',\n icon: HistoryIcon,\n content: History,\n};\n\nexport { History };\n\nexport { HistoryStore, useHistory, useHistoryActions } from './context';\n"],"names":["HISTORY_PLUGIN","title","icon","HistoryIcon","content","History"],"mappings":";;;;AAKO,MAAMA,iBAAiC;AAAA,EAC5CC,OAAO;AAAA,EACPC,MAAMC;AAAAA,EACNC,SAASC;AACX;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { GraphiQLPlugin, HistoryIcon } from '@graphiql/react';\nimport './style.css';\n\nimport { History } from './components';\n\nexport const HISTORY_PLUGIN: GraphiQLPlugin = {\n title: 'History',\n icon: HistoryIcon,\n content: History,\n};\n\nexport { History };\n\nexport { HistoryStore, useHistory, useHistoryActions } from './context';\nexport * from './deprecated';\n"],"names":["HISTORY_PLUGIN","title","icon","HistoryIcon","content","History"],"mappings":";;;;;AAKO,MAAMA,iBAAiC;AAAA,EAC5CC,OAAO;AAAA,EACPC,MAAMC;AAAAA,EACNC,SAASC;AACX;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphiql/plugin-history",
3
- "version": "0.3.0-rc.1",
3
+ "version": "0.3.0-rc.3",
4
4
  "sideEffects": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,7 +39,7 @@
39
39
  "react-dom": "^18 || ^19"
40
40
  },
41
41
  "dependencies": {
42
- "@graphiql/react": "^0.35.0-rc.1",
42
+ "@graphiql/react": "^0.35.0-rc.8",
43
43
  "@graphiql/toolkit": "^0.11.3",
44
44
  "react-compiler-runtime": "19.1.0-rc.1",
45
45
  "zustand": "^5"