1
+ /* eslint-disable @typescript-eslint/no-deprecated */
2
+
1
3
import { useGraphiQL , useGraphiQLActions } from './components' ;
2
4
import { pick } from './utility' ;
5
+ import type { MonacoEditor } from './types' ;
3
6
4
7
/**
5
8
* @deprecated Use `const { prettifyEditors } = useGraphiQLActions()` instead.
@@ -25,13 +28,66 @@ export function useMergeQuery() {
25
28
return mergeQuery ;
26
29
}
27
30
31
+ /**
32
+ * @deprecated Use `useGraphiQLActions` and `useGraphiQL` hooks instead.
33
+ */
34
+ export function useEditorContext ( ) {
35
+ const {
36
+ addTab,
37
+ changeTab,
38
+ moveTab,
39
+ closeTab,
40
+ updateActiveTabValues,
41
+ setEditor,
42
+ setOperationName,
43
+ setShouldPersistHeaders,
44
+ } = useGraphiQLActions ( ) ;
45
+
46
+ const setHeaderEditor = ( headerEditor : MonacoEditor ) =>
47
+ setEditor ( { headerEditor } ) ;
48
+ const setQueryEditor = ( queryEditor : MonacoEditor ) =>
49
+ setEditor ( { queryEditor } ) ;
50
+ const setResponseEditor = ( responseEditor : MonacoEditor ) =>
51
+ setEditor ( { responseEditor } ) ;
52
+ const setVariableEditor = ( variableEditor : MonacoEditor ) =>
53
+ setEditor ( { variableEditor } ) ;
54
+
55
+ const values = useGraphiQL (
56
+ pick (
57
+ 'headerEditor' ,
58
+ 'queryEditor' ,
59
+ 'responseEditor' ,
60
+ 'variableEditor' ,
61
+ 'initialHeaders' ,
62
+ 'initialQuery' ,
63
+ 'initialVariables' ,
64
+ 'externalFragments' ,
65
+ 'shouldPersistHeaders' ,
66
+ ) ,
67
+ ) ;
68
+ return {
69
+ addTab,
70
+ changeTab,
71
+ moveTab,
72
+ closeTab,
73
+ updateActiveTabValues,
74
+ setHeaderEditor,
75
+ setQueryEditor,
76
+ setResponseEditor,
77
+ setVariableEditor,
78
+ setOperationName,
79
+ setShouldPersistHeaders,
80
+ ...values ,
81
+ } ;
82
+ }
83
+
28
84
/**
29
85
* @deprecated Use `useGraphiQLActions` and `useGraphiQL` hooks instead.
30
86
*/
31
87
export function useExecutionContext ( ) {
32
88
const { run, stop } = useGraphiQLActions ( ) ;
33
89
const values = useGraphiQL ( state => ( {
34
- isFetching : state . isIntrospecting ,
90
+ isFetching : state . isFetching ,
35
91
isSubscribed : Boolean ( state . subscription ) ,
36
92
operationName : state . operationName ,
37
93
} ) ) ;
@@ -59,9 +115,12 @@ export function usePluginContext() {
59
115
*/
60
116
export function useSchemaContext ( ) {
61
117
const { introspect } = useGraphiQLActions ( ) ;
62
- const values = useGraphiQL (
63
- pick ( 'fetchError' , 'isFetching' , 'schema' , 'validationErrors' ) ,
64
- ) ;
118
+ const values = useGraphiQL ( state => ( {
119
+ isFetching : state . isIntrospecting ,
120
+ fetchError : state . fetchError ,
121
+ schema : state . schema ,
122
+ validationErrors : state . validationErrors ,
123
+ } ) ) ;
65
124
return {
66
125
introspect,
67
126
...values ,
@@ -76,7 +135,7 @@ export const useStorage = () => useGraphiQL(state => state.storage);
76
135
/**
77
136
* @deprecated Use `const storage = useGraphiQL(state => state.storage)` instead.
78
137
*/
79
- export const useStorageContext = useStorage ; // eslint-disable-line @typescript-eslint/no-deprecated
138
+ export const useStorageContext = useStorage ;
80
139
81
140
/**
82
141
* @deprecated Use `useGraphiQLActions` and `useGraphiQL` hooks instead.
@@ -89,3 +148,23 @@ export function useTheme() {
89
148
theme,
90
149
} ;
91
150
}
151
+
152
+ /**
153
+ * @deprecated Use `useGraphiQLActions` and `useGraphiQL` hooks instead.
154
+ */
155
+ export const useEditorStore = useEditorContext ;
156
+
157
+ /**
158
+ * @deprecated Use `useGraphiQLActions` and `useGraphiQL` hooks instead.
159
+ */
160
+ export const useExecutionStore = useExecutionContext ;
161
+
162
+ /**
163
+ * @deprecated Use `useGraphiQLActions` and `useGraphiQL` hooks instead.
164
+ */
165
+ export const usePluginStore = usePluginContext ;
166
+
167
+ /**
168
+ * @deprecated Use `useGraphiQLActions` and `useGraphiQL` hooks instead.
169
+ */
170
+ export const useSchemaStore = useSchemaContext ;
0 commit comments