add questionFilterOptions query
This commit is contained in:
@@ -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
|
||||||
@@ -8,6 +8,7 @@ module Types
|
|||||||
end
|
end
|
||||||
field :subjects, SubjectType.connection_type, null: false
|
field :subjects, SubjectType.connection_type, null: false
|
||||||
field :reviewers, UserType.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
|
field :current_user, Types::UserType, null: true
|
||||||
|
|
||||||
def questions(where: nil)
|
def questions(where: nil)
|
||||||
@@ -22,6 +23,11 @@ module Types
|
|||||||
Resolvers::ReviewersQueryResolver.new(context).resolve
|
Resolvers::ReviewersQueryResolver.new(context).resolve
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def question_filter_options
|
||||||
|
Resolvers::QuestionFilterOptionsQueryResolver.new.resolve
|
||||||
|
end
|
||||||
|
|
||||||
def current_user
|
def current_user
|
||||||
context[:current_user]
|
context[:current_user]
|
||||||
end
|
end
|
||||||
|
|||||||
7
app/graphql/types/question_filter_options_type.rb
Normal file
7
app/graphql/types/question_filter_options_type.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Types
|
||||||
|
class QuestionFilterOptionsType < Types::BaseObject
|
||||||
|
field :years, [String], null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
6
app/javascript/__generated__/graphql-schema.ts
generated
6
app/javascript/__generated__/graphql-schema.ts
generated
@@ -163,6 +163,7 @@ export type Query = {
|
|||||||
node?: Maybe<Node>;
|
node?: Maybe<Node>;
|
||||||
/** Fetches a list of objects given a list of IDs. */
|
/** Fetches a list of objects given a list of IDs. */
|
||||||
nodes: Array<Maybe<Node>>;
|
nodes: Array<Maybe<Node>>;
|
||||||
|
questionFilterOptions: QuestionFilterOptions;
|
||||||
questions: QuestionConnection;
|
questions: QuestionConnection;
|
||||||
reviewers: UserConnection;
|
reviewers: UserConnection;
|
||||||
subjects: SubjectConnection;
|
subjects: SubjectConnection;
|
||||||
@@ -313,6 +314,11 @@ export type QuestionEdge = {
|
|||||||
node?: Maybe<Question>;
|
node?: Maybe<Question>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type QuestionFilterOptions = {
|
||||||
|
__typename?: 'QuestionFilterOptions';
|
||||||
|
years: Array<Scalars['String']>;
|
||||||
|
};
|
||||||
|
|
||||||
export enum QuestionStatus {
|
export enum QuestionStatus {
|
||||||
Approved = 'APPROVED',
|
Approved = 'APPROVED',
|
||||||
Draft = 'DRAFT',
|
Draft = 'DRAFT',
|
||||||
|
|||||||
5
app/javascript/__generated__/schema.graphql
generated
5
app/javascript/__generated__/schema.graphql
generated
@@ -223,6 +223,7 @@ type Query {
|
|||||||
"""
|
"""
|
||||||
ids: [ID!]!
|
ids: [ID!]!
|
||||||
): [Node]!
|
): [Node]!
|
||||||
|
questionFilterOptions: QuestionFilterOptions!
|
||||||
questions(
|
questions(
|
||||||
"""
|
"""
|
||||||
Returns the elements in the list that come after the specified cursor.
|
Returns the elements in the list that come after the specified cursor.
|
||||||
@@ -424,6 +425,10 @@ type QuestionEdge {
|
|||||||
node: Question
|
node: Question
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type QuestionFilterOptions {
|
||||||
|
years: [String!]!
|
||||||
|
}
|
||||||
|
|
||||||
enum QuestionStatus {
|
enum QuestionStatus {
|
||||||
APPROVED
|
APPROVED
|
||||||
DRAFT
|
DRAFT
|
||||||
|
|||||||
Reference in New Issue
Block a user