add questionFilterOptions query

This commit is contained in:
2022-10-17 10:27:55 -03:00
parent 7dd11f8e07
commit f14eeb614d
5 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
module Resolvers
class QuestionFilterOptionsQueryResolver
def initialize; end
def resolve
{
years: Question.distinct(:authorship_year).pluck(:authorship_year)
}
end
end
end

View File

@@ -8,6 +8,7 @@ module Types
end
field :subjects, SubjectType.connection_type, null: false
field :reviewers, UserType.connection_type, null: false
field :question_filter_options, QuestionFilterOptionsType, null: false
field :current_user, Types::UserType, null: true
def questions(where: nil)
@@ -22,6 +23,11 @@ module Types
Resolvers::ReviewersQueryResolver.new(context).resolve
end
def question_filter_options
Resolvers::QuestionFilterOptionsQueryResolver.new.resolve
end
def current_user
context[:current_user]
end

View File

@@ -0,0 +1,7 @@
# frozen_string_literal: true
module Types
class QuestionFilterOptionsType < Types::BaseObject
field :years, [String], null: false
end
end

View File

@@ -163,6 +163,7 @@ export type Query = {
node?: Maybe<Node>;
/** Fetches a list of objects given a list of IDs. */
nodes: Array<Maybe<Node>>;
questionFilterOptions: QuestionFilterOptions;
questions: QuestionConnection;
reviewers: UserConnection;
subjects: SubjectConnection;
@@ -313,6 +314,11 @@ export type QuestionEdge = {
node?: Maybe<Question>;
};
export type QuestionFilterOptions = {
__typename?: 'QuestionFilterOptions';
years: Array<Scalars['String']>;
};
export enum QuestionStatus {
Approved = 'APPROVED',
Draft = 'DRAFT',

View File

@@ -223,6 +223,7 @@ type Query {
"""
ids: [ID!]!
): [Node]!
questionFilterOptions: QuestionFilterOptions!
questions(
"""
Returns the elements in the list that come after the specified cursor.
@@ -424,6 +425,10 @@ type QuestionEdge {
node: Question
}
type QuestionFilterOptions {
years: [String!]!
}
enum QuestionStatus {
APPROVED
DRAFT