Example Mutation

A breakdown of an example GraphQL mutation in inabit

GraphQL Mutation: Create Withdrawal

Mutations in GraphQL are operations used to modify data on the server. This example demonstrates how to create a withdrawal request.

Operation Name:

The operation is named CreateWithdrawal.

Operations:

1. Query to Retrieve Necessary Information:

query GetWalletAndBlockchainID {
  wallet(id: "clol7o576002oaz011mmtnvru") {
    id
  }
  financialAsset(id: "clefn78gv011olc6rcwtt0wel") {
    id
  }
  blockchain(id: "clefn78em00mslc6r3lzf3h5a") {
    id
  }
}

This query fetches the IDs of the wallet, financial asset, and blockchain associated with the withdrawal. These IDs are required for creating the withdrawal request.

2. Mutation to Create Withdrawal:

mutation CreateWithdrawal($data: WithdrawalCreateInput!, $jwtToken: String!) {
  createWithdrawal(data: $data, jwtToken: $jwtToken) {
    id
  }
}

Variables:

{
  "data": {
    "wallet": {
      "id": "clol7o576002oaz011mmtnvru"
    },
    "financialAsset": {
      "id": "clefn78gv011olc6rcwtt0wel"
    },
    "address": "0x7582f3483116105e0b7845ac1a0df5eb0c8cd062",
    "amount": 5,
    "blockchain": {
      "id": "clefn78em00mslc6r3lzf3h5a"
    },
    "note": "",
    "priority": "Medium"
  },
  "jwtToken": "***[accessToken from login response]***"
}

Explanation:

The process begins with a query to retrieve the IDs of the wallet, financial asset, and blockchain related to the withdrawal. These IDs are then passed as variables along with other necessary details (such as withdrawal amount, destination address, and priority level) to the mutation CreateWithdrawal. The mutation creates the withdrawal request using the provided data and the authorization token (jwtToken).

Response:

Upon successful execution of the mutation, the response contains the ID of the created withdrawal request.

Last updated