Class: GraphqlRails::Router::BuildSchemaActionType

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql_rails/router/build_schema_action_type.rb

Overview

Builds GraphQL type used in graphql schema

Defined Under Namespace

Classes: SchemaActionType

Constant Summary collapse

ROUTES_KEY =
:__routes__

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_name:, routes:) ⇒ BuildSchemaActionType

Returns a new instance of BuildSchemaActionType.



63
64
65
66
# File 'lib/graphql_rails/router/build_schema_action_type.rb', line 63

def initialize(type_name:, routes:)
  @type_name = type_name
  @routes = routes
end

Class Method Details

.call(**kwargs) ⇒ Object



59
60
61
# File 'lib/graphql_rails/router/build_schema_action_type.rb', line 59

def self.call(**kwargs)
  new(**kwargs).call
end

Instance Method Details

#callObject



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/graphql_rails/router/build_schema_action_type.rb', line 68

def call
  type_name = self.type_name
  scoped_routes = self.scoped_routes

  Class.new(SchemaActionType) do
    graphql_name(type_name)

    fields_for_nested_routes(
      type_name_prefix: type_name,
      scoped_routes: scoped_routes
    )
  end
end