Skip to content

Conversation

@gmac
Copy link
Owner

@gmac gmac commented Apr 29, 2025

Adds visibility controls to a stitched schema, allowing parts of a supergraph to be hidden from select audiences without compromising stitching implementation details. This offers the capabilities of Apollo Federation's @inaccessible directive with more flexibility atop GraphQL Ruby's Visibility system.

type Product {
  id: ID! @visibility(profiles: []) # hidden from all requests
  msrp: Float! @visibility(profiles: ["private"]) # only visible to "private" requests
  price: Float! # visibile to all requests
}

This features wraps the GraphQL::Schema::Visibility system and uses nil profiles, so requires GraphQL Ruby v2.5.3 or later. While this is a pretty significant new feature, it adds no breaking behavior to existing stitching operations.

Resolves #122.
Resolves #133.

@gmac gmac marked this pull request as ready for review April 29, 2025 12:24
@gmac gmac force-pushed the visibility3 branch 5 times, most recently from 056caa4 to 589a721 Compare May 1, 2025 02:25
@gmac gmac merged commit 8698a19 into main May 1, 2025
7 checks passed
@gmac gmac deleted the visibility3 branch May 1, 2025 02:49
@rmosolgo
Copy link

rmosolgo commented May 2, 2025

Very cool -- I dreamed of a similar Ruby API (visible_in(...)?) when I added visibility profiles but ran out of steam during rmosolgo/graphql-ruby#5074 😩 Maybe I can take some inspiration from this implementation!

@gmac
Copy link
Owner Author

gmac commented May 2, 2025

Ha, as the branch name implies, this was my third attempt (spanning two years) at incorporating visibility. The first two got bogged down in complexity and didn't feel very good. Once Visibility showed up though, there was a much clearer path. Once from_definition(base_types: ...) went in, I was out of excuses 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Composer directives for omitting elements Support schema visibility controls

3 participants