@@ -14,11 +14,11 @@ import {
14
14
createExecutionSlice ,
15
15
createPluginSlice ,
16
16
createSchemaSlice ,
17
+ EditorProps ,
18
+ ExecutionProps ,
19
+ PluginProps ,
20
+ SchemaProps ,
17
21
} from '../stores' ;
18
- import { EditorProps , PERSIST_HEADERS_STORAGE_KEY } from '../stores/editor' ;
19
- import { ExecutionProps } from '../stores/execution' ;
20
- import { PluginProps , STORAGE_KEY_VISIBLE_PLUGIN } from '../stores/plugin' ;
21
- import { SchemaProps } from '../stores/schema' ;
22
22
import { StorageStore , useStorage } from '../stores/storage' ;
23
23
import { ThemeStore } from '../stores/theme' ;
24
24
import { SlicesWithActions } from '../types' ;
@@ -30,10 +30,11 @@ import {
30
30
isSchema ,
31
31
validateSchema ,
32
32
} from 'graphql' ;
33
- import { DEFAULT_PRETTIFY_QUERY , DEFAULT_QUERY } from '../constants' ;
34
- import { STORAGE_KEY_QUERY } from './query-editor' ;
35
- import { STORAGE_KEY as STORAGE_KEY_VARIABLES } from './variable-editor' ;
36
- import { STORAGE_KEY as STORAGE_KEY_HEADERS } from './header-editor' ;
33
+ import {
34
+ DEFAULT_PRETTIFY_QUERY ,
35
+ DEFAULT_QUERY ,
36
+ STORAGE_KEY ,
37
+ } from '../constants' ;
37
38
import { getDefaultTabState } from '../utility/tabs' ;
38
39
39
40
interface InnerGraphiQLProviderProps
@@ -121,25 +122,25 @@ const InnerGraphiQLProvider: FC<InnerGraphiQLProviderProps> = ({
121
122
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- false positive
122
123
if ( storeRef . current === null ) {
123
124
function getInitialVisiblePlugin ( ) {
124
- const storedValue = storage . get ( STORAGE_KEY_VISIBLE_PLUGIN ) ;
125
+ const storedValue = storage . get ( STORAGE_KEY . visiblePlugin ) ;
125
126
const pluginForStoredValue = plugins . find (
126
127
plugin => plugin . title === storedValue ,
127
128
) ;
128
129
if ( pluginForStoredValue ) {
129
130
return pluginForStoredValue ;
130
131
}
131
132
if ( storedValue ) {
132
- storage . set ( STORAGE_KEY_VISIBLE_PLUGIN , '' ) ;
133
+ storage . set ( STORAGE_KEY . visiblePlugin , '' ) ;
133
134
}
134
135
return visiblePlugin ;
135
136
}
136
137
137
138
function getInitialState ( ) {
138
139
// We only need to compute it lazily during the initial render.
139
- const query = props . query ?? storage . get ( STORAGE_KEY_QUERY ) ?? null ;
140
+ const query = props . query ?? storage . get ( STORAGE_KEY . query ) ?? null ;
140
141
const variables =
141
- props . variables ?? storage . get ( STORAGE_KEY_VARIABLES ) ?? null ;
142
- const headers = props . headers ?? storage . get ( STORAGE_KEY_HEADERS ) ?? null ;
142
+ props . variables ?? storage . get ( STORAGE_KEY . variables ) ?? null ;
143
+ const headers = props . headers ?? storage . get ( STORAGE_KEY . headers ) ?? null ;
143
144
const response = props . response ?? '' ;
144
145
145
146
const { tabs, activeTabIndex } = getDefaultTabState ( {
@@ -152,11 +153,11 @@ const InnerGraphiQLProvider: FC<InnerGraphiQLProviderProps> = ({
152
153
variables,
153
154
} ) ;
154
155
155
- const isStored = storage . get ( PERSIST_HEADERS_STORAGE_KEY ) !== null ;
156
+ const isStored = storage . get ( STORAGE_KEY . persistHeaders ) !== null ;
156
157
157
158
const $shouldPersistHeaders =
158
159
shouldPersistHeaders !== false && isStored
159
- ? storage . get ( PERSIST_HEADERS_STORAGE_KEY ) === 'true'
160
+ ? storage . get ( STORAGE_KEY . persistHeaders ) === 'true'
160
161
: shouldPersistHeaders ;
161
162
162
163
const store = create < SlicesWithActions > ( ( ...args ) => {
0 commit comments