Assignment Mutations
Overview
Section titled “Overview”The assignment mutations allow you to create, update, and delete assignments within your Teachify courses — for example to provision a course together with its assignments, or to keep assignment content in sync with an external system.
All assignment mutations require the courses:write scope.
Available Mutations
Section titled “Available Mutations”createAssignment
Section titled “createAssignment”Creates a new assignment in a course.
Input Parameters:
| Field | Type | Description |
|---|---|---|
input | AdminAssignmentInput! | Input object containing assignment creation details |
AdminAssignmentInput Fields:
| Field | Type | Required | Description |
|---|---|---|---|
courseId | String! | Yes | Parent course ID. Course must belong to the same school |
name | String! | Yes | Assignment name |
description | String | No | Assignment description |
published | Boolean | No | Whether the assignment is visible to students. Defaults to false |
startedAt | BigInt | No | Start time, Unix timestamp |
dueAt | BigInt | No | Due time, Unix timestamp |
position | Int | No | Sort position when the course orders assignments by position |
contentRestriction | String | No | Whether text content is required on submissions: required, optional, none. Defaults to optional |
attachmentRestriction | String | No | Whether file attachments are required on submissions: required, optional, none. Defaults to none |
fileTypes | [String!] | No | Accepted MIME types for submission attachments. Note: application/msword and the docx MIME type are kept in sync server-side — docx is auto-added when msword is present and removed when it is not, so the stored list may differ slightly from what was sent |
commentable | Boolean | No | Whether students can comment on submissions. Defaults to true |
Limitation: instructor reference files on an assignment (the attachments teachers upload alongside the instructions) cannot currently be created or read through the Admin API.
Example:
mutation CreateAssignment { createAssignment(input: { courseId: "course-123" name: "Week 1 Essay" description: "Write a 500-word essay on the assigned topic." published: true dueAt: 1767225600 contentRestriction: "required" attachmentRestriction: "optional" fileTypes: ["application/pdf"] }) { assignment { id name published dueAt } errors }}updateAssignment
Section titled “updateAssignment”Updates an existing assignment. This is a partial update — only the provided fields are changed. Passing null for startedAt or dueAt clears the timestamp.
Input Parameters:
| Field | Type | Description |
|---|---|---|
id | String! | ID of the assignment to update |
input | AdminAssignmentUpdateInput! | Fields to change |
AdminAssignmentUpdateInput accepts the same fields as AdminAssignmentInput except courseId (an assignment cannot be moved to another course), and all fields are optional.
Example:
mutation UpdateAssignment { updateAssignment( id: "assignment-456" input: { published: true dueAt: 1767830400 } ) { assignment { id published dueAt } errors }}deleteAssignment
Section titled “deleteAssignment”Soft-deletes an assignment. Deletion is rejected when the assignment has already received submissions, so student work stays reachable.
Input Parameters:
| Field | Type | Description |
|---|---|---|
id | String! | ID of the assignment to delete |
Example:
mutation DeleteAssignment { deleteAssignment(id: "assignment-456") { success errors }}gradeSubmission
Section titled “gradeSubmission”Note: This mutation is still under development and will be fully documented when available.
Grades a student’s assignment submission, providing feedback and a score.
Error Handling
Section titled “Error Handling”All assignment mutations return an errors field containing validation errors (for example an invalid contentRestriction value). Not-found and permission problems are returned as top-level GraphQL errors with these codes:
| Code | Meaning |
|---|---|
ASSIGNMENT-001 | Course not found |
ASSIGNMENT-002 | Assignment not found |
ASSIGNMENT-003 | Cannot delete an assignment that has already received submissions |
For more information about the Teachify Admin API, please refer to the API Overview.