Skip to content

Commit

Permalink
Only notify when URL is changed. Closes #177.
Browse files Browse the repository at this point in the history
Wrap buildClientSchema in try..catch. Closes #178.
  • Loading branch information
imolorhe committed Nov 26, 2017
1 parent 2e6ed87 commit 8a3c56d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/app/containers/window/window.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ export class WindowComponent implements OnInit {

setApiUrl() {
const url = this.urlInput.nativeElement.value;
this.store.dispatch(new queryActions.SetUrlAction(url, this.windowId));
this.store.dispatch(new queryActions.SendIntrospectionQueryRequestAction(this.windowId));
if (url !== this.apiUrl) {
this.store.dispatch(new queryActions.SetUrlAction(url, this.windowId));
this.store.dispatch(new queryActions.SendIntrospectionQueryRequestAction(this.windowId));
}
}

sendRequest() {
Expand Down
17 changes: 11 additions & 6 deletions src/app/services/gql.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,19 @@ export class GqlService {
}

getIntrospectionSchema(data) {
if (data && data.__schema) {
const schema = buildClientSchema(data);
try {
if (data && data.__schema) {
const schema = buildClientSchema(data);

// One type => many fields
// One field => One type
return schema;
// One type => many fields
// One field => One type
return schema;
}
return null;
} catch(err) {
console.error('Bad introspection data.');
return null;
}
return null;
}

/**
Expand Down

0 comments on commit 8a3c56d

Please sign in to comment.