Skip to content

Commit b213ceb

Browse files
committed
persist still not working
1 parent 4194a3d commit b213ceb

File tree

3 files changed

+53
-31
lines changed

3 files changed

+53
-31
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"build-docs": "rimraf packages/graphiql/typedoc && typedoc packages",
3939
"build:nontsc": "yarn wsrun:noexamples --exclude-missing --serial build",
4040
"build:clean": "yarn tsc --clean",
41-
"build:watch": "yarn tsc --watch",
41+
"build:watch": "yarn wsrun:noexamples --done-criteria '\"Build success in|built in\"' -t dev",
4242
"build-demo": "wsrun -m build-demo",
4343
"watch": "yarn build:watch",
4444
"watch-vscode": "yarn tsc && yarn workspace vscode-graphql compile",

packages/graphiql-react/src/provider.tsx

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -80,36 +80,34 @@ export function GraphiQLProvider({
8080
variables,
8181
visiblePlugin,
8282
}: GraphiQLProviderProps) {
83-
const store = useMemo(
84-
() =>
85-
createGraphiQLStore({
86-
defaultQuery,
87-
defaultHeaders,
88-
defaultTabs,
89-
externalFragments,
90-
fetcher,
91-
getDefaultFieldNames,
92-
headers,
93-
inputValueDeprecation,
94-
introspectionQueryName,
95-
onEditOperationName,
96-
onSchemaChange,
97-
onTabChange,
98-
schema,
99-
schemaDescription,
100-
shouldPersistHeaders,
101-
validationRules,
102-
dangerouslyAssumeSchemaIsValid,
103-
fetchOptions,
104-
}),
105-
[defaultQuery],
106-
);
83+
const store = useRef(
84+
createGraphiQLStore({
85+
defaultQuery,
86+
defaultHeaders,
87+
defaultTabs,
88+
externalFragments,
89+
fetcher,
90+
getDefaultFieldNames,
91+
headers,
92+
inputValueDeprecation,
93+
introspectionQueryName,
94+
onEditOperationName,
95+
onSchemaChange,
96+
onTabChange,
97+
schema,
98+
schemaDescription,
99+
shouldPersistHeaders,
100+
validationRules,
101+
dangerouslyAssumeSchemaIsValid,
102+
fetchOptions,
103+
}),
104+
).current;
107105

108106
const state = useStore(store);
109107

110108
useEffect(() => {
111109
state.schema.introspect();
112-
}, [state.execution.fetcher]);
110+
}, [fetcher]);
113111
return (
114112
<GraphiQLStoreContext.Provider value={store}>
115113
<StorageContextProvider storage={storage}>

packages/graphiql-toolkit/src/zustand/store.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,35 @@ const middlewares = (
3232
return createStore<GraphiQLState>()(
3333
immer(
3434
devtools(
35-
// fn,
36-
persist(fn, {
37-
storage: createJSONStorage(() => storage),
38-
name: 'graphiql',
39-
}),
35+
fn,
36+
// TODO: more issues with persist middleware
37+
// persist(fn, {
38+
// storage: createJSONStorage(() => storage),
39+
// name: 'graphiql',
40+
// onRehydrateStorage: state => {
41+
// return {
42+
// ...state,
43+
// editor: {
44+
// ...state,
45+
46+
// }
47+
// }
48+
// // partialize: state => {
49+
// // const {
50+
// // editor: {
51+
// // queryEditor,
52+
// // variableEditor,
53+
// // headerEditor,
54+
// // responseEditor,
55+
// // ...editorState
56+
// // },
57+
// // } = state;
58+
// // console.log(state);
59+
// // return {
60+
// // editor: editorState,
61+
// // };
62+
// // },
63+
// }),
4064
),
4165
),
4266
);

0 commit comments

Comments
 (0)