diff --git a/package-lock.json b/package-lock.json index 0f850aa913..269caebd51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4546,13 +4546,15 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4575,7 +4577,8 @@ "version": "0.0.1", "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", @@ -4742,6 +4745,7 @@ "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } diff --git a/packages/insomnia-app/app/models/settings.js b/packages/insomnia-app/app/models/settings.js index 32896b4599..1a7b7a7a2e 100644 --- a/packages/insomnia-app/app/models/settings.js +++ b/packages/insomnia-app/app/models/settings.js @@ -27,6 +27,7 @@ type BaseSettings = { deviceId: string | null, updateChannel: string, updateAutomatically: boolean, + disableUpdateNotification: boolean, environmentHighlightColorStyle: string, fontMonospace: string | null, fontInterface: string | null, @@ -66,6 +67,7 @@ export function init(): BaseSettings { deviceId: null, updateChannel: UPDATE_CHANNEL_STABLE, updateAutomatically: true, + disableUpdateNotification: false, environmentHighlightColorStyle: 'sidebar-indicator', fontMonospace: null, fontInterface: null, 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 28a5ef4252..873c46d877 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 @@ -1,6 +1,5 @@ // @flow -import type { Request } from '../../../../models/request'; -import { newBodyRaw } from '../../../../models/request'; +import classnames from 'classnames'; import * as React from 'react'; import autobind from 'autobind-decorator'; import { markdownToHTML } from '../../../../common/markdown-to-html'; @@ -21,8 +20,11 @@ import TimeFromNow from '../../time-from-now'; import * as models from '../../../../models/index'; import * as db from '../../../../common/database'; import { showModal } from '../../modals'; +import type { Request } from '../../../../models/request'; +import { newBodyRaw } from '../../../../models/request'; import ResponseDebugModal from '../../modals/response-debug-modal'; import Tooltip from '../../tooltip'; +import { Dropdown, DropdownButton, DropdownDivider, DropdownItem } from '../../base/dropdown'; type GraphQLBody = { query: string, @@ -56,7 +58,8 @@ type State = { schemaIsFetching: boolean, hideSchemaFetchErrors: boolean, variablesSyntaxError: string, - forceRefreshKey: number + forceRefreshKey: number, + automaticFetch: boolean }; @autobind @@ -74,6 +77,14 @@ class GraphQLEditor extends React.PureComponent { this._queryEditor = null; this._isMounted = false; const body = GraphQLEditor._stringToGraphQL(props.content); + + let automaticFetch; + try { + automaticFetch = JSON.parse(window.localStorage.getItem('graphql.automaticFetch')); + } catch (err) { + automaticFetch = true; + } + this.state = { body, schema: null, @@ -82,7 +93,8 @@ class GraphQLEditor extends React.PureComponent { schemaIsFetching: false, hideSchemaFetchErrors: false, variablesSyntaxError: '', - forceRefreshKey: 0 + forceRefreshKey: 0, + automaticFetch }; } @@ -235,6 +247,7 @@ class GraphQLEditor extends React.PureComponent { }) ); + console.log('FETCH SCHEMA'); responsePatch = await network.send(introspectionRequest._id, environmentId); const bodyBuffer = models.response.getBodyBuffer(responsePatch); @@ -306,6 +319,12 @@ class GraphQLEditor extends React.PureComponent { await this._fetchAndSetSchema(this.props.request); } + async _handleToggleAutomaticFetching(): Promise { + const automaticFetch = !this.state.automaticFetch; + this.setState({ automaticFetch }); + window.localStorage.setItem('graphql.automaticFetch', automaticFetch); + } + _handlePrettify() { const { body, forceRefreshKey } = this.state; const { variables, query } = body; @@ -399,7 +418,7 @@ class GraphQLEditor extends React.PureComponent { } componentWillReceiveProps(nextProps: Props) { - if (nextProps.request.modified !== this.props.request.modified) { + if (this.state.automaticFetch && nextProps.request.url !== this.props.request.url) { clearTimeout(this._schemaFetchTimeout); this._schemaFetchTimeout = setTimeout(async () => { await this._fetchAndSetSchema(nextProps.request); @@ -455,7 +474,8 @@ class GraphQLEditor extends React.PureComponent { hideSchemaFetchErrors, variablesSyntaxError, forceRefreshKey, - schemaIsFetching + schemaIsFetching, + automaticFetch } = this.state; const { query, variables: variablesObject } = GraphQLEditor._stringToGraphQL(content); @@ -466,6 +486,25 @@ class GraphQLEditor extends React.PureComponent { return (
+ + + schema + + GraphQL Schema + + Refresh Schema + + + {' '} + Automatic Fetch + Automatically fetch schema when request URL is modified + +
{ )}
-
- {this.renderSchemaFetchMessage()} - {!schemaIsFetching && ( - - )} -
+ {this.renderSchemaFetchMessage()}
{this.renderSelectedOperationName()}

- Query Variables{' '} - + Query Variables + Variables to use in GraphQL query
(JSON format)
{variablesSyntaxError && ( diff --git a/packages/insomnia-app/app/ui/components/settings/general.js b/packages/insomnia-app/app/ui/components/settings/general.js index d533e26847..f818e7318d 100644 --- a/packages/insomnia-app/app/ui/components/settings/general.js +++ b/packages/insomnia-app/app/ui/components/settings/general.js @@ -458,6 +458,17 @@ class General extends React.PureComponent { />

+
+ +