Skip to content

How to do Field visibility by object owner (vs authorization) #3938

Answered by rmosolgo
nimmolo asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, great question.

"Visibility" is checked before running any of the query (even before validating the query string), so object isn't available. No fields have been executed, no queries have been started, etc -- there's just no runtime data. All we have is the query string and the context.

If you want to use actual runtime values (objects that are being used to resolve fields), then you have to use some runtime feature to implement this. "Authorization" might work (although you said it above it won't 😅 !) , but also, you could implement the field to return nil for unauthorized users:

field :email, String, description: "The user's email address. (Hidden for non-admins, unless you're requ…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@nimmolo
Comment options

@nimmolo
Comment options

Answer selected by nimmolo
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