You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So when a user is not authenticated, I expect the Unauthenticated error to be returned, but instead I get the Not authorized to access #{type}.#{field} defined in graphl_controller.rb.
Question:
Would it make sense to add the context to the callback so one could do something like this?
use GraphQL::Guard.new(
policy_object: GraphqlPolicy,
not_authorized: ->(type, field, ctx) do
ctx.add_error(GraphQL::ExecutionError.new("Not authorized to access #{type}.#{field}"))
end
)
That way we wouldn't remove any other errors that are in there and we can see that we are in fact unauthenticated as well as unauthorized.
The text was updated successfully, but these errors were encountered:
I am in need of this feature as well. I need to be able to tell the difference between a user trying to access a field they're not authorized to access vs the user is not logged in at all.
This is a question as well as a suggestion.
I'm combining graphql-ruby and graphql-guard with Doorkeeper+Sorcery to handle my authentication. In my
graphql_controller.rb
I have:And my policy is:
So when a user is not authenticated, I expect the
Unauthenticated
error to be returned, but instead I get theNot authorized to access #{type}.#{field}
defined ingraphl_controller.rb
.Question:
Would it make sense to add the context to the callback so one could do something like this?
That way we wouldn't remove any other errors that are in there and we can see that we are in fact unauthenticated as well as unauthorized.
The text was updated successfully, but these errors were encountered: