Skip to content

Commit

Permalink
works around emptystring with truthy check instead of 'null' fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitropoulos committed Jun 7, 2022
1 parent bdbd079 commit b41a223
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -482,7 +482,7 @@ export class GraphQLEditor extends PureComponent<Props, State> {
tabWidth: editorIndentSize,
});

const indentChars = (editorIndentWithTabs) ? '\t' : ' '.repeat(editorIndentSize);
const indentChars = editorIndentWithTabs ? '\t' : ' '.repeat(editorIndentSize);
const prettyVariables = jsonPrettify(variables, indentChars);

this._handleBodyChange(prettyQuery, prettyVariables, this.state.body.operationName);
Expand Down Expand Up @@ -563,7 +563,9 @@ export class GraphQLEditor extends PureComponent<Props, State> {
_handleVariablesChange(variables: string) {
try {
this._handleBodyChange(this.state.body.query, variables, this.state.body.operationName);
JSON.parse(variables || 'null');
if (variables) {
JSON.parse(variables);
}
} catch (err) {
this.setState({
variablesSyntaxError: err.message,
Expand Down

0 comments on commit b41a223

Please sign in to comment.