{dialog.object}graphQLQueryPromise Method
Syntax
var promise = {dialog.object}.graphQLQueryPromise(url, queryDefinition, variables, headers, queryParameters)
Arguments
- urlstring
The URL of the service (e.g. http://www.mygraphqlservice.com/northwind.a5svc)
- queryDefinitionstring
The string that defines the query
- variablesobject
An object that defines values for each of the query variables.
var variables = {"customerId":"BOLID"};- headersobject array
An array of objects. Each object in the array has a name and value property. Used when the service requires authentication using an api key that must be passed in the header of the request.
var headers = [ {"name":"apikey","value":"XXXXXXXXXXXXXXXXXXXX"}, {"name":"myHeader","value":"my header value"} ];- queryParametersstring
A string of name=value pairs. Used when the service requires authentication via an api key that must be passed as a query parameter.
Returns
- promisePromise
Returns a JavaScript Promise.
Description
Executes a GraphQL query and returns a promise.
Discussion
Example
var url = 'http://www.mygraphqlservice.com/northwind.a5svc';
var query = `
{
GetManyCustomers {
records {
CustomerID
ContactName
CompanyName
City
Country
}
}
}
`
{dialog.object}.graphQLQueryPromise(url,query,'','').then(data => {
var j = JSON.parse(data);
var lObj = {dialog.object}.getControl('list1')
lObj.populate(j.data.GetManyCustomers.records)
});This example uses Template literals.
See Also