import { gql } from 'apollo-angular';

export const CREATE_STUDENT = gql`
  mutation CreateStudent($input: CreateStudentInput!) {
    createStudent(input: $input) {
      student {
        id
        name
        email
        totalCredits
        enrollments {
          id
          subjectId
          subjectName
          credits
          professorName
          enrolledAt
        }
      }
    }
  }
`;

export const UPDATE_STUDENT = gql`
  mutation UpdateStudent($id: Int!, $input: UpdateStudentInput!) {
    updateStudent(id: $id, input: $input) {
      student {
        id
        name
        email
        totalCredits
        enrollments {
          id
          subjectId
          subjectName
          credits
          professorName
          enrolledAt
        }
      }
    }
  }
`;

export const DELETE_STUDENT = gql`
  mutation DeleteStudent($id: Int!) {
    deleteStudent(id: $id) {
      success
    }
  }
`;

export const ENROLL_STUDENT = gql`
  mutation EnrollStudent($input: EnrollStudentInput!) {
    enrollStudent(input: $input) {
      enrollment {
        id
        subjectId
        subjectName
        credits
        professorName
        enrolledAt
      }
    }
  }
`;

export const UNENROLL_STUDENT = gql`
  mutation UnenrollStudent($enrollmentId: Int!) {
    unenrollStudent(enrollmentId: $enrollmentId) {
      success
    }
  }
`;
