Module: Graphlient::Query::Serializer::Scalars::ClassMethods
- Defined in:
- lib/graphlient/query/serializer/scalars.rb
Instance Method Summary collapse
- #all_scalar_types ⇒ Object
- #custom_scalar_types ⇒ Object
-
#scalar(sym, graphql_type) ⇒ Object
Register a custom scalar type for use in variable declarations.
Instance Method Details
#all_scalar_types ⇒ Object
38 39 40 |
# File 'lib/graphlient/query/serializer/scalars.rb', line 38 def all_scalar_types BUILT_IN_SCALAR_TYPES.merge(custom_scalar_types) end |
#custom_scalar_types ⇒ Object
34 35 36 |
# File 'lib/graphlient/query/serializer/scalars.rb', line 34 def custom_scalar_types @custom_scalar_types ||= {} end |
#scalar(sym, graphql_type) ⇒ Object
Register a custom scalar type for use in variable declarations.
Graphlient::Query::Serializer.scalar(:date, 'Date')
Typically called via the client configuration block:
client = Graphlient::Client.new(url) do |c|
c.scalar :date, 'Date'
c.scalar :uuid, 'UUID'
c.scalar :decimal, 'Decimal'
end
After registration, use the symbol in variable declarations:
query(created_after: :date) { ... } # -> query($createdAfter: Date)
30 31 32 |
# File 'lib/graphlient/query/serializer/scalars.rb', line 30 def scalar(sym, graphql_type) custom_scalar_types[sym.to_sym] = graphql_type.to_s end |