@@ -42,7 +42,7 @@ import { Subject } from 'rxjs/Subject';
42
42
43
43
export class QueryTreeNode {
44
44
public id : number ;
45
- public fieldName : string = null ;
45
+ public fieldName : string ;
46
46
public alias : string ;
47
47
public ast : FieldNode ;
48
48
public isList = false ;
@@ -58,7 +58,6 @@ export class QueryTreeNode {
58
58
public queryAdded : Subject < Query > = new Subject < Query > ( ) ;
59
59
public queryRemoved : Subject < Query > = new Subject < Query > ( ) ;
60
60
61
- // TODO: Compute directives.
62
61
public directives : DirectiveNode [ ] = [ ] ;
63
62
public args : { [ name : string ] : IVariableReference } ;
64
63
@@ -95,7 +94,7 @@ export class QueryTreeNode {
95
94
( < any > this . root ) . rootNodeMap [ this . id ] = this ;
96
95
97
96
if ( ast && ast . name ) {
98
- this . fieldName = ast . name . value ;
97
+ this . fieldName = ast . name . value || '' ;
99
98
}
100
99
101
100
if ( ! this . isRoot ) {
@@ -169,7 +168,7 @@ export class QueryTreeNode {
169
168
let fp = this . fullPath ;
170
169
let res : string [ ] = [ ] ;
171
170
for ( let nod of fp ) {
172
- let nam = nod . fieldName ;
171
+ let nam = nod . fieldName || '' ;
173
172
if ( ! nam ) {
174
173
continue ;
175
174
}
@@ -202,7 +201,7 @@ export class QueryTreeNode {
202
201
public buildRGQLTree ( includeChildren = false ) : IRGQLQueryTreeNode {
203
202
let result : IRGQLQueryTreeNode = {
204
203
id : this . id ,
205
- fieldName : this . fieldName ,
204
+ fieldName : this . fieldName || '' ,
206
205
directive : this . buildRGQLDirectives ( ) ,
207
206
} ;
208
207
if ( this . ast && this . ast . arguments ) {
@@ -448,7 +447,7 @@ export class QueryTreeNode {
448
447
if ( ! tchild . ast || tchild . ast . kind !== 'Field' ) {
449
448
continue ;
450
449
}
451
- let childName = tchild . alias || tchild . fieldName ;
450
+ let childName = tchild . alias || tchild . fieldName || '' ;
452
451
if ( childName === nodef . name . value ) {
453
452
// Alias required.
454
453
let ai = this . aliasCounter ++ ;
@@ -482,7 +481,6 @@ export class QueryTreeNode {
482
481
}
483
482
484
483
// Check if this is reasonably equivilent (same arguments, etc).
485
- // TODO: Simplify to use arguments array, remove this.ast completely
486
484
private matchesAst ( node : ASTNode ) : boolean {
487
485
if ( node . kind !== this . ast . kind ) {
488
486
return false ;
0 commit comments