Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GraphQL lint to editor component mount (Fixes #1507) #1822

Merged
merged 1 commit into from
Dec 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,15 @@ class GraphQLEditor extends React.PureComponent<Props, State> {
constructor(props: Props) {
super(props);
this._disabledOperationMarkers = [];
this._documentAST = null;
this._queryEditor = null;
this._isMounted = false;

const body = GraphQLEditor._stringToGraphQL(props.content);
try {
this._documentAST = parse(body.query);
} catch (e) {
this._documentAST = null;
}

let automaticFetch;
try {
Expand Down Expand Up @@ -484,6 +489,15 @@ class GraphQLEditor extends React.PureComponent<Props, State> {
this._isMounted = true;
(async () => {
await this._fetchAndSetSchema(this.props.request);

// When the schema request returns the editor should
// exist as the first render should have completed.
// We put this guard in place just incase.
if (this._queryEditor) {
// $ExpectError
await this._queryEditor.performLint();
this.forceUpdate();
}
})();
}

Expand Down