graphql: convert group type to class api

Test plan: specs pass

Change-Id: I5774a1e65d819a559ba22ee689b8d8c85159f775
Reviewed-on: https://gerrit.instructure.com/163100
Reviewed-by: Jonathan Featherstone <jfeatherstone@instructure.com>
Tested-by: Jenkins
Product-Review: Cameron Matheson <cameron@instructure.com>
QA-Review: Cameron Matheson <cameron@instructure.com>
This commit is contained in:
Cameron Matheson 2018-09-04 12:28:03 -06:00
parent 863bde3cca
commit e58a85456e
1 changed files with 11 additions and 8 deletions

View File

@ -17,22 +17,25 @@
#
module Types
GroupType = GraphQL::ObjectType.define do
name "Group"
class GroupType < ApplicationObjectType
graphql_name "Group"
interfaces [Interfaces::TimestampInterface]
alias :group :object
field :_id, !types.ID, "legacy canvas id", property: :id
field :name, types.String
implements Interfaces::TimestampInterface
connection :membersConnection, GroupMembershipType.connection_type, resolve: ->(group, _, ctx) {
if group.grants_right? ctx[:current_user], :read_roster
field :_id, ID, "legacy canvas id", method: :id, null: false
field :name, String, null: true
field :members_connection, GroupMembershipType.connection_type, null: true
def members_connection
if group.grants_right?(current_user, :read_roster)
group.group_memberships.where(
workflow_state: GroupMembershipsController::ALLOWED_MEMBERSHIP_FILTER
)
else
nil
end
}
end
end
end