Constructor
new SelectionSetBuilder(typeBundle, typeSchema, selections)
This constructor should not be invoked directly. SelectionSetBuilders are created when building queries/mutations.
Parameters:
| Name | Type | Description | 
|---|---|---|
typeBundle | 
            
            Object | A set of ES6 modules generated by graphql-js-schema.  | 
        
typeSchema | 
            
            Object | The schema object for the type of the current selection.  | 
        
selections | 
            
            Array.<Field> | The fields on the current selection.  | 
        
- Source:
 
Methods
add(selectionOrFieldName, optionsopt, callbackOrSelectionSetopt)
Adds a field to be queried on the current selection.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
selectionOrFieldName | 
            
            SelectionSet | String | The selection or name of the field to add.  | 
        |||||||||||||
options | 
            
            Object | 
                
                    <optional> | 
            
            
            Options on the query including: Properties
  | 
        ||||||||||||
callbackOrSelectionSet | 
            
            function | SelectionSet | 
                
                    <optional> | 
            
            
            Either a callback which will be used to create a new SelectionSet, or an existing SelectionSet.  | 
        
- Source:
 
Example
client.query((root) => {
  root.add('cat', {args: {id: '123456'}, alias: 'meow'}, (cat) => {
    cat.add('name');
  });
});
        
            
    
    
    addConnection(name, optionsopt, callbackOrSelectionSetopt)
Adds a connection to be queried on the current selection. This adds all the fields necessary for pagination.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name | 
            
            String | The name of the connection to add to the query.  | 
        |||||||||||||
options | 
            
            Object | 
                
                    <optional> | 
            
            
            Options on the query including: Properties
  | 
        ||||||||||||
callbackOrSelectionSet | 
            
            function | SelectionSet | 
                
                    <optional> | 
            
            
            Either a callback which will be used to create a new SelectionSet, or an existing SelectionSet.  | 
        
- Source:
 
Example
client.query((root) => {
  root.add('cat', (cat) => {
    cat.addConnection('friends', {args: {first: 10}, alias: 'coolCats'}, (friends) => {
      friends.add('name');
    });
  });
});
        
            
    
    
    addFragment(fragmentSpread)
Adds a fragment spread on the current selection.
Parameters:
| Name | Type | Description | 
|---|---|---|
fragmentSpread | 
            
            FragmentSpread | The fragment spread to add.  | 
        
- Source:
 
Example
client.query((root) => {
  root.addFragment(catFragmentSpread);
});
        
            
    
    
    addInlineFragmentOn(typeName, callbackOrSelectionSetopt)
Adds an inline fragment on the current selection.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
typeName | 
            
            String | The name of the type of the inline fragment.  | 
        |
callbackOrSelectionSet | 
            
            function | SelectionSet | 
                
                    <optional> | 
            
            
            Either a callback which will be used to create a new SelectionSet, or an existing SelectionSet.  | 
        
- Source:
 
Example
client.query((root) => {
  root.add('animal', (animal) => {
    animal.addInlineFragmentOn('cat', (cat) => {
      cat.add('name');
    });
  });
});