graphql error querying with user id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2021
11:16 PM
Hi
I'm having a problem get data for a specific user from the graphql API
my graphql query is:
query MyQuery($courseID: ID!) {
course(id: $courseID) {
enrollmentsConnection {
nodes {
type
user(id: $userID) {
_id
name
}
}
}
}
}
variables are:
{"courseID": redacted, "userID": redacted}
and the response is:
{
"errors": [
{
"message": "Field 'user' doesn't accept argument 'id'",
"locations": [
{
"line": 6,
"column": 14
}
],
"path": [
"query MyQuery",
"course",
"enrollmentsConnection",
"nodes",
"user",
"id"
],
"extensions": {
"code": "argumentNotAccepted",
"name": "user",
"typeName": "Field",
"argumentName": "id"
}
}
]
}
Are we waiting for user to be made queriable?
How do you query a user's enrolments?
Solved! Go to Solution.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2021
07:28 PM
You can only use filters where they're allowed (E.g. the purple text in Canvas GraphQL explorer)
If you want to query on a particular user, you can use "legacyNode"
E.g.
query MyQuery {
legacyNode(_id: "9", type: User) {
... on User {
id
email
enrollments {
state
type
course {
name
}
}
}
}
}