-
Notifications
You must be signed in to change notification settings - Fork 42
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
Configurable error messages #189
Comments
Hi @TomasBarry , have you checked if the message you are trying to customize is among the translations file? |
Hey @TomasBarry! You can actually already customize this message if you are using the
You can initialize your
that extends inherits from GraphQL::ExecutionError so an error is placed in the top level errors of the GQL response.
So, to be clear, you could do class DummySchema < GraphQL::Schema
use GraphqlDevise::SchemaPlugin.new(
query: Types::QueryType,
mutation: Types::MutationType,
unauthenticated_proc: ->(field_name) { raise GraphqlDevise::AuthenticationError, "Custom error message for #{field_name}" }
)
end Now that I'm done writing, I realize this is not what you asked 🤣 Currently I don't see a way to differentiate why authentication failed (expiration, invalid, etc). I'll take a look and see if there's something we can do to customize that, but I'm thinking that if anything, it might have to happen at the controller level and not the GQL schema as we moved away from authenticating inside the schema. |
@mcelicalderon you're spot on. |
What is the problem the enhancement will solve?
When a token has expired, the error message returned is
x field requires authentication
. It would be great to be able to customise the error message and differentiate between the token being expired due to it having exceeded the lifespan, or whether it is invalidated due to previous usage.Describe the solution you have in mind
Configurable error messages in general.
Describe alternatives you've considered
Writing custom logic in the controller to test the different scenarios and overload the response.
This seems a bit flakey though if the API of this gem were to change.
The text was updated successfully, but these errors were encountered: