Improved API docs autogeneration
This commit is contained in:
@@ -7,14 +7,14 @@ module Graphqlable
|
|||||||
self.name.gsub('::', '_').underscore.to_sym
|
self.name.gsub('::', '_').underscore.to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
def graphql_pluralized_field_name
|
|
||||||
self.name.gsub('::', '_').underscore.pluralize.to_sym
|
|
||||||
end
|
|
||||||
|
|
||||||
def graphql_field_description
|
def graphql_field_description
|
||||||
"Find one #{self.model_name.human} by ID"
|
"Find one #{self.model_name.human} by ID"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def graphql_pluralized_field_name
|
||||||
|
self.name.gsub('::', '_').underscore.pluralize.to_sym
|
||||||
|
end
|
||||||
|
|
||||||
def graphql_pluralized_field_description
|
def graphql_pluralized_field_description
|
||||||
"Find all #{self.model_name.human.pluralize}"
|
"Find all #{self.model_name.human.pluralize}"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,6 +61,18 @@ module ActsAsTaggableOn
|
|||||||
|)
|
|)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.graphql_field_name
|
||||||
|
:tag
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.graphql_pluralized_field_name
|
||||||
|
:tags
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.graphql_type_name
|
||||||
|
'Tag'
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def custom_counter_field_name_for(taggable_type)
|
def custom_counter_field_name_for(taggable_type)
|
||||||
"#{taggable_type.underscore.pluralize}_count"
|
"#{taggable_type.underscore.pluralize}_count"
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ module GraphQL
|
|||||||
fields.each do |field_name, field_type|
|
fields.each do |field_name, field_type|
|
||||||
case ApiTypesCreator.type_kind(field_type)
|
case ApiTypesCreator.type_kind(field_type)
|
||||||
when :scalar
|
when :scalar
|
||||||
field(field_name, SCALAR_TYPES[field_type])
|
field(field_name, SCALAR_TYPES[field_type], model.human_attribute_name(field_name))
|
||||||
when :singular_association
|
when :singular_association
|
||||||
field(field_name, -> { api_types_creator.created_types[field_type] }) do
|
field(field_name, -> { api_types_creator.created_types[field_type] }) do
|
||||||
resolve -> (object, arguments, context) do
|
resolve -> (object, arguments, context) do
|
||||||
|
|||||||
Reference in New Issue
Block a user