Class: GraphqlRails::Router::ResourceRoutesBuilder

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

Overview

Generates graphql routes based on resource name and options

Constant Summary collapse

AVAILABLE_ROUTES =
%i[show index create update destroy].freeze

Instance Method Summary collapse

Constructor Details

#initialize(name, only: nil, except: [], **options) ⇒ ResourceRoutesBuilder

Returns a new instance of ResourceRoutesBuilder.



12
13
14
15
16
17
# File 'lib/graphql_rails/router/resource_routes_builder.rb', line 12

def initialize(name, only: nil, except: [], **options)
  @name = name.to_s

  @options = options
  @autogenerated_action_names = initial_action_names(only, except, AVAILABLE_ROUTES)
end

Instance Method Details

#mutation(*args, **kwargs) ⇒ Object



27
28
29
# File 'lib/graphql_rails/router/resource_routes_builder.rb', line 27

def mutation(*args, **kwargs)
  routes << build_mutation(*args, **kwargs)
end

#query(*args, **kwargs) ⇒ Object



23
24
25
# File 'lib/graphql_rails/router/resource_routes_builder.rb', line 23

def query(*args, **kwargs)
  routes << build_query(*args, **kwargs)
end

#routesObject



19
20
21
# File 'lib/graphql_rails/router/resource_routes_builder.rb', line 19

def routes
  @routes ||= initial_routes
end