Skip to content

Get access to the query/mutation parameters inside mapped type #521

@smilesrg

Description

@smilesrg

Hello!

How can query/mutation parameters be accessed inside a mapped type?

I'll give some real examples. There's a query:

query {
  feedback(classId:"41reqda11") {
    questions {
      answers {
        id
        answer
      }
      studentAnswers {
        id
        answer
      }
    }
  }
}

and the mapped type:

/**
 * @Type(class=Question::class)
 * @SourceField(name="answers")
 */
class QuestionType
{
    /**
     * @return Answer[]
     */
    #[Field, Logged, Right(User::ROLE_STUDENT)]
    public function getStudentAnswers(
        Question $question
    ): array {
        // I need an access to the query parameter "classId" right here
    }
}

So I need to get all answers answered by the student for the given class. To do this, I need to know the classId. How can I fetch classId parameter?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions