class RuboCop::Cop::Ezcater::RequireGqlErrorHelpers
Enforce use of GQLErrors helpers instead of throwing GraphQL::ExecutionErrors directly
@example
# good GQLErrors.summary_error("An error occurred") GQLErrors.request_error("You can't access this", 401) GQLErrors.field_error("is invalid", :first_name, "First Name") GQLErrors.field_errors_for(my_model, context) GQLErrors.field_errors_for(my_model, context, summary_error: "An error occurred") GQLErrors.field_errors_for(my_model, context, field_mapping: { first: :first_name }) # bad GraphQL::ExecutionError.new("An error occurred") GraphQL::ExecutionError.new("You can't access this", options: { status_code: 401 })
Constants
- MSG
Public Instance Methods
on_const(node)
click to toggle source
# File lib/rubocop/cop/ezcater/require_gql_error_helpers.rb, line 29 def on_const(node) return unless graphql_const?(node) add_offense(node, location: :expression, message: MSG) end