add questions query
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
module Types
|
||||
class BaseEnum < GraphQL::Schema::Enum
|
||||
def self.values_from_enumerize(enum_values)
|
||||
enum_values.values.each do |enum_value|
|
||||
value enum_value.upcase, value: enum_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,14 +4,12 @@ module Types
|
||||
include GraphQL::Types::Relay::HasNodeField
|
||||
include GraphQL::Types::Relay::HasNodesField
|
||||
|
||||
# Add root-level fields here.
|
||||
# They will be entry points for queries on your schema.
|
||||
field :questions, QuestionType.connection_type, null: false do
|
||||
argument :where, Inputs::QuestionWhereInput, required: false
|
||||
end
|
||||
|
||||
# TODO: remove me
|
||||
field :test_field, String, null: false,
|
||||
description: "An example field added by the generator"
|
||||
def test_field
|
||||
"Hello World!"
|
||||
def questions(where: nil)
|
||||
Resolvers::QuestionsQueryResolver.new(Question, context: context, where: where).resolve
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
12
app/graphql/types/question_alternative_type.rb
Normal file
12
app/graphql/types/question_alternative_type.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Types
|
||||
module Questions
|
||||
class Alternative < Types::BaseObject
|
||||
graphql_name "QuestionAlternative"
|
||||
|
||||
field :correct, Boolean, null: false
|
||||
field :text, String, null: true
|
||||
end
|
||||
end
|
||||
end
|
||||
28
app/graphql/types/question_type.rb
Normal file
28
app/graphql/types/question_type.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Types
|
||||
class QuestionType < Types::BaseObject
|
||||
implements GraphQL::Types::Relay::Node
|
||||
|
||||
graphql_name 'Question'
|
||||
|
||||
global_id_field :id
|
||||
field :user_id, Integer, null: false
|
||||
field :subject_id, Integer
|
||||
field :alternatives, GraphQL::Types::JSON, null: false
|
||||
field :authorship, String
|
||||
field :authorship_year, String
|
||||
field :body, String
|
||||
field :explanation, String
|
||||
field :instruction, String
|
||||
field :intention, String
|
||||
field :references, String
|
||||
field :support, String
|
||||
field :bloom_taxonomy, Enums::QuestionBloomTaxonomyEnum
|
||||
field :check_type, Enums::QuestionCheckTypeEnum
|
||||
field :difficulty, Enums::QuestionDifficultyEnum
|
||||
field :status, Enums::QuestionStatusEnum, null: false
|
||||
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
|
||||
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user