When integrating with the title system in Connect, the following setup is required:
Consider the following example:
Your title management system sent you a notification that a movie called "My Great Movie" has been updated with the following internal ID: 9ff00b2a-78a0-4486-aa86-4b97e2f576aa.
Note: The values included in the code samples below are illustrative and not functional.
First, you need to check if the title exists in Connect using the following query:
query title($id: ID!) {title(id: $id) {organizationIdidcreatedAtupdatedAtcreatedByIdupdatedByIdfiles {totalCountedges {...FileEdgeFragment}}nameslugentityTypeName}}
{"id": "9ff00b2a-78a0-4486-aa86-4b97e2f576aa"}
You will get the following response:
{"data": {"title": {"organizationId": "b1b8adf6-90e7-49d7-a45f-54259e85550d","id": "9ff00b2a-78a0-4486-aa86-4b97e2f576aa","createdAt": "2007-12-03","updatedAt": "2007-12-03","createdById": "24416ac7-64e7-474f-8b35-e9c4f1cbb28e","updatedById": "24416ac7-64e7-474f-8b35-e9c4f1cbb28e","files": {"totalCount": 1,"edges": [{"node": {"id": "44c93915-7ac0-4356-ac1a-cb6df98bfc01"}}]},"name": "xyz789","slug": "xyz789","entityTypeName": "Movie"}}}
If the query returns a title, the title exists. If the query does not return a title, you must use the createTitle
mutation to create it.
mutation createTitle($titleInput: TitleInput!) {createTitle(input: $titleInput) {organizationIdidnameslugentityTypeName}}
{"titleInput": {"organizationId": "b1b8adf6-90e7-49d7-a45f-54259e85550d","name": "My Great Movie","entityTypeId": "743a3d16-a35e-4126-9338-9dc4531343c5"}}
You will get the following response:
{"data": {"title": {"organizationId": "b1b8adf6-90e7-49d7-a45f-54259e85550d","id": "9ff00b2a-78a0-4486-aa86-4b97e2f576aa","name": "My Great Movie","slug": "my-great-movie-c6c04a5d-71f7-4b9f-8116-4191a66510a6","entityTypeId": "743a3d16-a35e-4126-9338-9dc4531343c5"}}}
You can update the name, entity type and other title attributes using the updatetitle
mutation.
mutation updateTitle($id: ID!, $titleInput: TitleInput!) {updateTitle(id: $id, input: $titleInput) {organizationIdidnameentityTypeId}}
{"titleInput": {"name": "My Fantastic Movie","entityTypeId": "a2c52562-eded-488a-9458-0d2039141b93"}}
You will get the following response:
{"data": {"title": {"organizationId": "b1b8adf6-90e7-49d7-a45f-54259e85550d","id": "9ff00b2a-78a0-4486-aa86-4b97e2f576aa","name": "My Fantastic Movie","entityTypeId": "a2c52562-eded-488a-9458-0d2039141b93"}}}
You can associate, update or remove metadata from the title using the queries and mutations below.
To update the title metadata, you must first get the entity type to list its attributes with their ID.
query getEntityTypeAttributes($entityTypeId: ID!) {metadataEntityType(id: $entityTypeId) {nameattributes {idname}}}
{"entityTypeId": "a2c52562-eded-488a-9458-0d2039141b93"}
You will get the following response:
{"data": {"metadataEntityType": {"name": "Movie","attributes": [{"id": "0c32687e-ad01-42d1-af16-b18fdffea697","name": "rating"},{"id": "cd1a8dd4-25bc-4b6a-bbb1-754a35e7254b","name": "genre"},{"id": "e4616cd0-d461-4849-8be8-14e9c30fec1a","name": "shortDescription"}]}}}
To update the metadata fields on the title, use the following mutation:
mutation updateTitle($id: ID!, $titleInput: TitleInput!) {updateTitle(id: $id, input: $titleInput) {organizationIdidnameentityTypeNamecustomFields {localevalues {idvalue}}}}
{"id" : "9ff00b2a-78a0-4486-aa86-4b97e2f576aa","titleInput": {"customFields": [{"locale": "en_US","values": [{"attributeId": "e4616cd0-d461-4849-8be8-14e9c30fec1a","value": "English Short Description"}]},{"locale": null,"values": [{"attributeId": "0c32687e-ad01-42d1-af16-b18fdffea697","value": "PG18"}]}]}}
You will get the following response:
{"data": {"updateTitle": {"organizationId": "b1b8adf6-90e7-49d7-a45f-54259e85550d","id": "9ff00b2a-78a0-4486-aa86-4b97e2f576aa","name": "My Fantastic Movie","entityTypeName": "Movie","customFields": [{"locale": null,"values": [{"id": "0c32687e-ad01-42d1-af16-b18fdffea697","value": "PG18"}]},{"locale": "en-US","values": [{"id": "e4616cd0-d461-4849-8be8-14e9c30fec1a","value": "English Short Description"}]}]}}}
In addition, you can also list all the existing titles using the following query:
query titles($first: Int,$skip: Int) {titles(first: $first,skip: $skip,) {totalCountedges {cursornode {...TitleFragment}}pageInfo {counthasNextPagelastCursor}}}
{"first": 20,"skip": 40}
You will get the following response:
{"data": {"titles": {"totalCount": 150,"edges": [{"cursor": "Mg==","node": {"id": "0466409a-cfcb-48bc-ad03-1447be7bd554","name": "example-show","entityTypeName": "Show","entityTypeId": "311f91cf-65e0-47ee-ab19-2b873790031e"}},{"cursor": "Mw==","node": {"id": "080096d9-f7f2-446c-80c8-2c85d57d3236","name": "example-season","entityTypeName": "Season","entityTypeId": "fac3930c-fabd-4bd2-86b7-9a95d5574747"}},{"cursor": "NA==","node": {"id": "0c61f33d-eed4-4c0b-9892-b591b325efb9","name": "example-episode","entityTypeName": "Episode","entityTypeId": "b4787492-0a78-41b6-b475-8a9d7c255c76"}},{"cursor": "NQ==","node": {"id": "0d3a1a45-fb7f-4539-b775-e6155670085b","name": "example-movie","entityTypeName": "Movie","entityTypeId": "a2c52562-eded-488a-9458-0d2039141b93"}},{"cursor": "Ng==","node": {"id": "9ff00b2a-78a0-4486-aa86-4b97e2f576aa","name": "My Fantastic Movie","entityTypeName": "Movie","entityTypeId": "a2c52562-eded-488a-9458-0d2039141b93"}}],"pageInfo": {"hasNextPage": true,"lastCursor": "Ng=="}}}}