While each Modus SDK offers similar capabilities, the APIs and usage may vary between languages.Modus GraphQL APIs documentation is available on the following pages:
- AssemblyScript GraphQL APIs(this page)
- Go GraphQL APIs
Import
To begin, import thegraphql namespace from the SDK:
GraphQL APIs
The APIs in thegraphql namespace are below, organized by category.
Functions
execute
Execute a GraphQL statement to call a query or apply mutation against a GraphQL endpoint.Type of object to use for the data returned from the query. This can be any
type, including a custom type defined in your project. It should match the shape
of the data returned from the GraphQL query.
Name of the connection, as defined in the
manifest.
GraphQL statement containing the query or mutation operation to execute.
Optional variables to include with the query.See the details of the
Variables object for more information.Types
Variables
A container for variables to include with a GraphQL operation. To use this feature, create a newVariables object and call the set method
for each variable you want to include. Then pass the object to the execute
function.
set(name, value)
Set a variable with a name and value to include with the GraphQL operation.
Serializes the variables to a JSON string for inclusion in the GraphQL
operation. The
execute function calls this automatically when you pass a
Variables object. You typically don’t need to call it directly.Response
A response object from the GraphQL query. Eithererrors or data is present, depending on the result of the query.
An array of errors incurred as part of your GraphQL request, if any.Each error in the array is an
ErrorResult object. If there are
no errors, this field is null.The resulting data selected by the GraphQL operation.The data has the type specified in the call to the
execute function. If data
is absent due to errors, this field is null.ErrorResult
The details of an error incurred as part of a GraphQL operation.Description of the error incurred.
An array of
CodeLocation objects that point to the specific
location of the error in the GraphQL statement.Path to the area of the GraphQL statement related to the error.Each item in the array represents a segment of the path.
CodeLocation
The location of specific code within a GraphQL statement.Line number within the GraphQL statement for the code.
Column number within the GraphQL statement for the code.