-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Visibility leaves dangling types #5265
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
Comments
I'm open to revisiting this. At first, I wrote it off because the new approach didn't have any top-level caches. But now it does, so this might be possible. Regarding fields in particular, I think the graphql-ruby/lib/graphql/schema/member/has_fields.rb Lines 150 to 157 in 19dcf75
I think that's needed because Visibility::Profile handles array entries itself (instead of using In
and
Perhaps it could call into If you're interested in exploring it, I hope those clues are helpful. Otherwise I'll take a look soon, probably early next week. |
Looking at this again a bit closer, my main reservation of the new system is that it leaves unreachable elements in the schema, which is a bit of a "soft" security risk. Another example: enum WidgetOrder { # << visibility unspecified
ID
}
type Widget { # << visibility hidden
id: ID
}
type Query {
widget(order: WidgetOrder): Widget # << visibility unspecified, but hidden via Widget return
} So in the above, |
👀 I'm surprised that didn't turn up in my migration notes, I guess I didn't have a setup like that in my tests.
It's true, that switching could result in publishing some orphan types. But a schema dump in source control would catch that (is it fair to assume that those are set up in the wild?). I built migration mode to help with this too, but if this case doesn't appear in my notes, then I don't know for sure that migration mode would cover it. I think it would need a call to |
I added a failing test for that case here: #5291 I'll see if it's possible to implement just like Warden. |
Not sure if this is a bug or not... it looks like Visibility and Warden put different priority on fields belonging to objects and interfaces. Consider:
It looks like Warden would resolve
Widget.size
as public, because the interface would have the final say on its fields. With Visibility it seems the object field has final say and goes private.In some ways the Visibility implementation makes sense because the more specific implementation wins, EXCEPT – we're allowing the object to renege on its interface. This turns into a footgun that allows developers to compose invalid schemas; best case scenario the more restrictive override should probably error.
I'm seeing echoes of this in other places with dangling objects and interfaces left in the schema without fields or implementations. On one hand this is a feature of faster visibility, on the other hand it's an open door for sloppy mistakes. I'm curious if there's a middle ground here that capitalizes on Visibility advantages while also enforcing strong schema guarantees, even if only in certain circumstances?
The text was updated successfully, but these errors were encountered: