Create Availability Rule

You can create an availability rule to link to objects later using the createAvailability function.

Here's a recipe for creating availability rules:

The inputs for availability are:

  • title: A human-friendly title for the availability rule that will display in the Skylark UI
  • slug: A computer-friendly name for the availability rule
  • start: The starting availability date
  • end: The ending availability date
  • dimensions: An array containing one or many availability dimensions to link, Each object contains:
    • dimension_slug: The slug of the existing availability dimension. This dimension must already exist in the database or a NotFound error will be thrown.
    • value_slugs: An array of strings containing the slugs for dimension values, as with the dimension slug, these values must already exist in the database or a NotFound error will be thrown.

When creating availability all input fields are optional. If you don’t supply data to a field the following will happen:

  • title: Nothing will happen, title will just be left as null
  • slug: Nothing will happen, slug will just be left as null
  • start: The start date will be automatically set to a date in the distant past to simulate no effective start date
  • end: The end date will be automatically set to a date in the distant future to simulate no effective end date
  • dimensions: If no dimensions are supplied this availability will be temporal only and will not be valid if the user supplies dimensions in a query
mutation MyMutation {
  createAvailability(availability: {
    title: "My availability", 
    slug: "my-availability",
    start: "", 
    end: "", 
    dimensions: {
      link: [
        {
          dimension_slug: "operating-system",
          value_slugs: ["ios", "android"]
        }
      ]
    }
  }) 
  # Return fields
  {
    uid
    title
  }
}