How to use GraphQL in your app
Data can be queried using GraphQL by following these steps.- Create a new
.graphqlfile within your application and include the GraphQL query you want to run. - Import the query into your app.
- Run the query using the
runQueryfunction or theuseQueryhook.
Exploring the GraphQL schema
To inspect the App SDK’s GraphQL schema, runnpm run dev and press o.
This opens a local GraphiQL instance in read-only mode, where you can browse available types and operations.
Query execution against workspace data is not yet supported in the playground.
Type generation
Runningnpm run dev will watch for updates to .graphql files and automatically generate TypeScript types for them. These types will be used to type the runQuery and useQuery functions with responses that match your query.
Making requests directly to the Attio REST API
The App SDK GraphQL API is read-only and client-side only. If you would like to read or write Attio data from server-side code, you can use the Attio REST API withATTIO_API_TOKEN
from within your server functions
Example: Get a person’s contact details
First, create a new.graphql file within your application and include the following GraphQL query:
src/app/extensions/add-to-sequence/get-person-contact-details.graphql
src/app/extensions/add-to-sequence/extension.tsx
Example: Get a text attribute’s value on a company record
First, create a new.graphql file within your application and include the following GraphQL query.
src/app/extensions/get-stock-price/get-text-attribute-value.graphql
src/app/extensions/get-stock-price/extension.tsx