### Create Teacher Account via GraphQL Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Creates a new teacher account with TEACHER role privileges. Requires username, password, firstName, and lastName as inputs. ```graphql mutation CreateTeacher($username: String!, $password: String!, $firstName: String!, $lastName: String!) { createOneTeacher(username: $username, password: $password, firstName: $firstName, lastName: $lastName) { ownerUsername firstName lastName owner { username role } } } ``` -------------------------------- ### POST /query (Create Teacher) Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Creates a new teacher account with full TEACHER role privileges. ```APIDOC ## POST /query ### Description Creates a new teacher account with full TEACHER role privileges. ### Method POST ### Endpoint /query ### Request Body - **username** (String) - Required - Unique username for the teacher - **password** (String) - Required - Password for the account - **firstName** (String) - Required - Teacher's first name - **lastName** (String) - Required - Teacher's last name ### Request Example mutation CreateTeacher($username: String!, $password: String!, $firstName: String!, $lastName: String!) { createOneTeacher(username: $username, password: $password, firstName: $firstName, lastName: $lastName) { ownerUsername firstName lastName } } ``` -------------------------------- ### Server Environment Configuration Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Defines the required environment variables for database connectivity, JWT authentication, and server port settings. ```bash DATABASE_URL="postgres://postgres:example@localhost:5432/postgres" JWT_KEY="your-secret-key" PORT="3000" USERNAME="admin" PASSWORD="admin123" ``` -------------------------------- ### POST /graphql (CreateStudent) Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Creates a new student with an associated user account. The username is auto-generated. ```APIDOC ## POST /graphql (CreateStudent) ### Description Creates a new student with associated user account. The username is auto-generated from the student's name. ### Method POST ### Endpoint /graphql ### Request Body - **student** (StudentInput) - Required - Student details - **user** (UserInput) - Required - User account details ### Request Example { "query": "mutation CreateStudent($student: StudentInput!, $user: UserInput!) { createOneStudent(student: $student, user: $user) { ownerUsername firstName lastName } }", "variables": { "student": { "firstName": "John", "lastName": "Doe" }, "user": { "password": "studentpassword123" } } } ``` -------------------------------- ### POST /graphql (CreateSkill) Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Adds a new skill to an existing contract. Requires TEACHER role. ```APIDOC ## POST /graphql (CreateSkill) ### Description Adds a new skill to an existing contract. Requires TEACHER role. ### Method POST ### Endpoint /graphql ### Request Body - **name** (String) - Required - The name of the skill - **contractID** (Int) - Required - The ID of the contract ### Request Example { "query": "mutation CreateSkill($name: String!, $contractID: Int!) { createOneSkill(name: $name, contractID: $contractID) { id name contractId } }", "variables": { "name": "Trigonometry", "contractID": 1 } } ``` -------------------------------- ### Manage Students via GraphQL Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Operations for student lifecycle management including creation, retrieval, group assignment updates, and deletion. ```graphql mutation CreateStudent($student: StudentInput!, $user: UserInput!) { createOneStudent(student: $student, user: $user) { ownerUsername firstName lastName owner { username role } } } query GetAllStudents { students { ownerUsername firstName lastName groups { id name } studentSkills { skillID mark skill { name } } } } mutation UpdateStudentGroups($ownerUsername: String!, $groupIDs: [Int!]) { updateOneStudent(ownerUsername: $ownerUsername, groupIDs: $groupIDs) { ownerUsername firstName lastName groups { id name } } } mutation DeleteStudent($ownerUsername: String!) { deleteOneStudent(ownerUsername: $ownerUsername) { ownerUsername firstName lastName } } ``` -------------------------------- ### Manage Student Groups via GraphQL Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Operations to create new student groups and retrieve existing groups with their associated contracts and students. ```graphql mutation CreateGroup($name: String!, $contractID: Int) { createOneGroup(name: $name, contractID: $contractID) { id name contracts { id name } } } query GetGroups { groups { id name contracts { id name } students { ownerUsername firstName lastName } } } ``` -------------------------------- ### Docker Compose Deployment Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Configuration for deploying the backend and database services using Docker Compose, including environment variable mapping and port forwarding. ```yaml version: "3.9" services: backend: build: . platform: linux/x86_64 environment: DATABASE_URL: "postgres://postgres:example@database:5432/postgres" JWT_KEY: "your-secure-jwt-secret" PORT: "3000" USERNAME: "admin" PASSWORD: "secureadminpassword" ports: - "3000:3000" database: image: postgres restart: always ports: - "5432:5432" environment: POSTGRES_PASSWORD: example ``` -------------------------------- ### POST /query (Generate Spreadsheet) Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Generates an Excel spreadsheet containing all contracts with student skill assessments. ```APIDOC ## POST /query ### Description Generates an Excel spreadsheet containing all contracts with student skill assessments. Returns a base64-encoded data URL for download. ### Method POST ### Endpoint /query ### Request Body - **query** (String) - Required - GraphQL mutation: `mutation { generateSpreadsheet }` ### Response #### Success Response (200) - **data** (Object) - Contains the base64 encoded spreadsheet string ### Response Example { "data": { "generateSpreadsheet": "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,..." } } ``` -------------------------------- ### POST /graphql (UpsertSkillMark) Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Creates or updates a skill assessment mark for a student. ```APIDOC ## POST /graphql (UpsertSkillMark) ### Description Creates or updates a skill assessment for a student. The mark indicates the student's progress level on a specific skill. ### Method POST ### Endpoint /graphql ### Request Body - **studentOwnerUsername** (String) - Required - The student's username - **skillID** (Int) - Required - The skill ID - **mark** (String) - Required - Progress level (TODO, TO_FINISH, TO_CORRECT, GOOD, VERY_GOOD, BAD, VERY_BAD) ### Request Example { "query": "mutation UpsertSkillMark($studentOwnerUsername: String!, $skillID: Int!, $mark: Mark!) { upsertOneSkillToStudent(studentOwnerUsername: $studentOwnerUsername, skillID: $skillID, mark: $mark) { skillID mark } }", "variables": { "studentOwnerUsername": "jdoe", "skillID": 1, "mark": "GOOD" } } ``` -------------------------------- ### Query Teacher Accounts via GraphQL Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Retrieves a list of all teacher accounts. Requires the caller to have the TEACHER role. ```graphql query GetTeachers { teachers { ownerUsername firstName lastName owner { username role } } } ``` -------------------------------- ### Manage Skill Assessments via GraphQL Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Operations to upsert student skill marks and query skill assessments for specific students. ```graphql mutation UpsertSkillMark($studentOwnerUsername: String!, $skillID: Int!, $mark: Mark!) { upsertOneSkillToStudent(studentOwnerUsername: $studentOwnerUsername, skillID: $skillID, mark: $mark) { skillID studentID mark skill { name } student { firstName lastName } } } query GetStudentSkills($studentUsername: String!, $contractID: Int) { studentSkills(studentUsername: $studentUsername, contractID: $contractID) { skillID studentID mark skill { id name contract { name } } } } ``` -------------------------------- ### Generate and Download Excel Report Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Generates a base64-encoded Excel spreadsheet of student skill assessments. Includes a GraphQL mutation and a JavaScript implementation for browser-based file downloading. ```graphql mutation GenerateReport { generateSpreadsheet } ``` ```javascript async function downloadSpreadsheet(token) { const response = await fetch('http://localhost:3000/query', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ query: 'mutation { generateSpreadsheet }' }) }); const { data } = await response.json(); const link = document.createElement('a'); link.href = data.generateSpreadsheet; link.download = 'skills-report.xlsx'; link.click(); } ``` -------------------------------- ### Manage Skills via GraphQL Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Operations to create, update, and delete skills associated with contracts. These mutations require appropriate authorization roles. ```graphql mutation CreateSkill($name: String!, $contractID: Int!) { createOneSkill(name: $name, contractID: $contractID) { id name contractId } } mutation UpdateSkill($skillID: Int!, $name: String) { updateOneSkill(skillID: $skillID, name: $name) { id name } } mutation DeleteSkill($id: Int!) { deleteOneSkill(id: $id) { id name } } ``` -------------------------------- ### Manage Educational Contracts Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Operations for creating, querying, updating, and deleting contracts. These operations require appropriate teacher-level authorization. ```graphql mutation CreateContract($name: String!, $start: String!, $end: String!, $hexColor: String!, $skillNames: [String!]!) { createOneContract(name: $name, start: $start, end: $end, hexColor: $hexColor, skillNames: $skillNames) { id name } } query GetContracts { contracts { id name } } mutation UpdateContractGroups($contractID: Int!, $groupIDs: [Int!]) { updateOneContract(contractID: $contractID, groupIDs: $groupIDs) { id } } mutation DeleteContract($id: Int!) { deleteOneContract(id: $id) { id } } ``` -------------------------------- ### User Authentication API Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Handles user login and retrieval of authenticated user information. ```APIDOC ## POST /query (Login Mutation) ### Description Authenticates a user and returns a JWT token for subsequent API requests. The token must be included in the Authorization header as a Bearer token for protected operations. ### Method POST ### Endpoint /query ### Parameters #### Request Body - **query** (String!) - The GraphQL mutation string for login. - **variables** (Object) - Variables for the mutation, including username and password. - **username** (String!) - The user's username. - **password** (String!) - The user's password. ### Request Example ```json { "query": "mutation Login($username: String!, $password: String!) { login(username: $username, password: $password) { token user { username role } } }", "variables": { "username": "teacher1", "password": "securepassword" } } ``` ### Response #### Success Response (200) - **data** (Object) - The result of the mutation. - **login** (Object) - Login result. - **token** (String) - JWT token for authentication. - **user** (Object) - User information. - **username** (String) - The username of the logged-in user. - **role** (String) - The role of the logged-in user (e.g., TEACHER, STUDENT, ADMIN). #### Response Example ```json { "data": { "login": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "user": { "username": "teacher1", "role": "TEACHER" } } } } ``` ## GET /query (Get Current User Query) ### Description Retrieves the currently authenticated user's information. Requires the `@isLoggedIn` directive authorization. ### Method POST ### Endpoint /query ### Parameters #### Request Body - **query** (String!) - The GraphQL query string for fetching the current user. - **variables** (Object) - Variables for the query (optional). ### Request Example ```json { "query": "query Me { me { username role student { firstName lastName } teacher { firstName lastName } } }" } ``` ### Request Headers - **Authorization**: Bearer [JWT_TOKEN] ### Response #### Success Response (200) - **data** (Object) - The result of the query. - **me** (Object) - Information about the current user. - **username** (String) - The username of the current user. - **role** (String) - The role of the current user. - **student** (Object) - Student details (if applicable). - **firstName** (String) - Student's first name. - **lastName** (String) - Student's last name. - **teacher** (Object) - Teacher details (if applicable). - **firstName** (String) - Teacher's first name. - **lastName** (String) - Teacher's last name. #### Response Example ```json { "data": { "me": { "username": "teacher1", "role": "TEACHER", "student": null, "teacher": { "firstName": "Jane", "lastName": "Doe" } } } } ``` ``` -------------------------------- ### Authenticate User via GraphQL and cURL Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Authenticates a user and returns a JWT token. The token is required in the Authorization header for subsequent requests. ```graphql mutation Login($username: String!, $password: String!) { login(username: $username, password: $password) { token user { username role } } } ``` ```bash curl -X POST http://localhost:3000/query \ -H "Content-Type: application/json" \ -d '{ "query": "mutation { login(username: \"teacher1\", password: \"secret\") { token user { username role } } }" }' ``` -------------------------------- ### Retrieve Authenticated User Information Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Fetches details for the currently logged-in user. Requires a valid Bearer token in the Authorization header. ```graphql query Me { me { username role student { firstName lastName } teacher { firstName lastName } } } ``` ```bash curl -X POST http://localhost:3000/query \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{"query": "query { me { username role } }"}' ``` -------------------------------- ### Contract Management API Source: https://context7.com/pixselve/kontrakt-server-go/llms.txt Endpoints for creating, querying, updating, and deleting educational contracts. ```APIDOC ## POST /query (Create Contract Mutation) ### Description Creates a new educational contract with a name, date range, color identifier, and initial skills. This operation requires TEACHER role authorization. ### Method POST ### Endpoint /query ### Parameters #### Request Body - **query** (String!) - The GraphQL mutation string for creating a contract. - **variables** (Object) - Variables for the mutation. - **name** (String!) - The name of the contract. - **start** (String!) - The start date of the contract (e.g., "YYYY-MM-DD"). - **end** (String!) - The end date of the contract (e.g., "YYYY-MM-DD"). - **hexColor** (String!) - A hexadecimal color code for the contract. - **skillNames** (Array[String]!) - An array of skill names to associate with the contract. ### Request Example ```json { "query": "mutation CreateContract($name: String!, $start: String!, $end: String!, $hexColor: String!, $skillNames: [String!]!) { createOneContract(name: $name, start: $start, end: $end, hexColor: $hexColor, skillNames: $skillNames) { id name start end hexColor skills { id name } } }", "variables": { "name": "Mathematics Q1", "start": "2024-01-01", "end": "2024-03-31", "hexColor": "#3498db", "skillNames": ["Algebra", "Geometry", "Statistics"] } } ``` ### Response #### Success Response (200) - **data** (Object) - The result of the mutation. - **createOneContract** (Object) - The newly created contract. - **id** (Int) - The unique identifier of the contract. - **name** (String) - The name of the contract. - **start** (String) - The start date of the contract. - **end** (String) - The end date of the contract. - **hexColor** (String) - The hex color code of the contract. - **skills** (Array[Object]) - An array of skills associated with the contract. - **id** (Int) - The skill ID. - **name** (String) - The skill name. #### Response Example ```json { "data": { "createOneContract": { "id": 1, "name": "Mathematics Q1", "start": "2024-01-01 00:00:00 +0000 UTC", "end": "2024-03-31 00:00:00 +0000 UTC", "hexColor": "#3498db", "skills": [ { "id": 1, "name": "Algebra" }, { "id": 2, "name": "Geometry" }, { "id": 3, "name": "Statistics" } ] } } } ``` ## GET /query (Query Contracts) ### Description Retrieves all contracts, optionally filtered by group membership. Returns contract details including associated skills and groups. ### Method POST ### Endpoint /query ### Parameters #### Request Body - **query** (String!) - The GraphQL query string for fetching contracts. - **variables** (Object) - Variables for the query (optional). - **groupIds** (Array[Int!]) - An array of group IDs to filter contracts by. ### Request Example (All Contracts) ```json { "query": "query GetContracts { contracts { id name start end hexColor archived skills { id name } groups { id name } } }" } ``` ### Request Example (Filtered by Groups) ```json { "query": "query GetContractsByGroups($groupIds: [Int!]) { contracts(groups: { idsIn: $groupIds }) { id name skills { id name } } }", "variables": { "groupIds": [1, 2] } } ``` ### Response #### Success Response (200) - **data** (Object) - The result of the query. - **contracts** (Array[Object]) - An array of contract objects. - **id** (Int) - The contract ID. - **name** (String) - The contract name. - **start** (String) - The contract start date. - **end** (String) - The contract end date. - **hexColor** (String) - The contract hex color. - **archived** (Boolean) - Whether the contract is archived. - **skills** (Array[Object]) - Skills associated with the contract. - **id** (Int) - Skill ID. - **name** (String) - Skill name. - **groups** (Array[Object]) - Groups associated with the contract. - **id** (Int) - Group ID. - **name** (String) - Group name. #### Response Example (Filtered) ```json { "data": { "contracts": [ { "id": 1, "name": "Mathematics Q1", "skills": [ { "id": 1, "name": "Algebra" } ] }, { "id": 2, "name": "Physics Q1", "skills": [ { "id": 4, "name": "Mechanics" } ] } ] } } ``` ## POST /query (Update Contract Groups Mutation) ### Description Links or unlinks groups to a contract using a transactional update. ### Method POST ### Endpoint /query ### Parameters #### Request Body - **query** (String!) - The GraphQL mutation string for updating contract groups. - **variables** (Object) - Variables for the mutation. - **contractID** (Int!) - The ID of the contract to update. - **groupIDs** (Array[Int!]) - An array of group IDs to associate with the contract. ### Request Example ```json { "query": "mutation UpdateContractGroups($contractID: Int!, $groupIDs: [Int!]) { updateOneContract(contractID: $contractID, groupIDs: $groupIDs) { id name groups { id name } } }", "variables": { "contractID": 1, "groupIDs": [1, 2, 3] } } ``` ### Response #### Success Response (200) - **data** (Object) - The result of the mutation. - **updateOneContract** (Object) - The updated contract. - **id** (Int) - The contract ID. - **name** (String) - The contract name. - **groups** (Array[Object]) - The groups now associated with the contract. - **id** (Int) - Group ID. - **name** (String) - Group name. #### Response Example ```json { "data": { "updateOneContract": { "id": 1, "name": "Mathematics Q1", "groups": [ { "id": 1, "name": "Group A" }, { "id": 2, "name": "Group B" }, { "id": 3, "name": "Group C" } ] } } } ``` ## DELETE /query (Delete Contract Mutation) ### Description Removes a contract and all associated skills and student skill records in a transaction. ### Method POST ### Endpoint /query ### Parameters #### Request Body - **query** (String!) - The GraphQL mutation string for deleting a contract. - **variables** (Object) - Variables for the mutation. - **id** (Int!) - The ID of the contract to delete. ### Request Example ```json { "query": "mutation DeleteContract($id: Int!) { deleteOneContract(id: $id) { id name } }", "variables": { "id": 1 } } ``` ### Response #### Success Response (200) - **data** (Object) - The result of the mutation. - **deleteOneContract** (Object) - The deleted contract. - **id** (Int) - The ID of the deleted contract. - **name** (String) - The name of the deleted contract. #### Response Example ```json { "data": { "deleteOneContract": { "id": 1, "name": "Mathematics Q1" } } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.