Custom GraphQL Queries

Introduction

Indico provides the ability to submit a custom GraphQL query. This is a powerful tool for creating mutations, which modify data, and queries, which retrieve data, that are tailor-made for a specific need or usecase. You can learn more about GraphQL here.

For both mutations and queries, there is one SDK call to build your own.

Example

from indico import IndicoClient, IndicoConfig                                                                                                                                                                      
from indico.queries import GraphQLRequest                                                                                                                                                                          
                                                                                                                                                                                                                   
HOST = 'mycluster.indico.io'                                                                                                                                                                     
TOKEN= "./indico_api_token.txt"                                                                                                                                                                                    
my_config = IndicoConfig(                                                                                                                                                                                          
    host=HOST, api_token_path=TOKEN                                                                                                                                                                                
)                                                                                                                                                                                                                  
client = IndicoClient(config=my_config)                                                                                                                                                                            
                                                                                                                                                                                                                   
QUERY = """                                                                                                                                                                                                        
query MyCustomQuery($id: Int) {                                                                                                                                                                                          
  dataset(id: $id) {                                                                                                                                                                                               
    id                                                                                                                                                                                                             
    labelsets {                                                                                                                                                                                                    
      name                                                                                                                                                                                                         
    }                                                                                                                                                                                                              
    fileTypes                                                                                                                                                                                                      
  }                                                                                                                                                                                                                
}                                                                                                                                                                                                                  
"""                                                                                                                                                                                                                
                                                                                                                                                                                                                   
variables= {                                                                                                                                                                                                       
    "id": 215                                                                                                                                                                                                      
}                                                                                                                                                                                                                  

request = GraphQLRequest(query=QUERY, variables=variables)
response = client.call(request)                                                                                                                                           
                                                                                                                                                                                                                   
print(response)   

You can use the GraphiQL explorer to help build custom queries and mutations.