Loading...
Loading...
Queries are the primary way of fetching data associated with a Profile, such as Connections, Accounts, Transactions and more.
A powerful feature of queries is that they natively support requesting complex, nested data structures. This allows you to:
Currently the following Queries are generally available via GraphQL:
profile: Access information about the authenticated Profile.connection: Look up a Connection by its ID.connections: Get a list of Connections with filters, search and sort options.account: Look up an Account by its ID.accounts: Get a list of Accounts with filters, search and sort options.transaction: Look up a Transaction by its ID.transactions: Get a paginated list of Transactions, with filters, search and sort options.holding: Look up a Holding by its ID.holdings: Get a paginated list of Holdings.statement: Look up a Statement by its ID.statements: Get a paginated list of Account Statements, with filters, search and sort options.profile QueryIn this example, we will define a profile query to get the user's basic profile details:
query GetProfile {
profile {
id
email
phone
metadata
}
}
curl --request POST \
--url 'https://api.quiltt.io/v1/graphql' \
--header 'Authorization: Bearer <SESSION_TOKEN>' \
--header 'Content-Type: application/json' \
--data @- <<GRAPHQL
{
"query": "query GetProfile {
profile {
id
email
phone
metadata
}
}"
}
GRAPHQL
{
"data": {
"profile": {
"id": "p_11oaRngjEOLf1YcBdZqKp0E",
"email": "example@quiltt.io",
"phone": null,
"metadata": {
"favoriteColor": "Purple",
}
}
}
}
In GraphQL, successful queries always return a data object that mirrors the structure of your request.
The Quiltt React SDK provides a built-in hook to call the Quiltt GraphQL API. Additionally, the GraphQL community provides a rich ecosystem of open-source clients and libraries that seamlessly plug-in to your client-side or server-side framework of choice.
For example, here's the profile query example implemented using our useQuery hook.
import { gql, useQuery } from '@quiltt/react'
// Set up your query string to fetch the user's profile.
const GET_PROFILE = gql`
query {
profile {
id
email
name
phone
}
}
`
export const Profile = () => {
const { loading, data } = useQuery(GET_PROFILE)
// Display a message while the query is in progress
if (loading) return <p>Loading...</p>
// Render the user's name from the response
return <p>Welcome back {data.profile.name}!</p>
}