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.
23 24 25 26 27 28 29 |
# File 'lib/dry/graphql/schema_builder.rb', line 23 def initialize(name: nil, type: nil, schema: nil, parent: nil, options: {}) @name = name @type = type @schema = schema @options = @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 @options 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
46 47 48 49 50 51 |
# File 'lib/dry/graphql/schema_builder.rb', line 46 def self.build_graphql_schema_class(name) Dry::Core::ClassBuilder.new( name: "DryGraphQLGeneratedTypeFor#{name}", parent: ::Dry::GraphQL::BaseObject ).call end |
Instance Method Details
#graphql_type ⇒ Object
42 43 44 |
# File 'lib/dry/graphql/schema_builder.rb', line 42 def graphql_type reduce end |
#reduce_with(*args) ⇒ Object
38 39 40 |
# File 'lib/dry/graphql/schema_builder.rb', line 38 def reduce_with(*args) with(*args).reduce end |
#with(opts) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/dry/graphql/schema_builder.rb', line 31 def with(opts) self.class.new(**{ name: @name, type: @type, schema: @schema, options: @options, parent: self }.merge(opts)) end |