Sha256: 5de1e9847d78e33832bff12561c09d19bcb3de30f4f7bb83718123df260a4ee4

Contents?: true

Size: 706 Bytes

Versions: 2

Compression:

Stored size: 706 Bytes

Contents

module GraphQL
  # If a field's resolve function returns a {ExecutionError},
  # the error will be inserted into the response's `"errors"` key
  # and the field will resolve to `nil`.
  class ExecutionError < GraphQL::Error
    # @return [GraphQL::Language::Nodes::Field] the field where the error occured
    attr_accessor :ast_node

    # @return [Hash] An entry for the response's "errors" key
    def to_h
      hash = {
        "message" => message,
      }
      if ast_node.nil?
        hash["locations"] = []
      else
        hash["locations"] = [
          {
            "line" => ast_node.line,
            "column" => ast_node.col,
          }
        ]
      end
      hash
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-0.12.1 lib/graphql/execution_error.rb
graphql-0.12.0 lib/graphql/execution_error.rb