Improved API docs autogeneration

This commit is contained in:
Alberto Miedes Garcés
2017-01-27 12:39:44 +01:00
parent 6101848f7a
commit 073ce38a8d
3 changed files with 17 additions and 5 deletions

View File

@@ -7,14 +7,14 @@ module Graphqlable
self.name.gsub('::', '_').underscore.to_sym
end
def graphql_pluralized_field_name
self.name.gsub('::', '_').underscore.pluralize.to_sym
end
def graphql_field_description
"Find one #{self.model_name.human} by ID"
end
def graphql_pluralized_field_name
self.name.gsub('::', '_').underscore.pluralize.to_sym
end
def graphql_pluralized_field_description
"Find all #{self.model_name.human.pluralize}"
end

View File

@@ -61,6 +61,18 @@ module ActsAsTaggableOn
|)
end
def self.graphql_field_name
:tag
end
def self.graphql_pluralized_field_name
:tags
end
def self.graphql_type_name
'Tag'
end
private
def custom_counter_field_name_for(taggable_type)
"#{taggable_type.underscore.pluralize}_count"

View File

@@ -46,7 +46,7 @@ module GraphQL
fields.each do |field_name, field_type|
case ApiTypesCreator.type_kind(field_type)
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
field(field_name, -> { api_types_creator.created_types[field_type] }) do
resolve -> (object, arguments, context) do