Builder GraphQL Content API
Usage
With the GraphQL Content API you can query your data by targeting attributes and/or custom fields and use your data as you choose!
The format is
You can also use POST requests with { "query": QUERY } as the body, though GET is preferred when possible for performance and caching purposes
Explorer
The best way to explore the GraphQL API for your data is to use the GraphQL explorer:
Examples
You can see real world examples of using our GraphQL API in our open source examples, such as our Gatsby examle
Basic usage
With targeting
See our content API docs for more info on custom targeting
With query
See our content API docs for more info on custom querying
For React
See our gatsby example for more info about querying and rendering to React
Get HTML
Data model fields
Questions or comments?
GraphQL Content API
To query your data using the GraphQL Content API, you can make requests to the endpoint with the following format:
You can also use POST requests with { "query": QUERY } as the body, though GET is preferred when possible for performance and caching purposes.
Explorer
The best way to explore the GraphQL API for your data is to use the GraphQL Explorer:
Querying models
When using the GraphQL Content API, your models are represented as fields defined on the root query type. For each model, there are two corresponding fields:
myCoolModel(...)to fetch paginated resultsoneMyCoolModel(...)to fetch a single record
For example, if your space had models named page, header, and footer, the root query type in your GraphQL schema would have fields such as page, onePage, footer, oneFooter, header, and oneHeader.
Examples
All of the following examples assume that your space has a model named page defined, but you could swap it out for any other model you have defined.
Tip: Explore real world examples of using the GraphQL API in Builder's open source examples, such as the Gatsby example.
Basic
Write a basic query to fetch the content of a page:
With targeting
Query with targeting to fetch a page with a specific URL path:
See the Content API for more detail on custom targeting.
With query
Query with custom conditions to fetch a page based on certain properties:
See the Content API documentation for more info on custom querying.
For React
For rendering the queried data in a React application, use BuilderComponent:
See Builder's Gatsby example for more info about querying and rendering to React.
Get HTML
Query to retrieve HTML content for a page:
Data model fields
Fetch data from the page model requesting a single record limit: 1 where the value of the someProperty field is someValue. The response will include the value of the someProperty field from the retrieved record:
What's next
For more information, visit the GraphQL Schema documentation.