Skip to content

Commit

Permalink
Addresses #132. Restricts the add query functionality depth level to 2
Browse files Browse the repository at this point in the history
for now.
Should try to increase it a little more for the user.
Another approach would be to make a decision on the depth level based on
the size of the search index.
  • Loading branch information
Samuel Imolorhe committed Nov 7, 2017
1 parent b4fee60 commit 649510e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Expand Up @@ -7,6 +7,8 @@ import {
SimpleChanges
} from '@angular/core';

import config from '../../../config';

@Component({
selector: 'app-doc-viewer',
templateUrl: './doc-viewer.component.html',
Expand Down Expand Up @@ -335,7 +337,12 @@ export class DocViewerComponent implements OnChanges {

// Don't add a field if it has been added in the query already.
// This happens when there is a recursive field
if (parentFields.filter(x => x.name === name && x.type === curTypeName).length) {
if (parentFields.filter(x => x.type === curTypeName).length) {
return { query: '', meta: {} };
}

// Stop adding new fields once the specified level depth limit is reached
if (level >= config.add_query_depth_limit) {
return { query: '', meta: {} };
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/config.ts
@@ -1,3 +1,4 @@
export default {
ga: 'UA-41432833-6'
ga: 'UA-41432833-6',
add_query_depth_limit: 3
};
10 changes: 3 additions & 7 deletions src/app/containers/window/window.component.ts
Expand Up @@ -18,8 +18,7 @@ import * as variableActions from '../../actions/variables/variables';
import * as dialogsActions from '../../actions/dialogs/dialogs';
import * as docsActions from '../../actions/docs/docs';

import { QueryService } from '../../services/query.service';
import { GqlService } from '../../services/gql.service';
import { QueryService, GqlService, NotifyService } from '../../services';
import { graphql } from 'graphql';

@Component({
Expand Down Expand Up @@ -66,6 +65,7 @@ export class WindowComponent implements OnInit {
constructor(
private queryService: QueryService,
private gql: GqlService,
private notifyService: NotifyService,
private store: Store<any>,
private toastr: ToastsManager,
private vRef: ViewContainerRef
Expand Down Expand Up @@ -183,11 +183,7 @@ export class WindowComponent implements OnInit {

// If the query has args
if (queryData.meta.hasArgs) {
const opts = {
message: 'Fill in the arguments for the query!',
success: false
};
this.store.dispatch(new queryActions.ShowEditorAlertAction(opts, this.windowId));
this.notifyService.warning('Fill in the arguments for the query!');
}
}

Expand Down

0 comments on commit 649510e

Please sign in to comment.