Manage Dimensions

“Dimension” refer to the parent of a group of values.

🚧

The value of dimension is assumed to be a slug and only if the query comes back empty will a query be made against the UID. This means for maximum efficiency its better to use the slug as there will be less calls to DynamoDB.

Create Dimentions

Creating new dimensions is handled by the createDimension mutation.

  • slug is a required field for all dimensions.
  • If a title is not supplied, the slug will be used.

Here's a recipe for creating dimensions:

mutation createDimension {
  createDimension(dimension: {
    title: "Device Type", 
    slug: "device-type", 
    description: "The type of device"
  }) {
    # Return fields
    uid
    title
    slug
    description
  }
}

Response:

{
  "data": {
    "createDimension": {
      "uid": "74b82dfa-727a-4323-87a5-e336f4ef3754",
      "title": "Device Type",
      "slug": "device-type",
      "description": "The type of device"
    }
  }
}

List Dimensions

Retrieving a list of dimensions is done via the listDimensions query. This returns paginated result.

query listDimensions {
  listDimensions {
    objects {
      uid
      title
      slug
      description
    }
    count
    next_token
  }
}

The values attribute can be included to view child dimension values, and _meta to display the created/modified information.

query listDimensions {
  listDimensions {
    objects {
      uid
      title
      slug
      description
      values {
        objects {
          uid
          slug
          title
        }
      }
      _meta {
        modified {
          user
          date
          account
        }
        created {
          user
          date
        }
      }
    }
  }
}

Response:

{
  "data": {
    "listDimensions": {
      "objects": 
        [
          {
            "uid": "cfe6eb7f-0591-4280-94f2-6beca39171ed",
            "title": "Device Type",
            "slug": "device-type",
            "description": "The type of device",
            "values": {
              "objects": [
                {
                  "slug": "pc",
                  "title": "PC"
                },
                {
                  "slug": "ipad",
                  "title": "iPad"
                }
              ]  
            },
            "_meta": {
              "modified": {
                "user": "[email protected]",
                "date": "2021-10-28T15:37:45.385222+00:00",
                "account": null
              },
              "created": {
                "user": "[email protected]",
                "date": "2021-10-28T15:37:45.385222+00:00"
              }
            }
          }
        ]
    }
  }
}

Get Dimensions

Retrieving a single of dimension is done via the getDimension query. The dimension_id value in the query can either be the dimension’s slug or UID. Alternately, a dimension can be retrieved using its external_id using external_id argument.

query MyQuery {
  getDimension(dimension_id: "device-type") {
    uid
    title
    slug
    description
  }
}

OR

query MyQuery {
  getDimension(dimension_id: "cfe6eb7f-0591-4280-94f2-6beca39171ed") {
    uid
    title
    slug
    description
  }
}

OR

query MyQuery {
  getDimension(external_id: "device-type-external-id") {
    uid
    title
    slug
    description
  }
}

The values attribute can be included to view child dimension values.

query MyQuery {
  getDimension(dimension_id: "device-type") {
    uid
    title
    slug
    description
    values {
      objects {
        uid
        slug
        title
      }
    }
    _meta {
      modified {
        user
        date
      }
      created {
        user
        date
      }
    }
  }
}

Response:

{
  "data": {
    "getDimension": {
      "uid": "cfe6eb7f-0591-4280-94f2-6beca39171ed",
      "title": "Device Type",
      "slug": "device-type",
      "description": "The type of device",
      "values": {
        "objects": [
          {
            "slug": "pc",
            "title": "PC"
          },
          {
            "slug": "ipad",
            "title": "iPad"
          }
        ]
      },
      "_meta": {
        "modified": {
          "user": "[email protected]",
          "date": "2021-10-28T15:37:45.385222+00:00"
        },
        "created": {
          "user": "[email protected]",
          "date": "2021-10-28T15:37:45.385222+00:00"
        }
      }
    }
  }
}

The availability attribute can be included to see all the availability slots using the dimension.

query MyQuery {
  getDimension(dimension_id: "device-types") {
    uid
    title
    slug
    description
    values {
      objects {
        uid
        slug
        title
      }
    }
    availability {
      objects {
        uid
        start
        end
      }
    }
}

Response

{
  "data": {
    "getDimension": {
      "uid": "cfe6eb7f-0591-4280-94f2-6beca39171ed",
      "title": "Device Type",
      "slug": "device-types",
      "description": "The type of device",
      "values": {
        "objects": [
          {
            "slug": "pc",
            "title": "PC"
          },
          {
            "slug": "ipad",
            "title": "iPad"
          }
        ]
      },
      "availability": {
        "objects": [
          {
            "uid": "7e5f319f-a957-4aa9-ab1c-aa157c559513",
            "start": "2022-10-30T00:00:00Z",
            "end": "2022-12-31T00:00:00Z"
          },
          {
            "uid": "c4bbc3a1-1bbb-42f8-82ba-f84b3b90f46a",
            "start": "1970-01-01T00:00:00+00:00",
            "end": "2038-01-19T03:14:07+00:00"
          },
          {
            "uid": "efe7c438-87b1-474f-a5be-fdc4a7a77b0e",
            "start": "2022-11-01T00:00:00Z",
            "end": "2022-12-01T00:00:00Z"
          }
        ]
      }
    }
  }
}

Update Dimensions

Updating a dimension is done via the updateDimension mutation and requires:

  • Either slug or UID of parent dimension. Alternately, external_id of the parent dimension can be passed in external_id argument.

Slugs and UIDs can also be mixed for the dimension and value.

mutation MyMutation {
  updateDimension(
    dimension_id: "device-type", 
    dimension: {
      title: "Updated device type", 
      slug: "updated-device-type", 
      description: "The device type that has been updated"
    }
  ) {
    uid
    title
    slug
    description
  }
}

Using external_id

mutation MyMutation {
  updateDimension(
    externalid: "device-type-ext-id", 
    dimension: {
      title: "Updated device type", 
      slug: "updated-device-type", 
      description: "The device type that has been updated"
    }
  ) {
    uid
    title
    slug
    description
  }
}

Response:

{
  "data": {
    "updateDimension": {
      title: "Updated device type", 
      slug: "updated-device-type", 
      description: "The device type that has been updated",
      uid: "15294f83-ae2b-4196-bbbe-e0aa64a93e5a"
    }
  }
}

Delete Dimensions

Deleting dimension values is done via the deleteDimension mutation.

Deleting a dimension value requires:

  • Either slug or UID or external_id of parent dimension

Slugs and UIDs can also be mixed for the dimension and value.

On deleting a dimension, all the child dimension values will be deleted too.

mutation MyMutation {
  deleteDimension(dimension_id: "device-type")
}

Response:

{
  "data": {
    "deleteDimension": "0d35f6b8-5fa2-4398-b8a6-7f5050374409"
  }
}

🚧

Note that a dimension cannot be deleted if there are availability slots associated with it.