Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to tell which record is causing GraphQL::Guard::NotAuthorizedError to be raised? #54

Open
asgeo1 opened this issue Mar 20, 2023 · 0 comments

Comments

@asgeo1
Copy link

asgeo1 commented Mar 20, 2023

I'm getting the Not authorized to access: Xxxxx.id (GraphQL::Guard::NotAuthorizedError) error in my logs, but are often not sure which record it's talking about, and it's making it a real pain to debug issues.

It usually happens when a GraphQL query with multiple levels of nested fields is executed, and the error is something deeper in the structure, so it can't easily be worked out, by just looking at the arguments.

What I would like to do, is override the default error message so that it prints something like:

raise NotAuthorizedError.new("Not authorized to access: #{type}.#{field} for #{type}.id = #{trace_data[:object].try(:id)}")

and then I'll better understand which record it's referring to when I see this error.

Looking at the source code, I think that it's not currently possible since the 'object' is not passed to the proc. But just putting this here as I think it would be really useful to be able to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant