Module: GraphQL::DSL::SelectionSet
- Included in:
- Field, FragmentOperation, InlineFragment, Operation
- Defined in:
- lib/graphql/dsl/nodes/mixins/selection_set.rb
Overview
This mixin help to reuse selections sets
Instance Method Summary collapse
-
#__field(name, __alias: nil, __directives: [], **arguments, &block) ⇒ void
Declare new GraphQL field.
-
#__fragment(name, __directives: []) ⇒ void
Insert GraphQL fragment.
-
#__inline_fragment(type, __directives: [], &block) ⇒ void
Insert GraphQL inline fragment.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
Declare new GraphQL field
99 100 101 102 103 |
# File 'lib/graphql/dsl/nodes/mixins/selection_set.rb', line 99 def method_missing(name, *args, &block) arguments = args.empty? ? {} : args[0] __field(name, **arguments, &block) end |
Instance Method Details
#__field(name, __alias: nil, __directives: [], **arguments, &block) ⇒ void
This method returns an undefined value.
Declare new GraphQL field
This method can help to avoid name collisions i.e. __field(:object_id)
36 37 38 |
# File 'lib/graphql/dsl/nodes/mixins/selection_set.rb', line 36 def __field(name, __alias: nil, __directives: [], **arguments, &block) # rubocop:disable Lint/UnderscorePrefixedVariableName @__nodes << Field.new(name, __alias, arguments, __directives, &block) end |
#__fragment(name, __directives: []) ⇒ void
This method returns an undefined value.
Insert GraphQL fragment
54 55 56 |
# File 'lib/graphql/dsl/nodes/mixins/selection_set.rb', line 54 def __fragment(name, __directives: []) # rubocop:disable Lint/UnderscorePrefixedVariableName @__nodes << FragmentSpread.new(name, __directives) end |
#__inline_fragment(type, __directives: [], &block) ⇒ void
This method returns an undefined value.
Insert GraphQL inline fragment
66 67 68 |
# File 'lib/graphql/dsl/nodes/mixins/selection_set.rb', line 66 def __inline_fragment(type, __directives: [], &block) # rubocop:disable Lint/UnderscorePrefixedVariableName @__nodes << InlineFragment.new(type, __directives, &block) end |