Tray Embedded / Embedded APIs / Intro to the APIs / Breakdown of an API

Breakdown of an API

Breakdown of a query

The following example queries the recorded end users:

query {
users(first: 2) {
edges {
node {
id
name
externalUserId
}
cursor
}
pageInfo {
hasNextPage
endCursor
}
}
}

For each user it can be seen that there is:

  • An edge. This groups the metadata associated with the object

Within each edge we have:

  • A node. This is the actual user object. Within the node you can specify exactly what data you want in return. So if, for example, you don't need 'name' just leave it out!
  • An optional cursor which can be used for pagination

Then for the page of results we also have:

  • pageInfo. This is also relevant for pagination of results
{
"data": {
"users": {
"edges": [
{
"node": {
"id": "d9b7302f-84we-4acb-8afe-b403242e3f26",
"name": "Gene Wolfe",
"externalUserId": "96f233085cd7"
},
"cursor": "ZDliNzMwMmYtcudhdYwThhZmUtYjQwMzI0MmUzZjI2"
},
{
"node": {
"id": "8db466c0-a041-4934-af35-158c704c59de",
"name": "Miguel Rangel",
"externalUserId": "96b93270-c55d-11e8-86ce-b79e66872daa"
},
"cursor": "OGRiNDY2YzAtYT8884fUIjjmMzUtHU5dtM1OWRl"
}
],
"pageInfo": {
"hasNextPage": true,
"endCursor": "OGRiNDY2Yzjfuey78YY90LWFmMzUtMTU4YzcwNGM1OWRl"
}
}
}
}