Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This method is meant to quickly check if
transformSupergraphToPublicSchema
is needed.Obviously, in most cases when
transformSupergraphToPublicSchema
is used, a provided schema contains Supergraph spec (join__Graph etc).Why do I create it then?
We have a special case in GraphQL Hive where we persist the output of
transformSupergraphToPublicSchema
, but when Apollo Federation adds something new, we might want to run this method again to remove new pieces.Performance
I used a Supergraph SDL with ~20k LOC and create three copies.
First copy used
field(whatever: join__Graph)
as an argument somewhere in the middle.Second copy had
scalar join__DirectiveArguments
, also in the middle of the file.Third copy had
directive @join__directive
definition (yeah yeah, in the middle).I wrote three versions of
containsSupergraphSpec
to make sure it has minimal performance footprint.sdl.includes("[name") or sdl.includes(" name")
I ran it 1000 times and I got (average):