Add Availability Dimensions To Query
When querying for an object availability dimensions can be supplied to the query representing different user parameters.
The query dimension argument can either be supplied as a single object or an array of objects (for Skylark accounts with multiple Dimensions configured). The fields of the UserDimension
input are:
dimension
: This is the slug of the parent dimension objectvalue
: This is the slug of the dimension value
Supplying a single dimension
query getBrand {
getBrand(
uid: "01H7JA06MDMQ47AG3C19Q1Y4PE",
dimensions:
{
dimension: "customer-type",
value: "premium"
}
)
{
uid
title
}
}
Supplying multiple dimensions
query getBrand {
getBrand(
uid: "01H7JA06MDMQ47AG3C19Q1Y4PE",
dimensions: [
{
dimension: "customer-type",
value: "premium"
},
{
dimension: "locale",
value: "europe"
}
]
)
{
uid
title
}
}
Using GraphQL Variables
In the examples above, we've explained how to supply dimensions into your Skylark GraphQL Queries. In practice, however, hard coding the Dimension values inside the query is unrealistic as it will result in a Query per combination of values.
Therefore, we recommend using GraphQL Variables in your queries to set Dimension values so that they are reusable regardless of the combination of values.
Passing Dimension Values in separate Variables
query GET_BRAND(
$uid: String!
$customerType: String!
$locale: String!
) {
getBrand(
uid: $uid
dimensions: [
{ dimension: "customer-type", value: $customerType }
{ dimension: "locale", value: $locale }
]
) {
__typename
title
title_short
synopsis
synopsis_short
}
}
Example GraphQL Request Variables:
{
"uid": "01H7JA06MDMQ47AG3C19Q1Y4PE",
"customerType": "premium",
"locale": "europe"
}
Passing all Dimensions in a Single Variable
In Skylark Accounts with multiple Dimensions configured, it may be optimal to use a single dimensions
variable rather than a variable per Dimension as in the example above.
The advantage of this method over the previous is that if you add another Dimension in the future, you are able to update any requests to Skylark. However, it is not as explicit as a variable per Dimension.
query GET_BRAND(
$uid: String!
$dimensions: [UserDimension]
) {
getBrand(
uid: $uid
dimensions: $dimensions
) {
__typename
title
title_short
synopsis
synopsis_short
}
}
Example GraphQL Request Variables:
{
"uid": "01H7JA06MDMQ47AG3C19Q1Y4PE",
"dimensions": [
{"dimension": "customer-types", "value": "premium"},
{"dimension": "locale", "value": "europe"}
]
}
Updated 5 months ago