diff --git a/console/src/components/ApiExplorer/Actions.js b/console/src/components/ApiExplorer/Actions.js index d04be9e6bf3b4..99cfd95b874cd 100644 --- a/console/src/components/ApiExplorer/Actions.js +++ b/console/src/components/ApiExplorer/Actions.js @@ -398,6 +398,12 @@ const getStateAfterClearingHistory = state => { }; }; +const getRemoteQueries = (queryUrl, cb) => { + fetch(queryUrl) + .then(resp => resp.text().then(cb)) + .catch(e => console.log('Invalid query URL: ', e)); +}; + const apiExplorerReducer = (state = defaultState, action) => { switch (action.type) { case CHANGE_TAB: @@ -625,4 +631,5 @@ export { createWsClient, focusHeaderTextbox, unfocusTypingHeader, + getRemoteQueries, }; diff --git a/console/src/components/ApiExplorer/ApiExplorer.js b/console/src/components/ApiExplorer/ApiExplorer.js index 0347b4129bf50..cf77b1e4972d3 100644 --- a/console/src/components/ApiExplorer/ApiExplorer.js +++ b/console/src/components/ApiExplorer/ApiExplorer.js @@ -67,6 +67,7 @@ class ApiExplorer extends Component { dataHeaders={this.props.dataHeaders} numberOfTables={this.props.tables.length} headerFocus={this.props.headerFocus} + queryParams={this.props.location.query} /> ); @@ -86,6 +87,7 @@ ApiExplorer.propTypes = { route: PropTypes.object.isRequired, tables: PropTypes.array.isRequierd, headerFocus: PropTypes.bool.isRequired, + location: PropTypes.object.isRequired, }; export default ApiExplorer; diff --git a/console/src/components/ApiExplorer/ApiRequest.js b/console/src/components/ApiExplorer/ApiRequest.js index dea09b29fd8bb..0d012b6023529 100644 --- a/console/src/components/ApiExplorer/ApiRequest.js +++ b/console/src/components/ApiExplorer/ApiRequest.js @@ -349,6 +349,7 @@ class ApiRequest extends Component { numberOfTables={this.props.numberOfTables} dispatch={this.props.dispatch} headerFocus={this.props.headerFocus} + queryParams={this.props.queryParams} /> ); default: @@ -395,6 +396,7 @@ ApiRequest.propTypes = { route: PropTypes.object.isRequired, numberOfTables: PropTypes.number.isRequired, headerFocus: PropTypes.bool.isRequired, + queryParams: PropTypes.object.isRequired, }; export default ApiRequest; diff --git a/console/src/components/ApiExplorer/ApiRequestWrapper.js b/console/src/components/ApiExplorer/ApiRequestWrapper.js index 7f31d028adb10..fcf6afd884f2c 100644 --- a/console/src/components/ApiExplorer/ApiRequestWrapper.js +++ b/console/src/components/ApiExplorer/ApiRequestWrapper.js @@ -40,6 +40,7 @@ class ApiRequestWrapper extends Component { dataHeaders={this.props.dataHeaders} numberOfTables={this.props.numberOfTables} headerFocus={this.props.headerFocus} + queryParams={this.props.queryParams} /> {this.props.request.bodyType !== 'graphql' ? ( + this.setState({ ...this.state, queries }) + ); + } } shouldComponentUpdate(nextProps) { @@ -40,7 +47,13 @@ class GraphiQLWrapper extends Component { ); if (!this.state.error && this.props.numberOfTables !== 0) { - content = ; + if (this.state.queries) { + content = ( + + ); + } else { + content = ; + } } else if (this.props.numberOfTables === 0) { content = (