I am working on permission queries, and I am tryin...
# prisma-whats-new
a
I am working on permission queries, and I am trying to check all existing records for a certain condition (only allow create on a new Task if all existing Tasks are completed). I can't seem to be able to rewrite that using SomeXYZExists. I have children_every to check something on ALL children, but not on ALL items. Is that possible somehow, or can it be rewritten in a way to get the same effect?
d
What exactly is preventing you from checking all existing records for a condition?
n
are all those tasks connected to a single node?
a
Well, yes...
n
of which type is that node?
a
But then we run into the PQ issue on nested mutations
Project
n
I don't think so
a
Project { ...... tasks: [Task!]! }
n
Copy code
SomeProjectExists(filter: {id: $input_projectId tasks_every: {completed: true}})
🎉 1
👍🏻 1
a
Ah, and that would be the PQ on create Task
Makes perfect sense. I completely overlooked that even though it's a PQ on Task, I can still do SomeParentExists there.
Thanks!
n
🙂
you can run any
SomeXExists
query in all PQs
a
Bonus question: how to solve this without a parent...
n
Well, I assume that in most cases it is somehow related to the user
if not, then I don't see a way either 🙂
a
Well, you could argue that having the same options for the main query would be nice, so:
Copy code
Tasks_every(filter: { completed: true})
And
_some
(the current option), and
_none
But at least this use case is solved for me! For the other ones: https://github.com/graphcool/feature-requests/issues/247
One last Q, the _meta field with count is not available in PQ right?
n
That's correct. Also saw your FR for that, thanks!