Getting a set if handled via the getSkylarkSet query.

To get a set you must have the set's UID and the set must be available.

The structure of the return object is a bit different to other relationship listings in Skylark as it uses GraphQL inline fragments. This means you can specify the return fields for an object based on the object type.

It is also possible to use the GraphQL meta field __typename to get the type/class of the returned objects.

As with lists of related objects, the content of a set is returned in list format (see here), so you can paginate results, sets limits, etc.

Get a Set and Shared Object Metadata

In this example the uid and __typename are being returned for all content objects, regardless of their type.

query getSkylarkSet {
  getSkylarkSet(uid: "e2fe230f-39c8-492f-99a9-30ce648a9b8e") {
    uid
    title
    content {
      objects {
        uid
        __typename
      }
    }
  }
}

Get a Set and Specific Object Fields

In this example:

  • The uid and __typename are being returned for all content objects
  • The title and episode_number are being returned for objects only of type Episode
  • The year_of_release and synopsis are being returned for objects only of type Movie
query getSkylarkSet {
  getSkylarkSet(uid: "e2fe230f-39c8-492f-99a9-30ce648a9b8e") {
    uid    
    title
    content {
      objects {
        uid
        __typename
        ... on Episode {
          title
          episode_number
        }
        ... on Movie {
          year_of_release
          synopsis
        }
      }
    }
  }
}

Getting A Set Within A Set

It is of course also possible to add a set to a set. This example shows how to retrieve the content of a nested set. Specifically, the uid, __typename and Episode title are being returned from the nested set.

query getSkylarkSet {
  getSkylarkSet(uid: "e2fe230f-39c8-492f-99a9-30ce648a9b8e") {
    uid   
    title
    content {
      objects {
        __typename
        ... on Set {
          content {
            objects {
              uid
              __typename
              ... on Episode {
                title
              }
            }
          }
        }
      }
    }
  }
}

Getting Sets That A Content Object Is A Member of

All objects that can be added to sets automatically have a sets relationship in their return fields.

This makes it possible to view the sets that objects are a member of. When content is added to a set a reverse relationship from the content to the set is added.

This relationship also exists for sets within sets.