Add helper method to define collection and object by id fields in QueryType
- Introduce `collection_and_object_by_id_fields` in QueryType to avoid duplication.
This commit is contained in:
@@ -1,41 +1,23 @@
|
||||
module Types
|
||||
class QueryType < Types::BaseObject
|
||||
field :budgets, Types::BudgetType.connection_type, "Returns all budgets", null: false
|
||||
object_by_id_field :budget, Types::BudgetType, "Returns budget for ID", null: false
|
||||
def self.collection_and_object_by_id_fields(name, type)
|
||||
field name.to_s.pluralize.to_sym,
|
||||
type.connection_type,
|
||||
"Returns all #{name.to_s.pluralize}",
|
||||
null: false
|
||||
object_by_id_field name, type, "Returns #{name} for ID", null: false
|
||||
end
|
||||
|
||||
field :comments, Types::CommentType.connection_type, "Returns all comments", null: false
|
||||
object_by_id_field :comment, Types::CommentType, "Returns comment for ID", null: false
|
||||
|
||||
field :debates, Types::DebateType.connection_type, "Returns all debates", null: false
|
||||
object_by_id_field :debate, Types::DebateType, "Returns debate for ID", null: false
|
||||
|
||||
field :geozones, Types::GeozoneType.connection_type, "Returns all geozones", null: false
|
||||
object_by_id_field :geozone, Types::GeozoneType, "Returns geozone for ID", null: false
|
||||
|
||||
field :milestones, Types::MilestoneType.connection_type, "Returns all milestones", null: false
|
||||
object_by_id_field :milestone, Types::MilestoneType, "Returns milestone for ID", null: false
|
||||
|
||||
field :proposals, Types::ProposalType.connection_type, "Returns all proposals", null: false
|
||||
object_by_id_field :proposal, Types::ProposalType, "Returns proposal for ID", null: false
|
||||
|
||||
field :proposal_notifications,
|
||||
Types::ProposalNotificationType.connection_type,
|
||||
"Returns all proposal notifications",
|
||||
null: false
|
||||
|
||||
object_by_id_field :proposal_notification,
|
||||
Types::ProposalNotificationType,
|
||||
"Returns proposal notification for ID",
|
||||
null: false
|
||||
|
||||
field :tags, Types::TagType.connection_type, "Returns all tags", null: false
|
||||
object_by_id_field :tag, Types::TagType, "Returns tag for ID", null: false
|
||||
|
||||
field :users, Types::UserType.connection_type, "Returns all users", null: false
|
||||
object_by_id_field :user, Types::UserType, "Returns user for ID", null: false
|
||||
|
||||
field :votes, Types::VoteType.connection_type, "Returns all votes", null: false
|
||||
object_by_id_field :vote, Types::VoteType, "Returns vote for ID", null: false
|
||||
collection_and_object_by_id_fields :budget, Types::BudgetType
|
||||
collection_and_object_by_id_fields :comment, Types::CommentType
|
||||
collection_and_object_by_id_fields :debate, Types::DebateType
|
||||
collection_and_object_by_id_fields :geozone, Types::GeozoneType
|
||||
collection_and_object_by_id_fields :milestone, Types::MilestoneType
|
||||
collection_and_object_by_id_fields :proposal, Types::ProposalType
|
||||
collection_and_object_by_id_fields :proposal_notification, Types::ProposalNotificationType
|
||||
collection_and_object_by_id_fields :tag, Types::TagType
|
||||
collection_and_object_by_id_fields :user, Types::UserType
|
||||
collection_and_object_by_id_fields :vote, Types::VoteType
|
||||
|
||||
def budgets
|
||||
Budget.public_for_api
|
||||
|
||||
Reference in New Issue
Block a user