Sha256: 8f4fe23395f08158537b5764f20865948b43135d5e1c76f19a1a18502349051a

Contents?: true

Size: 704 Bytes

Versions: 14

Compression:

Stored size: 704 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 < RuntimeError
    # @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

14 entries across 14 versions & 1 rubygems

Version Path
graphql-0.11.1 lib/graphql/execution_error.rb
graphql-0.11.0 lib/graphql/execution_error.rb
graphql-0.10.9 lib/graphql/execution_error.rb
graphql-0.10.8 lib/graphql/execution_error.rb
graphql-0.10.7 lib/graphql/execution_error.rb
graphql-0.10.6 lib/graphql/execution_error.rb
graphql-0.10.5 lib/graphql/execution_error.rb
graphql-0.10.4 lib/graphql/execution_error.rb
graphql-0.10.3 lib/graphql/execution_error.rb
graphql-0.10.2 lib/graphql/execution_error.rb
graphql-0.10.1 lib/graphql/execution_error.rb
graphql-0.10.0 lib/graphql/execution_error.rb
graphql-0.9.5 lib/graphql/execution_error.rb
graphql-0.9.4 lib/graphql/execution_error.rb