GraphQL Relationship Resolved w/o Context
Hi there, 👋
I have a query like
which I need to filter with a
Ash.Query.after_action
.
The filter is called as expected, but the actor of the request (available in the outer filter with the correct value) is nil
for this nested.
Do I manually need to forward the context in some way or might that be a bug?
This is the stack trace raising an exception from Ash.Query.after_action
(no error, but manually raised to get the stack):
12 Replies
These are the Ash-related dependencies I’m using:
Can I see what your after action hook looks like?
Sorry, I missed your question earlier! Here you go:
In that function:
can you add a change to the root resource and see if the actor is being passed at all?
I don't see a reason why the actor wouldn't be available in that context you showed
Yes, I’ll add the same debug statement. Gimme a minute.
It’s weird: The inner query is kind of executed first
I thought, that I may have added some query as a precondition, but that’s not the case: If I remove the relation in the query, there’s no query to the events table at all.
it has to do with the after action hooks
i.e the inner query's "after action" happens before the outer query's "after action"
and you're on the latest ash_graphql?
I figured it out
Yes, it’s 0.25.5 and installed as that version and not directly from master.
releasing a fix now. I was a bit worried as this sounded like something that could affect authorization
like the builtin policy authorization
but its not really, only if you have query preparations that reference the actor on read
I guess in some designs it could have been a security issue
but not for people using the policy authorizer at least
basically the case is when ash_graphql loaded related things, query preparations would get
actor: nil
but its highly unlikely that that would cause things to be less secure
more like more secure
(well, accidentally secure, preventing users who should be able to do things from doing them)Which is at least conservative and wouldn’t compromise date.
Yeah
anyway
0.25.6
is out w/ the fix 🙂Wow, you’re wild! 😀
Yes, that works: I can confirm that I now get the same context and my filters show the right data. Pew… 😌 As always: Thanks again for your fast help! 🚀
My pleasure 🙂