diff --git a/packages/insomnia-app/app/ui/components/editors/body/graph-ql-editor.js b/packages/insomnia-app/app/ui/components/editors/body/graph-ql-editor.js index b18b1049d..599cdf5dd 100644 --- a/packages/insomnia-app/app/ui/components/editors/body/graph-ql-editor.js +++ b/packages/insomnia-app/app/ui/components/editors/body/graph-ql-editor.js @@ -58,7 +58,6 @@ type State = { schemaIsFetching: boolean, hideSchemaFetchErrors: boolean, variablesSyntaxError: string, - forceRefreshKey: number, automaticFetch: boolean }; @@ -93,7 +92,6 @@ class GraphQLEditor extends React.PureComponent { schemaIsFetching: false, hideSchemaFetchErrors: false, variablesSyntaxError: '', - forceRefreshKey: 0, automaticFetch }; } @@ -288,7 +286,7 @@ class GraphQLEditor extends React.PureComponent { } } - _buildVariableTypes(schema: Object | null, query: string): { [string]: Object } { + _buildVariableTypes(schema: Object | null): { [string]: Object } { if (!schema) { return {}; } @@ -326,14 +324,16 @@ class GraphQLEditor extends React.PureComponent { } _handlePrettify() { - const { body, forceRefreshKey } = this.state; + const { body } = this.state; const { variables, query } = body; const prettyQuery = query && print(parse(query)); const prettyVariables = variables && JSON.parse(prettify.json(JSON.stringify(variables))); this._handleBodyChange(prettyQuery, prettyVariables, this.state.body.operationName); - setTimeout(() => { - this.setState({ forceRefreshKey: forceRefreshKey + 1 }); - }, 200); + + // Update editor contents + if (this._queryEditor) { + this._queryEditor.setValue(prettyQuery); + } } _getOperations() { @@ -481,7 +481,6 @@ class GraphQLEditor extends React.PureComponent { schemaFetchError, hideSchemaFetchErrors, variablesSyntaxError, - forceRefreshKey, schemaIsFetching, automaticFetch } = this.state; @@ -490,10 +489,10 @@ class GraphQLEditor extends React.PureComponent { const variables = prettify.json(JSON.stringify(variablesObject)); - const variableTypes = this._buildVariableTypes(schema, query); + const variableTypes = this._buildVariableTypes(schema); return ( -
+
schema diff --git a/packages/insomnia-app/flow-typed/codemirror.js b/packages/insomnia-app/flow-typed/codemirror.js index 3d10999f5..fa916feba 100644 --- a/packages/insomnia-app/flow-typed/codemirror.js +++ b/packages/insomnia-app/flow-typed/codemirror.js @@ -25,6 +25,7 @@ declare module 'codemirror' { doc: Doc; getCursor(): Pos; getValue(): string; + setValue(string): void; hasFocus(): boolean; indexFromPos(pos: Pos): number; }