Class: Dry::GraphQL::SchemaBuilder
- Inherits:
-
Object
- Object
- Dry::GraphQL::SchemaBuilder
- Defined in:
- lib/dry/graphql/schema_builder.rb
Overview
Reduces a DRY type to a GraphQL type
Defined Under Namespace
Classes: NameGenerationError, TypeMappingError
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #graphql_type ⇒ Object
-
#initialize(name: nil, type: nil, schema: nil, parent: nil, options: {}) ⇒ SchemaBuilder
constructor
A new instance of SchemaBuilder.
- #reduce_with(*args) ⇒ Object
- #with(opts) ⇒ Object
Constructor Details
#initialize(name: nil, type: nil, schema: nil, parent: nil, options: {}) ⇒ SchemaBuilder
Returns a new instance of SchemaBuilder.
22 23 24 25 26 27 28 |
# File 'lib/dry/graphql/schema_builder.rb', line 22 def initialize(name: nil, type: nil, schema: nil, parent: nil, options: {}) @name = name @type = type @schema = schema = @parent = parent end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
17 18 19 |
# File 'lib/dry/graphql/schema_builder.rb', line 17 def field @field end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/dry/graphql/schema_builder.rb', line 17 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/dry/graphql/schema_builder.rb', line 17 def end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
17 18 19 |
# File 'lib/dry/graphql/schema_builder.rb', line 17 def parent @parent end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
17 18 19 |
# File 'lib/dry/graphql/schema_builder.rb', line 17 def schema @schema end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
17 18 19 |
# File 'lib/dry/graphql/schema_builder.rb', line 17 def type @type end |
Class Method Details
.build_graphql_schema_class(name) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/dry/graphql/schema_builder.rb', line 45 def self.build_graphql_schema_class(name) Dry::Core::ClassBuilder.new( name: name, parent: ::Dry::GraphQL::BaseObject, namespace: Dry::GraphQL::GeneratedTypes ).call end |
Instance Method Details
#graphql_type ⇒ Object
41 42 43 |
# File 'lib/dry/graphql/schema_builder.rb', line 41 def graphql_type reduce end |
#reduce_with(*args) ⇒ Object
37 38 39 |
# File 'lib/dry/graphql/schema_builder.rb', line 37 def reduce_with(*args) with(*args).reduce end |
#with(opts) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/dry/graphql/schema_builder.rb', line 30 def with(opts) self.class.new({ name: @name, type: @type, schema: @schema, options: , parent: self }.merge(opts)) end |