Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. 1. for-loop over all federation scalars, enums and directives that used `sdl.includes("[name") or sdl.includes(" name")` 2. same for-loop but directives where checked first 3. regex (current implementation). I ran it 1000 times and I got (average): 1. 1.56 ms 2. 0.83 ms 3. 0.59 ms
- Loading branch information