CraftQL

It's like craft.entries for your API

Get the Plugin

                
    entry(slug:"my-awesome-story") {
        ...on Story {
            title
            body
            relatedEntries {
                title
                url
            }
        }
    }
}
            

Huh?

CraftQL is a zero-config plugin for CraftCMS that turns your existing website in to a secure GraphQL API. CraftQL analyzes your Craft sections and provides a complete GraphQL schema compatible with industry standard tools like Apollo and Relay.

Anything you can do with a Craft template you can do with CraftQL. Seriously, anything. CraftQL aims for feature parity with craft.entries so you can stop worrying about your API and start developing.

Query anything

Fetch entries with a familiar and approachable API.

{
    entries(section: news, limit: 10, order: "postDate desc", search: "body:breaking") {
        title
        url
    }
}

Full access

All your data is available via CraftQL, just like in a .twig template. That includes access to entries, globals, assets, tags, categories, and pretty much anything else you can think of.

{
    entries(section:news) {
        ...on News {
            title # the title field
            body # a text field
            hero { # an assets field
                url # the image url
                thumb: url(crop:{width: 100, height: 100}) # a cropped image
            }
            contactInfo { # a matrix field
                ...on ContactInfoPerson { # a matrix block
                    name # a field on the matrix block
                    phone # a field on the matrix block
                }
            }
        }
    }
}

Mutations

Configure permissions and upsert any content in Craft with ease.

mutation UpsertNews {
    upsertNews(
        title: "My News!" # set fields just like the Craft UI
        body: "This is my awesome news article" # set custom fields too
    ) {
        id
    }
}

Read the docs