-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Visibility profiles should always evaluate based on profile context #5231
Comments
Hey @gmac, thanks for reviewing this feature and sharing your thoughts. I definitely want to work out these rough edges you ran into.
|
I don't have strong feelings here as long as it works one way. Once I followed the code and found that it came from a query argument, that actually seemed pretty sensible – it's more deliberate than stuffing magic keys into context. That said, we already have a long history of magic context keys, so for us the context approach is almost more conventional.
I think I'd stick with this suggestion that makes both request context and profile settings available: class Widget < GraphQL::Schema::Object
def self.visible?(context)
super && context.visibility_profile_settings[:internal]
end
end The reason there is the very useful class Widget < GraphQL::Schema::Object
def self.visible?(context)
super && begin
if (profile_settings = context.visibility_profile_settings)
profile_settings[:internal]
else
context[:api_client].beta_enabled?(:my_beta_flag)
end
end
end
end At the front of the request, we'd then simply choose not to declare a visibility profile for clients that we see have certain beta flag sensitivities. Another possible approach would be to increase argument arity to |
Actually, follow-up thought here: maybe we could get the best of both worlds… in a request that defines This puts pretty strong gravity on the |
Agreed on how those contexts should work. I took a crack at it here: #5235 |
Describe the bug
I'm playing around with the new visibility features and really like the direction this is going. Nice work. The DX is pretty unintuitive though because of all the nuanced interactions. It could be a lot simpler and more reliable, IMO. Consider:
This gets even more nuanced with the
preload
attribute in play:Versions
graphql
version: 2.4Expected behavior
What I'd expect would be for visibility to always favor evaluating based on the profile definition. The profile settings should always be provided to
visible?
as a separate argument or through context, then documentation should indicate that we should always check static profile settings before other aspects of request context, ie:Actual behavior
Visibility without preloading computes based on request context, which may or may not match what's defined for the visibility profile. Preloaded profiles may not match request context. Also, docs say that
visibility_profile
is a context key, when it actually appears to be a query argument.The text was updated successfully, but these errors were encountered: