đŸŒĒī¸Variables

Learn how you can add variables to an Airstack GraphQL query to provide dynamic inputs into the API.

You can add variables to an Airstack GraphQL query to provide dynamic inputs.

To do so, simply define the variable with $ prefix and specify the correct typing.

As an example, below is shown on how a query looks like after and before adding variable to an Airstack query:

query MyQuery($tokenAddress: Address) { # Define variable on the top level with the correct typing
  TokenBalances(
    input: {
      filter: {
        tokenAddress: {
          _eq: $tokenAddress # Variable as an input
        }
      },
      blockchain: ethereum
    }
  ) {
    TokenBalance {
      owner {
        addresses
        domains {
          isPrimary
          name
        }
        socials {
          dappName
          profileName
        }
        xmtp {
          isXMTPEnabled
        }
      }
    }
  }
}

Developer Support

If you have any questions or need help regarding adding variables into your Airstack query, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?