Hey guys. I’m struggling with defining permission ...
# prisma-whats-new
s
Hey guys. I’m struggling with defining permission queries for relations. For example, I have a relation called
JournalEntryOnFile
where there’s a one to one relation between a journal entry and a file upload. I’m trying to find some good code examples to see what I’m doing wrong, but struggling to find some good examples of permission queries for relations. I’ve tried many variations similar to this:
Copy code
query($journalEntry_id: ID!, $fileFile_id: ID!) {
  SomeFileExists(
    filter: { AND: [{ id: $fileFile_id }, { journalEntry: $journalEntry_id }] }
  )
}
I’m getting errors like
'$journalEntry_id' of type 'ID!' used in position expecting type 'JournalEntryFilter'
What I want to do is limit connections and disconnections to that relation to the owner of the
JournalEntry
node, which is called
user
. It’s a pretty simple use-case and I’m sure that it’s just me doing something silly with that query, so any pointer would be super appreciated.
a
to fix the error it should be something like this I think
query($journalEntry_id: ID!, $fileFile_id: ID!) { SomeFileExists( filter: { AND: [{ id: $fileFile_id }, { journalEntry: {id: $journalEntry_id} }] } ) }
sorry for the poor formatting 😛
s
Thanks so much for the help! Unfortunately, I’m still getting an error with that query:
Variable '$journalEntry_id' expected value of type 'ID!' but value is undefined. Reason: Expected non-null value, found null.
a
are you passing variables to the query?
s
I’m not passing anything explicitly no, I was under the impression that the variables get passed automatically for permission queries?
a
oh sorry. I haven’t tried permission queries on relations
s
Thanks, yes, I’m finding them to be a bit confusing and hard to debug