Class: ActiveAdmin::GraphQL::RunActionMutationDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/active_admin/graphql/run_action_mutation_dsl.rb

Overview

Nested DSL for a single run-action mutation kind (batch_action_mutation, etc.): type and resolve, similar to graphql-ruby pairing field type with resolution.

Instance Method Summary collapse

Constructor Details

#initialize(mutation_config) ⇒ RunActionMutationDSL

Returns a new instance of RunActionMutationDSL.



10
11
12
# File 'lib/active_admin/graphql/run_action_mutation_dsl.rb', line 10

def initialize(mutation_config)
  @mutation_config = mutation_config
end

Instance Method Details

#arguments(&block) ⇒ Object

Per-action fields only: extra GraphQL arguments (+argument :reason, String, …+). Not used on the aggregate posts_member_action(action: …) field.



27
28
29
# File 'lib/active_admin/graphql/run_action_mutation_dsl.rb', line 27

def arguments(&block)
  @mutation_config.arguments_proc = block
end

#authorize(value = true) ⇒ Object



31
32
33
# File 'lib/active_admin/graphql/run_action_mutation_dsl.rb', line 31

def authorize(value = true)
  @mutation_config.authorize = !!value
end

#resolve(&block) ⇒ Object



21
22
23
# File 'lib/active_admin/graphql/run_action_mutation_dsl.rb', line 21

def resolve(&block)
  @mutation_config.resolve_proc = block
end

#type(gql_object_class) ⇒ Object Also known as: payload_type

GraphQL object type for this mutation field (alias: payload_type).



15
16
17
18
# File 'lib/active_admin/graphql/run_action_mutation_dsl.rb', line 15

def type(gql_object_class)
  RunActionMutationConfig.ensure_graphql_object_subclass!(gql_object_class)
  @mutation_config.payload_type = gql_object_class
end