Children

GraphQL can significantly enhance the power of your API Integration. To onboard, please reach out to your Account Manager for pricing information.

Children is a field on the Entity root type that represents the entity's associated child records. Children is an array of type Entity, and is specified by passing a char type ID parameter.

{
    entity(id: 10, charTypeId: 4) {
       children(charTypeId: 3) {
            items {
                 id
                 title
                 template {
                      templateId
                 }
            }
       }   
    }
}

The Children field is especially powerful because it allows you to traverse a record's hierarchy. You can include multiple Children fields for each entity to represent different char types, and each Children Entity can have its own Children field. These Children fields can be chained together to traverse an entire records hierarchy.

In the below example, we retrieve a Deal record, it's child Table records, and the Catalog records that are associated to each of those Table records.

{
    entity(id: 10, charTypeId: 4) {
        children(charTypeId: 5) {
            items {
                id
                title
                template {
                    templateId
                }
                children(charTypeId: 1) {
                    items {
                        id
                        title
                        template {
                            templateId
                        }
                    }
                }
            }
        }    
    }
}

Response:

{
    "data": {
        "entity": {
            "children": {
                "items": [
                    {
                        "id": 500,
                        "title": "Table 1",
                        "template": {
                            "templateId": 1
                        }
                        "children": {
                            "items": [
                                {
                                    "id": 100,
                                    "title": "Catalog 1",
                                    "template": {
                                        "templateId": 1
                                    }
                                },
                                {
                                    "id": 101,
                                    "title": "Catalog 2",
                                    "template": {
                                        "templateId": 2
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "id": 501,
                        "title": "Table 2",
                        "template": {
                            "templateId": 2
                        }
                        "children": {
                            "items": []
                        }
                    }
                ]
            }
        }
    }
}

Aliasing

When including multiple Children fields, in order to keep track of what a certain Children field represents, you can add an Alias. Adding an alias to a field will rename the response Children field with the desire alias name.

In the below example, the alias rights has been added to the Children field where char type ID = 3, and the alias tables has been added to the Children field where char type ID = 5. You can see in the response that these two fields have been replaced with their respective aliases.

{
    entity(id: 10, charTypeId: 4) {
       rights: children(charTypeId: 3) {
            items {
                 id
                 title
                 template {
                      templateId
                 }
            }
       } 
       tables: children(charTypeId: 5) {
            items {
                 id
                 title
                 template {
                      templateId
                 }
            }
       }    
    }
}

Response:

{
    "data": {
        "entity": {
            "id": 10,
            "title": "Deal 1",
            "template": {
                "templateId": 1
            },
            : {
                "items": [
                    {
                        "id": 100,
                        "template": {
                            "templateId": 1
                        },
                        "title": "Rights 1"
                    },
                    {
                        "id": 101,
                        "template": {
                            "templateId": 2
                        },
                        "title": "Rights 2"
                    }
                ]
            },
            : {
                "items": [
                    {
                        "id": 200,
                        "template": {
                            "templateId": 1
                        },
                        "title": "Table 1"
                    },
                    {
                        "id": 201,
                        "template": {
                            "templateId": 2
                        },
                        "title": "Table 2"
                    }
                ]
            }
        }
    }
}

Paging

To limit response sizes, the Children field utilizes paging. To page through the children records, use the skip and take parameters:

{
    entity(id: 10, charTypeId: 4) {
       rights: children(charTypeId: 3, : 10, : 10) {
            items {
                 id
                 title
                 template {
                      templateId
                 }
            }
       }  
    }
}

The default page size is 50.

There are also additional fields in the request that help to identify the total number of Children records (totalCount), if a previous page exists (hasPreviousPage), and if a next page exists (hasNextPage). hasPreviousPage and hasNextPage are nested in a pageInfo object on the Children object:

{
    entity(id: 10, charTypeId: 4) {
       rights: children(charTypeId: 3, skip: 10, take: 2) {
            
            pageInfo {
                 hasPreviousPage
                 hasNextPage
            }
            items {
                 id
                 title
                 template {
                      templateId
                 }
            }
       }  
    }
}

Response:

{
    "data": {
        "entity": {
            "id": 10,
            "title": "Deal 1",
            "template": {
                "templateId": 1
            },
            "rights": {
                "totalCount": 24,
                "pageInfo": {
                    "hasPreviousPage": true,
                    "hasNextPage": true
                },
                "items": [
                    {
                        "id": 100,
                        "template": {
                            "templateId": 1
                        },
                        "title": "Rights 1"
                    },
                    {
                        "id": 101,
                        "template": {
                            "templateId": 2
                        },
                        "title": "Rights 2"
                    }
                ]
            }
        }
    }
}

Using these fields and parameters, you can page through the Children in subsequent requests, using logic similar to:

if (pageInfo.hasNextPage)

skip = skip + take

Filtering

Children can be filtered by using a special parameter object called where:

{
    entity(id: 10, charTypeId: 4) {
       rights: children(charTypeId: 3, where: {templateId: {eq: 1}}) {
            items {
                 id
                 title
                 template {
                      templateId
                 }
            }
       }  
    }
}

All of the following Entity fields can be filtered on in the Children collection:

  • title

  • templateId

  • statusId

  • createdBy

  • createdDate

  • lastUpdatedBy

  • lastUpdatedDate

  • statusUpdatedBy

  • statusUpdatedDate

String Filtering

String fields (title) can be filtered using the following operators:

operatorvalue typedescriptionusage

eq

String

exact match

{title: {eq: "Episode 1"}}

neq

String

doesn't match

{title: {neq: "Episode 1"}}

contains

String

substring match

{title: {contains: "Episode"}}

ncontains

String

doesn't contain substring match

{title: {ncontains: "Episode"}}

in

[String]

exact match one of the following

{title: {in: ["Episode 1", "Episode 2"]}}

nin

[String]

doesn't match any of the following

{title: {nin: ["Episode 1", "Episode 2"]}}

startsWith

String

string starts with

{title: {startsWith: "Episode"}}

nstartsWith

String

string doesn't start with

{title: {nstartsWith: "Episode"}}

endsWith

String

string ends with

{title: {endsWith: "Episode"}}

nendsWith

String

string doesn't end with

{title: {nendsWith: "Episode"}}

Comparable Filtering

Field types of bool, int, and DateTime such as templateId, statusId, createdBy, createdDate, lastUpdatedBy, lastUpdatedDate, statusUpdatedBy, statusUpdatedDate can be filtered using the following operators:

operatorvalue typedescriptionusage

eq

Int, Bool, DateTime

exact match

{templateId: {eq: 1}}

neq

Int, Bool, DateTime

doesn't match

{templateId: {eq: 1}}

in

[Int], [Bool], [DateTime]

matches one of the following

{templateId: {in: [1,2]}}

nin

[Int], [Bool], [DateTime]

doesn't match any of the following

{statusId: {nin: [1,2,3]}}

gt

Int, Bool, DateTime

greater than

{createdDate: {gt:

"2023-06-27T16:07:08.570Z"}}

ngt

Int, Bool, DateTime

not greater than

{createdDate: {gt:

"2023-06-27T16:07:08.570Z"}}

gte

Int, Bool, DateTime

greater than or equal

{createdDate: {gte:

"2023-06-27T16:07:08.570Z"}}

ngte

Int, Bool, DateTime

not greater than or equal

{createdDate: {ngte:

"2023-06-27T16:07:08.570Z"}}

lt

Int, Bool, DateTime

less than

{createdDate: {lt:

"2023-06-27T16:07:08.570Z"}}

nlt

Int, Bool, DateTime

not less than

{createdDate: {nlt:

"2023-06-27T16:07:08.570Z"}}

lte

Int, Bool, DateTime

less than or equal

{createdDate: {lte:

"2023-06-27T16:07:08.570Z"}}

nlte

Int, Bool, DateTime

not less than or equal

{createdDate: {nlte:

"2023-06-27T16:07:08.570Z"}}

and / or Filtering

All of the above operators can be combined using the and & or operators:

operatordescriptionusage

and

all conditions must be true

{ and: [ {lastUpdatedDate: {gt: "2023-06-27T16:07:08.570Z"}}, {templateId: {in: [1,2]}} ] }

or

one condition must be true

{ or: [ {lastUpdatedDate: {gt: "2023-06-27T16:07:08.570Z"}}, {templateId: {in: [1,2]}} ] }

Sorting

To sort the records in the response by a specific field, specify an order parameter:

{
    entity(id: 10, charTypeId: 4) {
       rights: children(charTypeId: 3, order: [{ lastUpdatedDate: DESC }]) {
            items {
                 id
                 title
                 template {
                      templateId
                 }
            }
       }  
    }
}

You can sort by the following fields:

  • id

  • title

  • createdBy

  • createdDate

  • lastUpdatedBy

  • lastUpdatedDate

  • statusUpdatedBy

  • statusUpdatedDate

You can sort each of the fields above either ascending using ASC or descending using DESC.

You can also sort on a field and then by another field:

{
    entity(id: 10, charTypeId: 4) {
       rights: children(charTypeId: 3, order: [{ lastUpdatedDate: DESC }, { id: ASC }]) {
            items {
                 id
                 title
                 template {
                      templateId
                 }
            }
       }  
    }
}

Last updated