Class: NulogyGraphqlApi::GraphQLError

Inherits:
Object
  • Object
show all
Defined in:
lib/nulogy_graphql_api/graphql_error.rb

Instance Method Summary collapse

Constructor Details

#initialize(message, backtrace: nil) ⇒ GraphQLError

Returns a new instance of GraphQLError.



3
4
5
6
# File 'lib/nulogy_graphql_api/graphql_error.rb', line 3

def initialize(message, backtrace: nil)
  @message = message
  @backtrace = backtrace
end

Instance Method Details

#extensionsObject



15
16
17
18
19
20
21
# File 'lib/nulogy_graphql_api/graphql_error.rb', line 15

def extensions
  if @backtrace
    { extensions: { backtrace: @backtrace } }
  else
    {}
  end
end

#renderObject



8
9
10
11
12
13
# File 'lib/nulogy_graphql_api/graphql_error.rb', line 8

def render
  {
    data: {},
    errors: [{ message: @message }.merge(extensions)]
  }
end