Skip to content

Commit 1d6bef7

Browse files
committed
Add getVariableEditor() and refresh()
Closes #152 This adds two new public API methods to the `<GraphiQL>` component. `getVariableEditor()` gets the CodeMirror instance for editing variables. `refresh()` will refresh all CodeMirror instances, this may be helpful after changing the size of the containing element or after making it visible for the first time.
1 parent 790e242 commit 1d6bef7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/components/GraphiQL.js

+20
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,26 @@ export class GraphiQL extends React.Component {
341341
return this.queryEditorComponent.getCodeMirror();
342342
}
343343

344+
/**
345+
* Get the variable editor CodeMirror instance.
346+
*
347+
* @public
348+
*/
349+
getVariableEditor() {
350+
return this.variableEditorComponent.getCodeMirror();
351+
}
352+
353+
/**
354+
* Refresh all CodeMirror instances.
355+
*
356+
* @public
357+
*/
358+
refresh() {
359+
this.queryEditorComponent.getCodeMirror().refresh();
360+
this.variableEditorComponent.getCodeMirror().refresh();
361+
this.resultComponent.getCodeMirror().refresh();
362+
}
363+
344364
/**
345365
* Inspect the query, automatically filling in selection sets for non-leaf
346366
* fields which do not yet have them.

0 commit comments

Comments
 (0)