So I thought I had this working, but as soon as I wanted to allow some fields to be public I ran back into these issues.
I added a new role that has “read” for some fields and put it to the right of the existing role. This worked and I could now retrieve all records from any user using graphql.
However, I don’t want to always get all of them, I want an individual user to see their own records only most of the time. To that end I modified my graphql query to filter by the user’s own ID:
query MyListings($userId: ObjectId!) {
listings(query: {
user_id: {
_id: $userId
}
}) {
_id
description
}
}
This unfortunately returns no results:
{
"data": {
"listings": []
}
}
And yes, I’m sure the userID is correct and on the records. I copy-pasted it and even altered some records to have their user_id set to ffffffffffffffffffffffff
and ran it with that - no luck.
To validate that I’m using the query-input types correctly I also ran this query which did return results:
query ListingsWithDescription($description: String!) {
listings(query: {
description: $description
}) {
_id
description
}
}
Not sure where to go from here, this seems like a continuation of the initial problem. I’ve been unable to resolve it.
ObjectId clearly behaves differently as indicated by the other thread - but its not clear how to filter on an ObjectId field.
How can I filter to a specific user’s listings?