Class: Stardust::GraphQLController

Inherits:
ActionController::API
  • Object
show all
Defined in:
app/controllers/stardust/graphql_controller.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/stardust/graphql_controller.rb', line 4

def execute
  result = nil

  around_execute do
    result = GraphQL::Schema.execute(
      query,
      variables: variables,
      context: context.merge({tracing_enabled: tracing_enabled}),
      operation_name: operation_name
    )
  end
  render json: ApolloFederation::Tracing.attach_trace_to_result(result)


rescue Stardust::Errors::FailedAuthorization => e
  render json: {
    error: { message: e.message }
  }, status: 401
rescue StandardError => e
  raise e unless Rails.env.development?
  handle_error_in_development e
end