Queries

How do I access my product data from the GraphQL API?

All of the supported queries are documented in the schema viewable inside of our GraphQL Playground; however, we have put some examples together to help you understand what queries to use in which scenario.

Name and Slug property

Any object in our database that has been given a name property will also receive have a slug property. These values are a generated representation of the name that was provided, generated at the time of its creation.

We use these slugs as a means to programmatically access a specific record through our GraphQL API.

Examples

Product

For this example, we'll retrieve a fictional product called ACME Inc.

In the application, you can visit your product's settings page to retrieve what slug you will need to use with the API, and then you will be ready to write your query.

The query to retrieve a product with the slug of acme-inc would be:

Query
Response
Query
{
product(slug:"acme-inc") {
name
slug
}
}
Response
{
"data": {
"product": {
"name": "ACME Inc.",
"slug": "acme-inc"
}
}
}

Plans

To retrieve details about your plans (such as slugs, or base cost), you can query them as an edge of the Product query:

Query
Response
Query
{
product(slug:"acme-inc") {
plans(limit: 2, offset:0) {
plans{
name
description
slug
cost
}
}
}
}
Response
{
"data": {
"product": {
"plans": {
"plans": [
{
"name": "Solo",
"slug": "plan-1",
"cost": 0
},
{
"name": "Team",
"slug": "starter",
"cost": 0
}
]
}
}
}
}

Feature definitions

To retrieve details about your feature types (such as slug, or visibility), you can query them as an edge of the Product query:

Query
Response
Query
{
product(slug:"acme-inc") {
featureSlugs(limit: 10, offset:0) {
featureSlugs{
description
slug
visibility
}
}
}
}
Response
{
"data": {
"product": {
"featureSlugs": {
"featureSlugs": [
{
"slug": "widgets",
"visibility": "VISIBLE"
},
{
"slug": "toggles",
"visibility": "VISIBLE"
},
{
"slug": "anvils",
"visibility": "VISIBLE"
}
]
}
}
}
}

Values

Each feature in a plan can have its own value. To retrieve details of what each plan includes you can query your Plans and find the values under the Features edge:

Query
Response
Query
{
product(slug:"acme-inc") {
plans(limit: 10, offset: 0){
plans{
name
features (limit: 25, offset: 0) {
features {
featureType: __typename
billingType: class
description
featureSlug {slug}
... on StringFeature {
stringValues: values {
display
value
cost
default
}
}
... on BooleanFeature {
booleanValues: values {
display
value
cost
default
}
}
... on IntFeature {
intValues: values {
display
value
cost
}
}
... on IntRangeFeature {
intRangeValues: values {
min
max
increments
cost
}
}
}
}
}
}
}
}
Response
{
"data": {
"product": {
"plans": {
"plans": [
{
"name": "Plan 1",
"features": {
"features": [
{
"featureType": "StringFeature",
"billingType": "FIXED",
"description": "This value is a basic string",
"featureSlug": {
"slug": "feature-1"
},
"stringValues": [
{
"display": null,
"value": "Your string value here",
"cost": 0,
"default": true
}
]
},
{
"featureType": "BooleanFeature",
"billingType": "FIXED",
"description": "This value is a boolean checkmark",
"featureSlug": {
"slug": "feature-2"
},
"booleanValues": [
{
"display": null,
"value": true,
"cost": 0,
"default": true
}
]
},
{
"featureType": "IntFeature",
"billingType": "FIXED",
"description": "This value is an integer",
"featureSlug": {
"slug": "feature-3"
},
"intValues": [
{
"display": null,
"value": 1234,
"cost": 0
}
]
},
{
"featureType": "IntRangeFeature",
"billingType": "METERED",
"description": "This value is a metered integer, with 100 free",
"featureSlug": {
"slug": "feature-4"
},
"intRangeValues": [
{
"min": 0,
"max": 100,
"increments": 1,
"cost": 0
},
{
"min": 100,
"max": null,
"increments": 1,
"cost": 10
}
]
}
]
}
}
]
}
}
}
}