Mutation to create a new survey.
The input data containing the survey details, including the title, description, and category.
The context object that contains the currently authenticated user.
A Promise that resolves to the newly created Survey object.
This mutation allows a user to create a new survey. Only users with the "user" or "admin" roles can create surveys. The survey is associated with the currently authenticated user.
Mutation to delete an existing survey.
The ID of the survey to delete.
The context object that contains the currently authenticated user.
A Promise that resolves to the deleted Survey object, or null if the survey could not be found or deleted.
This mutation allows an admin or user to delete an existing survey. Only the admin or the survey owner can delete surveys. If the user is not an admin or the wurvey owner, the mutation will not be executed.
Query to get a specific survey by ID.
The ID of the survey to fetch.
A Promise that resolves to a Survey object if found, or null if no survey is found.
This query retrieves a specific survey by its ID, along with its associated user and category information.
Query to get all surveys.
A Promise that resolves to an array of Survey objects.
This query retrieves all surveys, along with their associated user and category information.
Mutation to update an existing survey.
The ID of the survey to update.
The input data containing the updated survey details.
The context object that contains the currently authenticated user.
A Promise that resolves to the updated Survey object, or null if the survey could not be found or updated.
This mutation allows a user to update an existing survey. Only users with the "user" or "admin" roles can update surveys. If the user is not an admin, they can only update surveys they have created.
Survey Resolver
Description
Handles all survey-related GraphQL mutations and queries.