What I would expect after working with and/or logic in the auth directive is for it to work almost the same way with arrays with the first and being understood.
I understand this would be a breaking change because there is no way to right GraphQL schema where a filter can be either an object or an array so filter: {title: {...}} would no longer work if this is implemented
These two queries would be equivalent:
# with understood `and`
query example1 {
queryPost(filter: [
{title: {allofterms: "GraphQL"}},
{title: {allofterms: "Dgraph" }}
] ) { ... }
}
# with defined `and` using an array:
query example1 {
queryPost(filter: [{
and: [
{title: {allofterms: "GraphQL"}},
{title: {allofterms: "Dgraph" }}
]
}] ) { ... }
}
Notice that filter would require an array instead of an object. This would be needed because { title: {...}, title: {...} } does not validate, but [{title: {...}}, {title: {...}}] does validate
This would also make nested and/or logic easier to understand:
Yes. The behaviour would be similar to what we have for auth rules. We have noted this down in bug’s list and I will update you on the timeline after discussing with the team.
I understand. I am just thinking of the longevity of Dgraph. Fix it now early on when there are less users who it causes breaking change to, or do it later when it affects even more. This will be an endless battle with breaking changes to the graphql generated schema.
I did not realize that this could be accomplished without breaking changes with some current somewhat obscur and hidden spec features: GraphQL
If the value passed as an input to a list type is not a list and not the null value, then the result of input coercion is a list of size one, where the single item value is the result of input coercion for the list’s item type on the provided value
@arijit I believe that this will resolve this “bug” with an updated doc page changing some wording that indicate the list brackets are implicit for a single filter object for any and & or blocks. Feel free to close this as you see fit.