Skip to content

Commit 2b26ac4

Browse files
committed
fix: various preformace imporvements
1) getObjectOrInterfaceTypeNameIfExists - This function was not fixed on the move to map based metadata storage. Now instead of looking inside an entire metadata array, it fetches the item from the map 2) MetadataCollectionModel - I noticed that the interfaces list recieves duplicate instances of the same interface, so I switched the implementation to a map to remvoe duplicates. 3) LazyMetadataStorageHost.load - In very large applications (ie several millions of metadata object) we encountered an invalid arugments size thrown from V8, this is because the spread operator behind the scenes translates the values to multiple arguments. Switching to flat() solves this issue. 4) GraphQLSchemaFactory.create & LazyMetadataStorageHost.updateStorage - We noticed that the entire GQL metadata model was being rebuilt several times during the bootstrap of the application, I assume this was done because of the need to clear and rebuild the arrays every time. Now when we use maps we can't get duplicates in the metadata store, so I verify that the updateStorage callback is called only once, and I removed the clear call from the GraphQLSchemaFactory.create(). This results in a tremendous memory consumption boost! (in our case, from 8GB to 700MB)
1 parent edd5545 commit 2b26ac4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/mercurius/tests/e2e/code-first-federation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type Query @extends {
7575
"""Search result description"""
7676
union FederationSearchResultUnion = Post | User
7777
78-
type User @extends @key(fields: "id") {
78+
type User @key(fields: "id") @extends {
7979
id: ID! @external
8080
posts: [Post!]!
8181
}

0 commit comments

Comments
 (0)