Class: GraphqlRails::Router::ResourceRoutesBuilder
- Inherits:
-
Object
- Object
- GraphqlRails::Router::ResourceRoutesBuilder
- 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
-
#initialize(name, only: nil, except: [], **options) ⇒ ResourceRoutesBuilder
constructor
A new instance of ResourceRoutesBuilder.
- #mutation(*args, **kwargs) ⇒ Object
- #query(*args, **kwargs) ⇒ Object
- #routes ⇒ Object
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: [], **) @name = name.to_s @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 |
#routes ⇒ Object
19 20 21 |
# File 'lib/graphql_rails/router/resource_routes_builder.rb', line 19 def routes @routes ||= initial_routes end |