Skip to main content

Variables

Variables allow you to pass dynamic values to your queries and mutations, making them reusable.

Using variables

Define variables in your query and pass them separately:
Variables:

Variable types

GraphQL supports various variable types:
  • ID! - Required ID
  • String - Optional string
  • Int - Integer
  • Float - Floating point number
  • Boolean - True/false
  • Custom input types

Example with multiple variables

Variables:

Fragments

Fragments allow you to reuse field selections across multiple queries.

Basic fragment

Multiple fragments

You can use multiple fragments in a single query:

Selecting loan fields

Request the fields you need directly on a loan:

Inline fragments

Use inline fragments to select fields that only exist on a specific implementation of an interface. For example, institutionName is only available on assets that implement FinancialAccountAsset:

Best practices

  1. Use variables for dynamic values - Never hardcode IDs or filters
  2. Create reusable fragments - Define common field selections once
  3. Name fragments descriptively - Use clear, descriptive names
  4. Keep fragments focused - Don’t create overly large fragments

Common patterns

Reusable borrower fragment

Using in multiple queries