ask-and-trust - v1.1.0
    Preparing search index...

    Survey Resolver

    Handles all survey-related GraphQL mutations and queries.

    Index

    Constructors

    Methods

    • Mutation to create a new survey.

      Parameters

      • data: CreateSurveyInput

        The input data containing the survey details, including the title, description, and category.

      • context: Context

        The context object that contains the currently authenticated user.

      Returns Promise<Survey>

      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.

      Parameters

      • id: number

        The ID of the survey to delete.

      • context: Context

        The context object that contains the currently authenticated user.

      Returns Promise<null | Survey>

      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.

      Parameters

      • id: number

        The ID of the survey to fetch.

      Returns Promise<null | Survey>

      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.

    • Mutation to update an existing survey.

      Parameters

      • id: number

        The ID of the survey to update.

      • data: UpdateSurveyInput

        The input data containing the updated survey details.

      • context: Context

        The context object that contains the currently authenticated user.

      Returns Promise<null | Survey>

      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.