Availability Inheritance

Availability inheritance allows availability rules to flow through to related objects.

Enabling Availability Inheritance

Inheritance is enabled on a per object, per relationship basis. This is done via the setRelationshipConfiguration mutation.

This example shows enabling availability inheritance from the Movie object to its credits relationship, so all genres related to movies will inherit the movie's availability.

mutation {
  setRelationshipConfiguration(
    object: Movie, 
    relationship_name: "credits", 
    relationship_config: 
  {
  	inherit_availability: true
    
  }) {
    inherit_availability
  }
}

Getting Inheritance Information

Inheritance information can be viewed on an object's availability relationship. There are 4 relevant fields:

FieldDescription
inheritedThis boolean field is set to true when the object's availability has been inherited from another object
inheritance_sourceThis boolean field is set to ture when the object's availability is being inherited by another object
inherited_fromThis relationship list shows all object's this availability is being inherited from
inherited_byThis relationship list shows all object's this availability is being inherited by

It's important to note that a single object's availability could be inherited from multiple sources and also be the source for many other object's availability.

Example: Viewing inherited from information

This example shows viewing a Credit object's availability.

query {
  getCredit(uid: "01HKRPJEQJ2JKCRXC46S45T0K8") {
    uid
    availability {
      objects {
        title
        inherited
        inherited_from {
          objects {
            __typename
            uid
          }
        }
      }
    }
  }
}

The response below shows the availability is being inherited from multiple Movie objects.

{
  "data": {
    "getCredit": {
      "uid": "01HKRPJEQJ2JKCRXC46S45T0K8",
      "availability": {
        "objects": [
          {
            "title": "Always - Premium/Standard, Europe/North America",
            "inherited": true,
            "inherited_from": {
              "objects": [
                {
                  "__typename": "Movie",
                  "uid": "01HKRPKRPJBV4JYSTS03Z9NEQB"
                },
                {
                  "__typename": "Movie",
                  "uid": "01HKRPKRPYA2GKCD6XKVPD6RGC"
                },
                {
                  "__typename": "Movie",
                  "uid": "01HKRPKRQ6503V96E1J95WPCTF"
                },
                {
                  "__typename": "Movie",
                  "uid": "01HKRPKRQ9FXH4HR4SCTY4RB0J"
                },
                {
                  "__typename": "Movie",
                  "uid": "01HKRPKRXKTJA7TS99RBNQ0DGB"
                },
                {
                  "__typename": "Movie",
                  "uid": "01HKRPKRXS551SF4BW66DD9A2X"
                },
                {
                  "__typename": "Movie",
                  "uid": "01HKRPKV1BE6GW7Q9S4GBDEXDS"
                }
              ]
            }
          }
        ]
      }
    }
  }
}

Example: Viewing inherited by information

We can now view the other direction:

query {
  getCredit(uid: "01HKRPJEQJ2JKCRXC46S45T0K8") {
    uid
    availability {
      objects {
        title
        inheritance_source
        inherited_by {
          objects {
            __typename
            uid
          }
        }
      }
    }
  }
}

The response below shows the availability of this credit is not just being inherited from the movie, but inherited by a Person and Role:

{
  "data": {
    "getCredit": {
      "uid": "01HKRPJEQJ2JKCRXC46S45T0K8",
      "availability": {
        "objects": [
          {
            "title": "Always - Premium/Standard, Europe/North America",
            "inheritance_source": true,
            "inherited_by": {
              "objects": [
                {
                  "__typename": "Person",
                  "uid": "01HKRPJ867WMPTX73RM3R52AW7"
                },
                {
                  "__typename": "Role",
                  "uid": "01HKRPJBSGSQ0HRYXB2M6QJ4QK"
                }
              ]
            }
          }
        ]
      }
    }
  }
}

Deactivating Inherited Availability

It's possible to deactivate inherited availability on an object by object bases, if there are cases where an object type is inheriting availability, but there are instances where you don't want that inherited availability to be applied.

This is done the same way as unlinking an availability rule, however rather than being removed from the object entirely the active field is set to False, and the rule is no longer taken into account when calculating the object's availability.

Example: Deactivated inherited availability

This example shows the availability on the credit mentioned above being deactivated:

mutation {
  updateCredit(
    uid: "01HKRPJEQJ2JKCRXC46S45T0K8"
    credit: {
      availability: {
        unlink: ["01HKRPGTVVPM94EW3DW2MRRS2P"]
      }
    }
  ) {
    uid
    availability {
      objects {
        uid
        active
      }
    }
  }
}

The response shows the active field is now showing as false.

{
  "data": {
    "updateCredit": {
      "uid": "01HKRPJEQJ2JKCRXC46S45T0K8",
      "availability": {
        "objects": [
          {
            "uid": "01HKRPGTVVPM94EW3DW2MRRS2P",
            "active": false
          }
        ]
      }
    }
  }
}

Reactivating an availability rule is as simple as deactivating it. Just use the same steps as linking an availability rule.

mutation {
  updateCredit(
    uid: "01HKRPJEQJ2JKCRXC46S45T0K8"
    credit: {
      availability: {
        link: ["01HKRPGTVVPM94EW3DW2MRRS2P"]
      }
    }
  ) {
    uid
    availability {
      objects {
        uid
        active
      }
    }
  }
}

Removing Inherited Availability

Once an availability rule has been inherited, it is removed when the rule on the upstream object is removed or the relationship to the upstream object has been removed.

An inherited rule is only removed entirely from an object when every inherited source has been removed.

For example, if a Brand object inherits the same availability rule from 10 Movie objects, that rule will remain on the brand until all the movie relationships have been unlinked or the rule has been unlinked from all the movies.