Class: GraphitiGql::Schema::Fields::Show
- Inherits:
-
Object
- Object
- GraphitiGql::Schema::Fields::Show
- Defined in:
- lib/graphiti_gql/schema/fields/show.rb
Instance Method Summary collapse
- #apply(query) ⇒ Object
-
#initialize(registered) ⇒ Show
constructor
A new instance of Show.
Constructor Details
#initialize(registered) ⇒ Show
Returns a new instance of Show.
5 6 7 |
# File 'lib/graphiti_gql/schema/fields/show.rb', line 5 def initialize(registered) @registered = registered end |
Instance Method Details
#apply(query) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/graphiti_gql/schema/fields/show.rb', line 9 def apply(query) field = query.field name, @registered[:type], null: true, extras: [:lookahead] unless @registered[:resource].singular field.argument(:id, GraphQL::Types::ID, required: true) end _registered = @registered query.define_method name do |**arguments| params = Util.params_from_args(arguments) _registered[:resource].find(params).data end end |