Skip to content

What does 'root' mean? #1948

Answered by JClackett
MincePie asked this question in Q&A
Feb 22, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Yeah so in this particular example we are applying a "method decorator" called UseIsCurrentUser to a field on the user model/type. The purpose is that once we've retrieved the user from the database, we check if the current user (i.e the logged in user "making" the request), is authorised to "see" the email of the user that is being requested. This is stop random users getting information of other users that we don't want! When applying a method decorator to a field or field resolver, the root refers to the type "above" the current field in the graphql tree/schema

so for example, imagine we are querying a user, our graphql query will look something like:

user(id: String!) { # <--- this is…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MincePie
Comment options

Answer selected by JClackett
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants