What do you expect by providing null? Just need a way to return no data? What do you mean by
I believe that if you used ID for the type of id then the correct filter would be filter: { id: [$postId] } with $postId being of type ID!.
If you want to be able to provide a null variable, you could extract the [...] to the variable layer and then it would accept null: filter: { id: $postIds } with variable type $postIds: [ID!]
I cannot reproduce your error on Slash GraphQL (v20.07.1-rc1-29-g43c04cff). Your particular error may be specific to 20.11 which I don’t have up and running.
Does your setup differ from this?
Schema:
type Users {
id: String! @id
name: String
posts: [Posts]
}
type Posts {
id: String! @id
message: String
}
When $postId is null the posts edge will return an empty array. If you want
then that is different. The filter Posts.id === null is not the same as “no filter”.
To get a “no filter is applied”, you need to extrapolate the $postId into the parent type of { eq: String } which in my particular case with my schema directives is StringHashFilter Then when providing a null variable it will return all.
query UsersWithPostFilterVariable ($postIdFilter: StringHashFilter) {
queryUsers {
id
name
posts(filter: { id: $postIdFilter })
}
}
I wouldn’t suspect any of this to be any different for version 20.11 but there could very well be a bug in there.