Module: GraphQL::SchemaDirectives::HasDirectives
- Included in:
- InitializeWithDirectives
- Defined in:
- lib/graphql/schema_directives/has_directives.rb
Instance Attribute Summary collapse
-
#schema_directives ⇒ Object
readonly
Returns the value of attribute schema_directives.
Instance Method Summary collapse
Instance Attribute Details
#schema_directives ⇒ Object (readonly)
Returns the value of attribute schema_directives.
5 6 7 |
# File 'lib/graphql/schema_directives/has_directives.rb', line 5 def schema_directives @schema_directives end |
Instance Method Details
#add_directive(name, arguments = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/graphql/schema_directives/has_directives.rb', line 7 def add_directive(name, arguments=nil) raise ArgumentError, 'directive name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol) raise ArgumentError, 'directive arguments must be a Hash or nil' unless arguments.is_a?(Hash) || arguments.nil? @schema_directives ||= [] @schema_directives << { name: name, arguments: arguments } end |
#to_graphql ⇒ Object
17 18 19 20 21 |
# File 'lib/graphql/schema_directives/has_directives.rb', line 17 def to_graphql type = super type.[:schema_directives] = @schema_directives type end |