Hi Michael,
Sorry for the delay on this one. I’m glad to see you answered your 2nd question. I’ve added some more details below and answered the rest as well.
- Why is the first retrieved record present? It has a state of Standard, not Candidate.
I think this is a bug in the GraphQL, where is is searching for any item that has “ever had a status” of Candidate, not searching for items where the “current status” is Candidate. We’ll look into corecting this, and will also look at adding some extra queries for “status level X or above” and “ever had a status of X” as well.
- I can see in pageInfo that there are more pages to retrieve. How can I get page 2 instead of page 1?
In GraphQL you request a page, you can specify the point the “cursor” starts at by adding a “after” parameter. For example, you can request the first 5 metadata items from an Aristotle Metadata Registry like this:
query {
metadata (first: 5) {
pageInfo {
endCursor
hasNextPage
}
edges {
node {
uuid
name
}
}
}
}
Which will return a pageInfo
section below that will help you paginate the query:
{
"data": {
"metadata": {
"pageInfo": {
"endCursor": "YXJyYXljb25uZWN0aW9uOjQ=",
"hasNextPage": true
},
"edges": [
# A list of metadata here.
]
}
}
}
The important section is the endCursor
(in this case YXJyYXljb25uZWN0aW9uOjQ=
) which is GraphQL idendifier for the last item in this set.
In the next query you can modify the query to request items after this cursor to get the next set:
metadata (first: 5, after: "YXJyYXljb25uZWN0aW9uOjQ=") {
This modified query with then get the first 5 items after the cursor point, and this query will give the endCursor that can be used for a 3rd query, and so on…
- Is there a reason why we need to specify “candidate” in the query with all lower case, when the field we’re searching for in the results will start with a capital letter “Candidate”?
This was just a system design preference, but could be improved. The query is designed to use the system identifier for the status level (“candidate”) and returns a human readable result (“Candidate”).
- How would I modify this query to pick up all data elements that are Candidate or Recorded? graphQL doesn’t like lines like “dataElements(status: “candidate”, status: “recorded”)”
For this you’ll need to multiple queries, but this can be done with GraphQL variables. Queries can accept a variable, which can be set when calling the query. For example, this query:
query ($state:String) {
properties (status: $state) {
With this variables object, will all you to query recorded items only.
{
"state": "recorded",
}
Then when rerunning the query, you can just change the Variables object. But how this is called will depend on the language you are using.