GraphQL is a modern query language that allows you to define the data structure of your queries and ask for exactly what you want and nothing more.
GraphQL queries access not just the properties of one resource but also smoothly follow references between them. While typical REST APIs require loading from multiple URLs, GraphQL APIs get all the data your app needs in a single request.
Query: READ operations are performed by GraphQL queries, these do not change data.
Mutation: You will use mutations to perform all other operations to modify data.
Object types are sets of fields that are used to define the set of data you can query from the API.
query {
}
mutation {
}
Fields are used to ask for specific object properties.
Each object has fields that can be queried by name in order to query for the properties you need.
query {
EnjinToken {
id
}
}
You can determine the return value of a query by passing arguments to it. This narrows down the results and allows you to only get what you're after.
In the following example, the object is “token”, the requested field is “name”, the argument is “id”.
query GetToken($name: String) {
token: EnjinTokens(
name: $name
) {
id
}
}
Probably the most user-friendly feature of GraphQL is its visual interface, an in-browser tool for writing, validating, and testing GraphQL queries.
Before you query the API, it’s recommended to run your queries through the visual interface to make sure they are correct and the data being returned is the data you expect.
You can use the following GraphiQL web interfaces to interact with the Trusted Cloud:
You can also download the desktop version of GraphiQL to interact with the Trusted Cloud
Download for Windows: https://www.electronjs.org/apps/graphiql
Here are the endpoints to use within the desktop app:
Querying is the way to ask for data, it’s similar to the GET action in REST-based APIs.
Here is a list of the Enjin object types you can query through the API:
Mutating in GraphQL is the way to modify data, it is the term used to include all non-API functions other than GET. This includes functions such as PUT, POST, and DELETE that you may be familiar with from REST-based APIs.
Unlike querying, mutating requires adding all the arguments to the mutation. After it runs, you can query the values of the object after the mutation took place.
There are different types of Enjin object types that can be mutated through the API.
Here is a list of the Enjin object types that can be mutated:
You can find comprehensive information about what data can be queried and mutated using these Object Types in the GraphiQL Documentation Explorer.
To find it, go to the GraphiQL visual interface and click the "Docs" button in the top-right corner.
You may notice in our documetatation, we provide examples of our queries and mutations that you can use and they will often contain vairables within them. You can query these variables by simply passing through the data in the "Query Variables" section at the bottom of the page.
Simply slide up the bottom-bar (Query Variables) and begin inputting the variables and their respective data.