The goal of this document is to articulate and spec out a GraphQL query that would allow a GraphQL query to:
- Get a list of all of the certificates awarded for a course or list of courses
- Allow query filtering by
startDateandendDatewhich would only show certificates granted between those two dates - Allow query filtering by
userIdsto limit the returned certificates to only those awarded to those specific users
The proposed schema is very similar to the existing CourseUserVisits query, but instead of returning CourseUsers based on visit count, the new CourserUserCertificates query would return certificates filtered by startDate, endDate, and userIds for all courses or the courses specified in the courseIds argument.
{
"name": "courseCertificates",
"description": "This query will get back course user certificates data for specfied courses.",
"args": [
{
"name": "courseIds",
"description": null,
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
}
},
"defaultValue": null
},
{
"name": "limit",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "offset",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
}
],
"fields": [
{
"name": "id",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "courseId",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "certificates",
"description": "A list of the course granted certificated",
"args": [
{
"name": "userIds",
"description": null,
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
}
},
"defaultValue": null
},
{
"name": "uid",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "startDate",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Date",
"ofType": null
},
"defaultValue": null
},
{
"name": "endDate",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Date",
"ofType": null
},
"defaultValue": null
},
{
"name": "limit",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "offset",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "UserCertificate",
"ofType": null
}
}
}
],
"isDeprecated": false,
"deprecationReason": null
}Below is an example of the three queries that would accomplish the above 3 objectives.
All three examples would use the same query, but with a different set of variable values:
query CourseCertificates(
$courseIds: [Int],
$limit: Int,
$offset: Int,
$startDate: Date,
$endDate: Date,
$userIds: [Int]
) {
courseCertificates(
courseIds: $courseIds,
limit: $limit,
offset: $offset
) {
courseId
certificates(
userIds: $userIds,
startDate: $startDate,
endDate: $endDate
) {
awardedAt
userId
}
}
}Omitting all values other than courseIds would return the certificates for all of the courses.
{
"limit": null,
"offset": null,
"courseIds": [555555],
"startDate": null,
"endDate": null
}Setting the startDate and endDate would filter the certificates to only show those that have an awardedAt date between the two date values.
{
"limit": null,
"offset": null,
"courseIds": [555555],
"startDate": "2025-12-18",
"endDate": "2025-12-17"
}Settings the userIds value would allow for the certificates to be filter only to users with matching userIds in the courses matching the coursesIds.
{
"limit": null,
"offset": null,
"courseIds": [555555],
"userIds": [10000021]
}