graphql: convert assignment override type to object api
Change-Id: I53c051893133485771eabb9ce7a2745940131ae7 Reviewed-on: https://gerrit.instructure.com/162263 Tested-by: Jenkins Reviewed-by: Jonathan Featherstone <jfeatherstone@instructure.com> Product-Review: Cameron Matheson <cameron@instructure.com> QA-Review: Cameron Matheson <cameron@instructure.com>
This commit is contained in:
parent
32c825193e
commit
ccc6167639
|
@ -17,42 +17,6 @@
|
|||
#
|
||||
|
||||
module Types
|
||||
AssignmentOverrideType = GraphQL::ObjectType.define do
|
||||
name "AssignmentOverride"
|
||||
|
||||
interfaces [Interfaces::TimestampInterface]
|
||||
|
||||
field :_id, !types.ID, "legacy canvas id", property: :id
|
||||
|
||||
field :assignment, AssignmentType, resolve: ->(override, _, _) {
|
||||
Loaders::AssociationLoader.for(AssignmentOverride, :assignment)
|
||||
.load(override)
|
||||
.then { override.assignment }
|
||||
}
|
||||
|
||||
field :title, types.String
|
||||
|
||||
field :set, AssignmentOverrideSetUnion do
|
||||
description "This object specifies what students this override applies to"
|
||||
|
||||
resolve ->(override, _, _) {
|
||||
if override.set_type == "ADHOC"
|
||||
# AdhocStudentsType will load the actual students
|
||||
override
|
||||
else
|
||||
Loaders::AssociationLoader.for(AssignmentOverride, :set)
|
||||
.load(override)
|
||||
.then { override.set }
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
field :dueAt, DateTimeType, property: :due_at
|
||||
field :lockAt, DateTimeType, property: :lock_at
|
||||
field :unlockAt, DateTimeType, property: :unlock_at
|
||||
field :allDay, types.Boolean, property: :all_day
|
||||
end
|
||||
|
||||
AssignmentOverrideSetUnion = GraphQL::UnionType.define do
|
||||
name "AssignmentOverrideSet"
|
||||
|
||||
|
@ -82,4 +46,37 @@ module Types
|
|||
}
|
||||
|
||||
end
|
||||
class AssignmentOverrideType < ApplicationObjectType
|
||||
graphql_name "AssignmentOverride"
|
||||
|
||||
implements GraphQL::Relay::Node.interface
|
||||
implements Interfaces::TimestampInterface
|
||||
|
||||
alias :override :object
|
||||
|
||||
field :_id, ID, "legacy canvas id", method: :id, null: false
|
||||
|
||||
field :assignment, AssignmentType, null: true
|
||||
def assignment
|
||||
load_association(:assignment)
|
||||
end
|
||||
|
||||
field :title, String, null: true
|
||||
|
||||
field :set, AssignmentOverrideSetUnion,
|
||||
"This object specifies what students this override applies to",
|
||||
null: true
|
||||
def set
|
||||
if override.set_type == "ADHOC"
|
||||
override
|
||||
else
|
||||
load_association(:set)
|
||||
end
|
||||
end
|
||||
|
||||
field :due_at, DateTimeType, null: true
|
||||
field :lock_at, DateTimeType, null: true
|
||||
field :unlock_at, DateTimeType, null: true
|
||||
field :all_day, Boolean, null: true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -165,13 +165,16 @@ input AssignmentInput {
|
|||
name: String!
|
||||
}
|
||||
|
||||
type AssignmentOverride implements Timestamped {
|
||||
type AssignmentOverride implements Node & Timestamped {
|
||||
# legacy canvas id
|
||||
_id: ID!
|
||||
allDay: Boolean
|
||||
assignment: Assignment
|
||||
createdAt: DateTime
|
||||
dueAt: DateTime
|
||||
|
||||
# ID of the object.
|
||||
id: ID!
|
||||
lockAt: DateTime
|
||||
|
||||
# This object specifies what students this override applies to
|
||||
|
|
Loading…
Reference in New Issue