Swapnull
12/02/2020, 4:35 PMconst isAuthed = rule()(async (parent, args, ctx) => {
const recordId = ctx.where?.id?.equals;
/* do rest of auth using recordId */
}
This obviously sucks because if the FE chooses to use in
or contains
or any other input, it won't work.
One thing we have thought is to allow something like
query getRecords {
records(recordId: "someId") {
uuid
}
}
But when creating the record query we have
t.crud.records({ filtering: true, ordering: true, pagination: true });
and we can't find a way to say for type query
on records
accept a recordId
argument.
The other option is to run the query and then check when it comes back.
Anybody have any thoughts on how they are authorising these types of owned records?Ryan
12/03/2020, 7:28 AMuserId
beforehand in the resolver after adding the filters.
Something like:
prisma.record.findMany({
where: {
userId: 1,
...restOfTheFilters
}
})
This is something that could be explored where the userId
can be obtained from the context
. Iām doubtful that this could be solved with graphql-shield
due to the fact that the filter arguments could contain anything here.
Let me know if this is a viable solution.Swapnull
12/03/2020, 9:25 AM