Mutation operations for managing courses and student enrollments in your Loopwise school
The course mutations allow you to create, update, and delete courses within your Loopwise school, as well as manage student enrollments. These operations enable you to programmatically manage your course catalog and student access.
Course entity mutations:
createCourse — Creates a new course
updateCourse — Updates an existing course
deleteCourse — Deletes a course
Enrollment mutations:
enrollStudentToCourse — Enrolls a student to a course or updates an existing enrollment
removeStudentFromCourse — Removes a student's enrollment from a course
expireStudentCourseAccess — Marks a student's course access as expired
extendStudentCourseAccess — Extends a student's access to a course
All course mutations return an errors field in the response that will contain any validation or processing errors that occurred during the operation.
type AdminCourseCreatePayload { # The created course object, null if operation failed course: AdminCourse # Array of error messages, if any occurred during the operation errors: [String!]}
type AdminCourseUpdatePayload { # The updated course object, null if operation failed course: AdminCourse # Array of error messages, if any occurred during the operation errors: [String!]}
The enrollStudentToCourse mutation allows you to enroll a student to a specified course, or update existing enrollment details. For paid or pre-order courses, this mutation automatically creates payment records using the specified curriculum plan's pricing information.
Email of the student. If user doesn't exist, a placeholder user will be created
name
String
No
Name of the student. Required when creating a new user
courseId
String!
Yes
ID of the course to enroll the student into
planId
String
No
ID of the curriculum plan to apply to this enrollment. If not provided, will use the course's first plan (ordered by creation date). For paid/pre-order courses, the plan's amount and currency are used to create the payment record
endedAt
Int
No
Optional expiration date for the enrollment (Unix Timestamp)
mutation EnrollNewStudent { enrollStudentToCourse( courseId: "ab6ee332-614d-475d-93b5-abc5ebb1fc84" email: "student@example.com" name: "John Doe" # Required when creating a new user ) { enrollment { id completionRate createdAt updatedAt endedAt course { id name slug } user { id name email } } }}
mutation EnrollStudentToPaidCourse { enrollStudentToCourse( courseId: "paid-course-123" email: "premium.student@example.com" name: "Premium Student" planId: "premium-plan-456" endedAt: 1735689600 ) { enrollment { id completionRate endedAt course { id name } user { id name email } } }}
Note: For paid or pre-order courses, this mutation creates a payment record with amount and currency from the specified plan, status set to manual_enrolled, and a lineitem linking to the curriculum plan. For free or redeem courses, no payment record is created. If the student is already enrolled in a paid/pre-order course, the mutation returns the existing enrollment without creating a new payment.
The removeStudentFromCourse mutation allows you to completely remove a student's enrollment from a specified course. This action revokes the student's access to course content and removes all enrollment records.
type AdminRemoveStudentFromCoursePayload { # Additional information about the operation result message: String # Indicates whether the removal was successful success: Boolean!}
The extendStudentCourseAccess mutation allows you to extend a student's access to a course by updating the ended_at date. This is useful when you want to grant additional time for course completion.
mutation ExtendStudentAccessWithDate { extendStudentCourseAccess( userId: "387b0c87-0f85-44cc-833e-7306c1b5d3e6" courseId: "9a1216f7-36de-4c50-8094-2ebfb7d3c383" newEndedAt: 1735689600 ) { enrollment { id endedAt course { id name } user { id name } } }}
mutation GrantIndefiniteAccess { extendStudentCourseAccess( userId: "387b0c87-0f85-44cc-833e-7306c1b5d3e6" courseId: "9a1216f7-36de-4c50-8094-2ebfb7d3c383" indefinite: true ) { enrollment { id endedAt course { id name } user { id name } } }}
The expireStudentCourseAccess mutation allows you to mark a student's course access as expired while retaining their course data. This is useful when you want to temporarily revoke a student's access without removing their progress and enrollment records.
mutation ExpireStudentAccessWithCustomDate { expireStudentCourseAccess( userId: "a1b2c3d4-5678-90ef-ghij-klmnopqrstuv" courseId: "ab6ee332-614d-475d-93b5-abc5ebb1fc84" customEndedAt: 1735689600 reason: "Course access expired due to non-payment" ) { enrollment { id endedAt course { id name } user { id name } } }}