thecodingmachine / graphqlite

Use PHP Attributes/Annotations to declare your GraphQL API

Home Page:https://graphqlite.thecodingmachine.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get access to the query/mutation parameters inside mapped type

smilesrg opened this issue · comments

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?