scalar Time
scalar UUID
scalar Upload

type ProjectLabel {
  id: ID!
  createdDate: Time!
  labelColor: LabelColor!
  name: String
}

type LabelColor {
  id: ID!
  name: String!
  position: Float!
  colorHex: String!
}

type TaskLabel {
  id: ID!
  projectLabel: ProjectLabel!
  assignedDate: Time!
}

type ProfileIcon {
  url: String
  initials: String
  bgColor: String
}

type ProjectMember {
  id: ID!
  fullName: String!
  profileIcon: ProfileIcon!
}

type RefreshToken {
  id: ID!
  userId: UUID!
  expiresAt: Time!
  createdAt: Time!
}

type UserAccount {
  id: ID!
  email: String!
  createdAt: Time!
  fullName: String!
  initials: String!
  username: String!
  profileIcon: ProfileIcon!
}

type Team {
  id: ID!
  createdAt: Time!
  name: String!
}

type Project {
  id: ID!
  createdAt: Time!
  name: String!
  team: Team!
  owner: ProjectMember!
  taskGroups: [TaskGroup!]!
  members: [ProjectMember!]!
  labels: [ProjectLabel!]!
}

type TaskGroup {
  id: ID!
  projectID: String!
  createdAt: Time!
  name: String!
  position: Float!
  tasks: [Task!]!
}

type Task {
  id: ID!
  taskGroup: TaskGroup!
  createdAt: Time!
  name: String!
  position: Float!
  description: String
  assigned: [ProjectMember!]!
  labels: [TaskLabel!]!
}

input ProjectsFilter {
  teamID: String
}

input FindUser {
  userId: String!
}

input FindProject {
  projectId: String!
}

input FindTask {
  taskID: UUID!
}

type Query {
  users: [UserAccount!]!
  findUser(input: FindUser!): UserAccount!
  findProject(input: FindProject!): Project!
  findTask(input: FindTask!): Task!
  projects(input: ProjectsFilter): [Project!]!
  teams: [Team!]!
  labelColors: [LabelColor!]!
  taskGroups: [TaskGroup!]!
  me: UserAccount!
}

input NewRefreshToken {
  userId: String!
}

input NewUserAccount {
  username: String!
  email: String!
  fullName: String!
  initials: String!
  password: String!
}

input NewTeam {
  name: String!
  organizationID: String!
}

input NewProject {
  userID: UUID!
  teamID: UUID!
  name: String!
}

input NewTaskGroup {
  projectID: String!
  name: String!
  position: Float!
}

input LogoutUser {
  userID: String!
}
input NewTask {
  taskGroupID: String!
  name: String!
  position: Float!
}
input NewTaskLocation {
  taskID: UUID!
  taskGroupID: UUID!
  position: Float!
}

input DeleteTaskInput {
  taskID: String!
}

type DeleteTaskPayload {
  taskID: String!
}

input UpdateTaskName {
  taskID: String!
  name: String!
}

input NewTaskGroupLocation {
  taskGroupID: UUID!
  position: Float!
}

input DeleteTaskGroupInput {
  taskGroupID: UUID!
}

type DeleteTaskGroupPayload {
  ok: Boolean!
  affectedRows: Int!
  taskGroup: TaskGroup!
}

input AssignTaskInput {
  taskID: UUID!
  userID: UUID!
}

input UnassignTaskInput {
  taskID: UUID!
  userID: UUID!
}
input UpdateTaskDescriptionInput {
  taskID: UUID!
  description: String!
}

input AddTaskLabelInput {
  taskID: UUID!
  projectLabelID: UUID!
}

input RemoveTaskLabelInput {
  taskLabelID: UUID!
}

input NewProjectLabel {
  projectID: UUID!
  labelColorID: UUID!
  name: String
}

input DeleteProjectLabel {
  projectLabelID: UUID!
}

input UpdateProjectLabelName {
  projectLabelID: UUID!
  name: String!
}

input UpdateProjectLabel {
  projectLabelID: UUID!
  labelColorID: UUID!
  name: String!
}

input UpdateProjectLabelColor {
  projectLabelID: UUID!
  labelColorID: UUID!
}

input ToggleTaskLabelInput {
  taskID: UUID!
  projectLabelID: UUID!
}

type ToggleTaskLabelPayload {
  active: Boolean!
  task: Task!
}

input UpdateProjectName {
  projectID: UUID!
  name: String!
}

type UpdateTaskLocationPayload {
  previousTaskGroupID: UUID!
  task: Task!
}

input UpdateTaskGroupName  {
  taskGroupID: UUID!
  name: String!
}

type Mutation {
  createRefreshToken(input: NewRefreshToken!): RefreshToken!

  createUserAccount(input: NewUserAccount!): UserAccount!

  createTeam(input: NewTeam!): Team!
  clearProfileAvatar:  UserAccount!

  createProject(input: NewProject!): Project!
  updateProjectName(input: UpdateProjectName): Project!

  createProjectLabel(input: NewProjectLabel!): ProjectLabel!
  deleteProjectLabel(input: DeleteProjectLabel!): ProjectLabel!
  updateProjectLabel(input: UpdateProjectLabel!): ProjectLabel!
  updateProjectLabelName(input: UpdateProjectLabelName!): ProjectLabel!
  updateProjectLabelColor(input: UpdateProjectLabelColor!): ProjectLabel!

  createTaskGroup(input: NewTaskGroup!): TaskGroup!
  updateTaskGroupLocation(input: NewTaskGroupLocation!): TaskGroup!
  updateTaskGroupName(input: UpdateTaskGroupName!): TaskGroup!
  deleteTaskGroup(input: DeleteTaskGroupInput!): DeleteTaskGroupPayload!

  addTaskLabel(input: AddTaskLabelInput): Task!
  removeTaskLabel(input: RemoveTaskLabelInput): Task!
  toggleTaskLabel(input: ToggleTaskLabelInput!): ToggleTaskLabelPayload!

  createTask(input: NewTask!): Task!
  updateTaskDescription(input: UpdateTaskDescriptionInput!): Task!
  updateTaskLocation(input: NewTaskLocation!): UpdateTaskLocationPayload!
  updateTaskName(input: UpdateTaskName!): Task!
  deleteTask(input: DeleteTaskInput!): DeleteTaskPayload!
  assignTask(input: AssignTaskInput): Task!
  unassignTask(input: UnassignTaskInput): Task!

  logoutUser(input: LogoutUser!): Boolean!
}
