I am trying to query a GraphQL endpoint, and struggling with a many-to-many relationship.
https://developer.getadministrate.com/docs/core/api#TrainingPassAssignment
Basically, my stakeholder wants to know what accounts were assigned a training pass. On the TrainingPass endpoint, there is an Account link, but this is a one-to-many (1 training pass can be assigned to many accounts).
{
trainingPasses(filters:[]) {
edges{
node{
id
lifecycleState
validFrom
validUntil
account{
id
}
}
}
}
}
This does not work:
{"errors":[{"message":"Cannot return null for non-nullable field TrainingPass.account.","locations":[{"line":9,"column":9}],"path":["trainingPasses","edges",44,"node","account"],"trace_id":"Root=1-66db693f-350e72f245a286e344efd941","query_error_fragment":["account {id}"]}],"data":null}
I understand I probably need to paginate through the accounts to grab all of them, but this seems inefficient + I am not sure how the syntax works for these items:
The Account linked to the Training Pass
filters
[AccountFieldGraphFilter]
order
AccountFieldGraphOrder
first
Int
offset
Int
after
String
orderBy
[AccountFieldGraphOrder]
According to the documentation, there is an object called “TrainingPassAssignment” but when I actually try to query this, it says the object does not exist.