Runway Logo


GraphQL is an awesome way to fetch just the right information you need from your backend. It's commonly used in 'headless' environments.

Statamic includes a read-only GraphQL API out of the box. Runway extends upon this so you can query your Eloquent models.

Enabling for resources

GraphQL must be enabled for each of the resources you wish to query. It's as simple as adding to your config:

1// config/runway.php
3'resources' => [
4 \App\Models\Product::class => [
5 'name' => 'Products',
6 'blueprint' => 'product',
8 'graphql' => true,
9 ],

You must also ensure you have GraphQL enabled in Statamic as well for it to be available to you.

As a side note, please ensure you've installed the doctrine/dbal package, Runway uses it for reviewing your database columns. To install it, run composer require doctrine/dbal


For each resource, there's two kinds of queries you can do. An 'index' query and a 'show' query:

Index Query

Example of an index query:

2 products {
3 data {
4 id
5 name
6 price
7 description
8 }
9 }

An index query also allows for pagination between results, you can read up more on that in the Statamic Documentation.

Show Query

Example of a show query:

2 products(id: "2") {
3 id
4 name
5 price
6 description
7 }


If you're using the 'Belongs To' or 'Has Many' fieldtypes provided by Runway, you can also query the related models.

2 product(id: "2") {
3 id
4 name
5 brand {
6 id
7 name
8 created_at
9 updated_at
10 }
11 }

Notice that in the above example, we have a 'Belongs To' fieldtype which we're querying as simply brand, instead of brand_id. Runway removes the _id for you so you can build a nice, clean query.

Filtering and Sorting

You may also filter & sort results the same way you would with the built-in queries. Review the Statamic Docs.

Code highlighting provided by Torchlight.

Edit this page