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

    QuestionsResolver

    Handles all GraphQL operations related to survey questions.

    Index

    Constructors

    Methods

    • Mutation to create a new survey question.

      Parameters

      • data: CreateQuestionsInput

        The input content for creating the question (title, type, answers, etc.).

      • surveyId: number
      • context: Context

        The GraphQL context containing the authenticated user.

      Returns Promise<Questions>

      A Promise that resolves to the newly created Questions object.

      This mutation allows an authenticated user ("user" or "admin" role) to create a new question. The created question is optionally linked to a survey and associated with the authenticated user.

    • Mutation to delete an existing survey question.

      Parameters

      • id: number

        The ID of the question to delete.

      • context: Context

        The context object that contains the currently authenticated user.

      Returns Promise<null | Questions>

      A Promise that resolves to the deleted Question object, or null if the question could not be found or deleted.

      This mutation allows an admin or user to delete an existing survey question. Only the admin or question owner can delete questions. If the user is not an admin or question owner, the mutation will not be executed.

    • Query to get a specific survey question by ID.

      Parameters

      • id: number

        The ID of the question to retrieve.

      Returns Promise<null | Questions>

      A Promise that resolves to the corresponding Questions object, or null if not found.

      This query fetches a specific question based on its ID, including its related survey.

    • Mutation to update an existing survey question.

      Parameters

      • id: number

        The ID of the question to update.

      • data: UpdateQuestionInput
      • context: Context

        The context object that contains the currently authenticated user.

      Returns Promise<null | Questions>

      A Promise that resolves to the updated Questions object, or null if the question could not be found or updated.

      This mutation allows an admin user to update an existing survey question. Only the admin or the question owner can update questions. If the user is not an admin, the mutation will not be executed.