Class: Graphql::Generators::ObjectGenerator
- Inherits:
-
TypeGeneratorBase
- Object
- Rails::Generators::NamedBase
- TypeGeneratorBase
- Graphql::Generators::ObjectGenerator
- Includes:
- FieldExtractor
- Defined in:
- lib/generators/graphql/object_generator.rb
Overview
Generate an object type by name, with the specified fields.
rails g graphql:object PostType name:String!
Add the Node interface with --node
.
Class Method Summary collapse
Methods included from FieldExtractor
#column_type_string, #fields, #generate_column_string, #klass
Methods inherited from TypeGeneratorBase
Methods included from Core
#create_dir, #insert_root_type, #module_namespacing_when_supported, #schema_file_path
Class Method Details
.normalize_type_expression(type_expression, mode:, null: true) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/generators/graphql/object_generator.rb', line 26 def self.normalize_type_expression(type_expression, mode:, null: true) case type_expression.camelize when "Text", "Citext" ["String", null] when "Decimal" ["Float", null] when "DateTime", "Datetime" ["GraphQL::Types::ISO8601DateTime", null] when "Date" ["GraphQL::Types::ISO8601Date", null] when "Json", "Jsonb", "Hstore" ["GraphQL::Types::JSON", null] else super end end |