MCPcopy
hub / github.com/graphql/graphiql / useMergeQuery

Function useMergeQuery

packages/graphiql-react/src/editor/hooks.ts:201–219  ·  view source on GitHub ↗
({ caller }: UseMergeQueryArgs = {})

Source from the content-addressed store, hash-verified

199};
200
201export function useMergeQuery({ caller }: UseMergeQueryArgs = {}) {
202 const { queryEditor } = useEditorContext({
203 nonNull: true,
204 caller: caller || _useMergeQuery,
205 });
206 const { schema } = useSchemaContext({
207 nonNull: true,
208 caller: _useMergeQuery,
209 });
210 return () => {
211 const documentAST = queryEditor?.documentAST;
212 const query = queryEditor?.getValue();
213 if (!documentAST || !query) {
214 return;
215 }
216
217 queryEditor.setValue(print(mergeAst(documentAST, schema)));
218 };
219}
220
221export type UsePrettifyEditorsArgs = {
222 /**

Callers 4

useHeaderEditorFunction · 0.90
useVariableEditorFunction · 0.90
useQueryEditorFunction · 0.90
GraphiQLToolbarFunction · 0.90

Calls 2

mergeAstFunction · 0.90
useEditorContextFunction · 0.85

Tested by

no test coverage detected