Class: Hai::GraphQL::ReadQueries
- Inherits:
-
Object
- Object
- Hai::GraphQL::ReadQueries
- Defined in:
- lib/hai/graphql/read_queries.rb
Class Method Summary collapse
- .add(query_type, model) ⇒ Object
- .add_field(query_type, model) ⇒ Object
- .define_read_method(query_type, model) ⇒ Object
Class Method Details
.add(query_type, model) ⇒ Object
5 6 7 8 |
# File 'lib/hai/graphql/read_queries.rb', line 5 def add(query_type, model) add_field(query_type, model) define_read_method(query_type, model) end |
.add_field(query_type, model) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hai/graphql/read_queries.rb', line 10 def add_field(query_type, model) query_type.field( "read_#{model.name.downcase}", "Types::#{model}Type".constantize ) do query_type.description("List a single #{model}.") model.attribute_types.each do |attr, type| argument( attr, Hai::GraphQL::AREL_TYPE_CAST[type.class] || Hai::GraphQL::Types::Arel::IntInputType, required: false ) end end end |