Made in Builder.io

Ship Your First Personalized Web Experience webinar on June 15 @ 10AM PT. Register Now

Talk to Us
Product
Developers
Talk to Us

Blog

Home

Resources

Blog

Forum

Github

Login

Signup

×

Visual CMS

Drag-and-drop visual editor and headless CMS for any tech stack

Theme Studio for Shopify

Build and optimize your Shopify-hosted storefront, no coding required

Resources

Blog

Get StartedLogin

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

https://cdn.builder.io/api/v1/graphql/YOUR_API_KEY?query=QUERY

You can also use POST requests with { "query": QUERY } as the body, though GET is preferred when possible for performance and caching purposes.

The best way to explore the GraphQL API for your data is to use the GraphQL explorer:

Try the GraphQL explorer

Your models appear as fields defined on the root query type. For each model a new field will be defined myCoolModel(...) to fetch paginated results, and oneMyCoolModel(...) to fetch a single record.

For example, if in my space I have the models page, header, and footer, my GraphQL schema's root query type will have the fields page, onePage, footer, oneFooter, header, and oneHeader.

You can see real world examples of using our GraphQL API in our open source examples, such as our Gatsby example.

All the examples below assume that your space has a model named page defined, but you could swap it out for any other model you have defined.

query {
  page(limit: 1) { 
    content
  }
}

See our content API docs for more info on custom targeting.

query {
  page(target: { urlPath: "/foobar" }, limit: 1) { 
    content
  }
}

See the Content API documentation for more info on custom querying.

query {
  page(query: { data: { someProperty: "someValue" }}, limit: 1) { 
    content
  }
}

See Builder's Gatsby example for more info about querying and rendering to React.

query {
  page(query: { data: { someProperty: "someValue" }}, limit: 1) { 
    content
  }
}

# Render with
# <BuilderComponent name="page" content={data.page[0].content} />
query {
  page(prerender: true, limit: 1, target: { urlPath: "/" }) { 
    data { html }
  }
}

# Render {{data.page[0].html}} in your site or app
query {
  page(query: {  data: { someProperty: "someValue" }}, limit: 1) { 
    data {
      someProperty
    }
  }
}

Looking to hire a third party to help with your project?

Submit a project request and our partnerships team will reach out to connect you with an Expert from our partner ecosystem.

Connect with us

Was this article helpful?

Product

Visual CMS

Theme Studio for Shopify

Sign up

Login

Featured Integrations

React

Angular

Next.js

Gatsby

Get In Touch

Chat With Us

Twitter

Linkedin

Careers

© 2020 Builder.io, Inc.

Security

Privacy Policy

Terms of Service

Get the latest from Builder.io

Developer Newsletter

Latest tips, tricks, and news for frontend developers from our blog

Product Newsletter

Latest features and updates on the Builder.io platform

By submitting, you agree to our Privacy Policy

Product

Features

Pricing

What's New

Resources

Documentation

Blog

Community Forum

Templates

Partners

Submit an Idea

Use Cases

Landing Pages

Headless CMS

Headless Storefront

Customer Showcase

Customer Success Stories

Builder.io logo

Visually build and optimize digital experiences on any tech stack. No coding required, and developer approved.

Get Started

Log In

Product

Features

Pricing

Integrations

Use Cases

© 2023 Builder.io, Inc.

Security

Privacy Policy

SaaS Terms