Add more fields to api.yml
This commit is contained in:
@@ -19,6 +19,8 @@ class Comment < ActiveRecord::Base
|
|||||||
belongs_to :commentable, -> { with_hidden }, polymorphic: true, counter_cache: true
|
belongs_to :commentable, -> { with_hidden }, polymorphic: true, counter_cache: true
|
||||||
belongs_to :user, -> { with_hidden }
|
belongs_to :user, -> { with_hidden }
|
||||||
|
|
||||||
|
has_many :votes, -> { for_comments }, foreign_key: 'votable_id'
|
||||||
|
|
||||||
before_save :calculate_confidence_score
|
before_save :calculate_confidence_score
|
||||||
|
|
||||||
scope :for_render, -> { with_hidden.includes(user: :organization) }
|
scope :for_render, -> { with_hidden.includes(user: :organization) }
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class Debate < ActiveRecord::Base
|
|||||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||||
belongs_to :geozone
|
belongs_to :geozone
|
||||||
has_many :comments, as: :commentable
|
has_many :comments, as: :commentable
|
||||||
|
has_many :votes, -> { for_debates }, foreign_key: 'votable_id'
|
||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
validates :description, presence: true
|
validates :description, presence: true
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class Proposal < ActiveRecord::Base
|
|||||||
belongs_to :geozone
|
belongs_to :geozone
|
||||||
has_many :comments, as: :commentable
|
has_many :comments, as: :commentable
|
||||||
has_many :proposal_notifications
|
has_many :proposal_notifications
|
||||||
|
has_many :votes, -> { for_proposals }, foreign_key: 'votable_id'
|
||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
validates :question, presence: true
|
validates :question, presence: true
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
class Vote < ActsAsVotable::Vote
|
class Vote < ActsAsVotable::Vote
|
||||||
|
|
||||||
|
scope :for_debates, -> { where(votable_type: 'Debate') }
|
||||||
|
scope :for_proposals, -> { where(votable_type: 'Proposal') }
|
||||||
|
scope :for_comments, -> { where(votable_type: 'Comment') }
|
||||||
|
|
||||||
scope :public_for_api, -> do
|
scope :public_for_api, -> do
|
||||||
joins("FULL OUTER JOIN debates ON votable_type = 'Debate' AND votable_id = debates.id").
|
joins("FULL OUTER JOIN debates ON votable_type = 'Debate' AND votable_id = debates.id").
|
||||||
joins("FULL OUTER JOIN proposals ON votable_type = 'Proposal' AND votable_id = proposals.id").
|
joins("FULL OUTER JOIN proposals ON votable_type = 'Proposal' AND votable_id = proposals.id").
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
User:
|
User:
|
||||||
fields:
|
fields:
|
||||||
id: integer
|
id: integer
|
||||||
username: string
|
username: string
|
||||||
|
debates: [Debate]
|
||||||
|
proposals: [Proposal]
|
||||||
|
comments: [Comment]
|
||||||
Voter:
|
Voter:
|
||||||
fields:
|
fields:
|
||||||
gender: string
|
gender: string
|
||||||
@@ -24,6 +27,7 @@ Debate:
|
|||||||
geozone: Geozone
|
geozone: Geozone
|
||||||
comments: [Comment]
|
comments: [Comment]
|
||||||
public_author: User
|
public_author: User
|
||||||
|
votes: [Vote]
|
||||||
Proposal:
|
Proposal:
|
||||||
fields:
|
fields:
|
||||||
id: integer
|
id: integer
|
||||||
@@ -45,6 +49,7 @@ Proposal:
|
|||||||
comments: [Comment]
|
comments: [Comment]
|
||||||
proposal_notifications: [ProposalNotification]
|
proposal_notifications: [ProposalNotification]
|
||||||
public_author: User
|
public_author: User
|
||||||
|
votes: [Vote]
|
||||||
Comment:
|
Comment:
|
||||||
fields:
|
fields:
|
||||||
id: integer
|
id: integer
|
||||||
@@ -58,6 +63,7 @@ Comment:
|
|||||||
ancestry: string
|
ancestry: string
|
||||||
confidence_score: integer
|
confidence_score: integer
|
||||||
public_author: User
|
public_author: User
|
||||||
|
votes: [Vote]
|
||||||
Geozone:
|
Geozone:
|
||||||
fields:
|
fields:
|
||||||
id: integer
|
id: integer
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ QueryType = query_type_creator.create
|
|||||||
|
|
||||||
ConsulSchema = GraphQL::Schema.define do
|
ConsulSchema = GraphQL::Schema.define do
|
||||||
query QueryType
|
query QueryType
|
||||||
max_depth 10
|
max_depth 12
|
||||||
|
|
||||||
resolve_type -> (object, ctx) do
|
resolve_type -> (object, ctx) do
|
||||||
type_name = object.class.name # look up types by class name
|
type_name = object.class.name # look up types by class name
|
||||||
|
|||||||
Reference in New Issue
Block a user