From 5c3a8a80e399e33017dd9750b3426649bd17ad9b Mon Sep 17 00:00:00 2001 From: abgeorge7 Date: Fri, 7 Dec 2018 16:14:52 -0600 Subject: [PATCH 1/2] fix graphiql bugs --- src/GraphQLEditor/GqlEditor.jsx | 45 +++++++++++++++++++++++--------- src/GraphQLEditor/GqlEditor.less | 2 +- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/GraphQLEditor/GqlEditor.jsx b/src/GraphQLEditor/GqlEditor.jsx index 4c74da1094..0ece956be8 100644 --- a/src/GraphQLEditor/GqlEditor.jsx +++ b/src/GraphQLEditor/GqlEditor.jsx @@ -9,15 +9,22 @@ import { config } from '../params'; import './GqlEditor.less'; const parameters = {}; +const defaultValue = config.arrangerConfig ? 1 : 0; class GqlEditor extends React.Component { constructor(props) { super(props); this.state = { - selectedEndpointIndex: props.endpointIndex || 0, + selectedEndpointIndex: props.endpointIndex, }; } + componentDidMount() { + if (this.props.endpointIndex && this.state.selectedEndpointIndex !== this.props.endpointIndex) { + this.selectEndpoint(this.props.endpointIndex); + } + } + getOtherIndex = index => +!index // will either return 0 or 1 @@ -54,9 +61,10 @@ class GqlEditor extends React.Component { } // If provided endpoint is not 0 or 1, default to 0 (graph model) - const index = this.state.selectedEndpointIndex < options.length ? - this.state.selectedEndpointIndex - : 0; + const index = this.state.selectedEndpointIndex !== null && + this.state.selectedEndpointIndex < options.length ? + this.state.selectedEndpointIndex + : defaultValue; return (
@@ -74,14 +82,25 @@ class GqlEditor extends React.Component { ) : null }
- + { + index === 0 ? + + : + + } ); } @@ -94,7 +113,7 @@ GqlEditor.propTypes = { }; GqlEditor.defaultProps = { - endpointIndex: 0, + endpointIndex: defaultValue, }; export default GqlEditor; diff --git a/src/GraphQLEditor/GqlEditor.less b/src/GraphQLEditor/GqlEditor.less index f0a2e6fcae..e26467170f 100644 --- a/src/GraphQLEditor/GqlEditor.less +++ b/src/GraphQLEditor/GqlEditor.less @@ -16,7 +16,7 @@ } .gql-editor .graphiql-container { - height: calc(~"100vh - 181px - 80px"); + height: calc(~"100vh - 191px - 80px"); } .gql-editor__button { From 619ab649c0486adb8f0d90853889db75521dc5cd Mon Sep 17 00:00:00 2001 From: abgeorge7 Date: Fri, 7 Dec 2018 16:15:22 -0600 Subject: [PATCH 2/2] linting --- src/GraphQLEditor/GqlEditor.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GraphQLEditor/GqlEditor.jsx b/src/GraphQLEditor/GqlEditor.jsx index 0ece956be8..dd504d5c88 100644 --- a/src/GraphQLEditor/GqlEditor.jsx +++ b/src/GraphQLEditor/GqlEditor.jsx @@ -63,8 +63,8 @@ class GqlEditor extends React.Component { // If provided endpoint is not 0 or 1, default to 0 (graph model) const index = this.state.selectedEndpointIndex !== null && this.state.selectedEndpointIndex < options.length ? - this.state.selectedEndpointIndex - : defaultValue; + this.state.selectedEndpointIndex + : defaultValue; return (
@@ -100,7 +100,7 @@ class GqlEditor extends React.Component { onEditQuery={editQuery} onEditVariables={editVariables} /> - } + }
); }