Sha256: 5cbcd0ff66f008b8f8749e4ddc8c76ac6c449a186a74f3beaa534d85e13be5a3
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
module RuboCop module Cop module Ezcater # 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 }) class RspecRequireGqlErrorHelpers < Cop MSG = "Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly.".freeze def_node_matcher :graphql_const?, <<~PATTERN (const (const _ :GraphQL) :ExecutionError) PATTERN def on_const(node) return unless graphql_const?(node) add_offense(node, location: :expression, message: MSG) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ezcater_rubocop-0.51.6 | lib/rubocop/cop/ezcater/rspec_require_gql_error_helpers.rb |
ezcater_rubocop-0.51.5 | lib/rubocop/cop/ezcater/rspec_require_gql_error_helpers.rb |