Skip to content

Instantly share code, notes, and snippets.

@pmbanka
Forked from mmierzwa/schema.graphql
Created October 12, 2021 12:38
Show Gist options
  • Save pmbanka/c90d23ee9edd5293e2338c0f93b70e8b to your computer and use it in GitHub Desktop.
Save pmbanka/c90d23ee9edd5293e2338c0f93b70e8b to your computer and use it in GitHub Desktop.
schema {
query: Query
mutation: Mutation
}
type Query {
session(id: ID!): Session
}
type Mutation {
finishSessionByUser(input: FinishSessionByUserInput!): Session
@aws_cognito_user_pools(cognito_groups: ["user_group"])
finishSessionByTutor(input: FinishSessionByTutorInput!): Session
@aws_cognito_user_pools(cognito_groups: ["tutor_group"])
# "rate session by user"
# includes reporting the tutor
rateSession(input: RateSessionInput!): Session
@aws_cognito_user_pools(cognito_groups: ["user_group"])
# "report session by tutor"
# in fact, it's more about reporting the user, not the session
reportSession(input: ReportSessionInput!): Session
@aws_cognito_user_pools(cognito_groups: ["tutor_group"])
# the tutor disconnection process is handled with the internal API + broadcastSessionUpdate
}
type Session {
id: ID!
# ...
state: SessionState!
stateLog: [SessionStateEntry!]
# the first option is to leave closure reason as a simple value:
closureReason: SessionClosureReason @aws_cognito_user_pools(cognito_groups: ["tutor_qa_group", "tutor_group_admin", "supervisor_group", "admin_group"])
# second is changing it to a complex, more descriptive type:
closureReason: SessionClosureReasonDescriptor @aws_cognito_user_pools(cognito_groups: ["tutor_qa_group", "tutor_group_admin", "supervisor_group", "admin_group"])
# third is to promote "closedBy" from the type above to the session itself:
closedBy: Actor
# closure case should be used for client integration
# is doesn't have to be persisted and can be inferred based on other persisted session fields
# this is a single value field, so a priority needs to be specified in case of multiple possible values (i.e. disconnected and later reported by tutor)
closureCase: SessionClosureCase @aws_cognito_user_pools(cognito_groups: ["user_group"])
# should rating or report be accessible by tutor or user?
userRating: UserRating @aws_cognito_user_pools(cognito_groups: ["tutor_qa_group", "tutor_group_admin", "supervisor_group", "admin_group"])
tutorReport: TutorReport @aws_cognito_user_pools(cognito_groups: ["tutor_qa_group", "tutor_group_admin", "supervisor_group", "admin_group"])
}
enum SessionState {
CREATED
STARTED
CLOSED
REJECTED
}
enum SessionClosureReason {
FINISHED
TUTOR_DISCONNECTED
NOT_ANSWERED
LANGUAGE_NOT_SUPPORTED
}
type SessionClosureReasonDescriptor {
closedBy: Actor!
closureReason: SessionClosureReason!
}
# name is to be decided (case, scenario, etc.)
enum SessionClosureCase {
NORMAL
CONNECTION_ISSUES
TUTOR_REPORTED_USER
}
enum UserClosureReason {
FINISHED
# possibly, more values in the future
}
input FinishSessionByUserInput {
id: ID!
closureReason: UserClosureReason!
}
enum TutorClosureReason {
FINISHED
NOT_ANSWERED
LANGUAGE_NOT_SUPPORTED
}
input FinishSessionByTutorInput {
id: ID!
closureReason: TutorClosureReason!
}
type SessionStateEntry @aws_cognito_user_pools {
state: SessionState
createdAt: AWSDateTime
createdBy: Actor
}
type UserRating @aws_iam @aws_cognito_user_pools {
session: Session!
score: UserRatingScore!
tags: [UserRatingTag!]!
comment: String
user: Actor!
createdAt: AWSDateTime!
}
type TutorReport @aws_iam @aws_cognito_user_pools {
session: Session!
tags: [TutorReportTag!]!
comment: String
tutor: Actor!
createdAt: AWSDateTime!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment