Class: GraphqlRails::QueryRunner

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
lib/graphql_rails/query_runner.rb

Overview

executes GraphQL queries and returns json

Instance Method Summary collapse

Constructor Details

#initialize(params:, context: {}, schema: nil, router: nil, group: nil, **schema_options) ⇒ QueryRunner

rubocop:disable Metrics/ParameterLists



11
12
13
14
15
16
17
18
# File 'lib/graphql_rails/query_runner.rb', line 11

def initialize(params:, context: {}, schema: nil, router: nil, group: nil, **schema_options) # rubocop:disable Metrics/ParameterLists
  @group = group
  @graphql_schema = schema
  @params = params
  @router = router
  @initial_context = context
  @schema_options = schema_options
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
# File 'lib/graphql_rails/query_runner.rb', line 20

def call
  graphql_schema.execute(
    params[:query],
    variables: variables,
    operation_name: params[:operationName],
    context: context,
    **schema_options
  )
end