Enjin Platform API Requests
Understanding Enjin Platform API Requests
In the context of the Enjin Platform, by using GraphQL, developers are able to create, mint, transfer and fetch information on FTs and NFTs created using the platform without needing to interact with any back-end information from the blockchain.
As an example, we are going to display one Query and one Mutation that is used by the Enjin Platform
Query - with this specific query, we are able to perform a READ operation on the Enjin Database in order to retrieve information pertaining to a specific project, all queries must contain an object, fields, and arguments.
query{
GetProject {
id
name
description
image
createdAt
updatedAt
}
}
Response - In the response field, we can see that the
GetProject
query returned the Id of the project, the name, description, and the image attached to the project itself.{
"data": {
"GetProject": {
"id": 2912,
"name": "Esther Project 1",
"description": "QA Testing Project for Esther",
"image": "<project-image>"
}
}
}
Mutation - Just like in queries, if the mutation field returns an object type, you can ask for nested fields. This can be useful for fetching the new state of an object after an update. Let's look at a simple example of a mutation.
mutation {
Message(
message: "This is a Test"
wallet: "0x7AEAB7C231c88611a2ad434d3A2715Ab3C91F406"
) {
type
value
state
}
}
Response - with this mutation, we are sending a request to the platform to sign a message through the blockchain, which still needs to get approved by the wallet in order to change the information requested by us.
"Message": {
"type": "MESSAGE",
"value": "0",
"state": "PENDING"
}
}
}