Skip to content
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

feat: expose compose method of engine federation config factory #876

Conversation

ikawaha
Copy link
Contributor

@ikawaha ikawaha commented Aug 21, 2024

First of all, we want to express our respect for the wundergraph team's work on graphql-go-tools. We appreciate the effort that has gone into developing this tool, and we hope that this PR can contribute to improving the performance and memory efficiency of subgraph composition in GraphQL federation.

When building the EngineConfiguration, the BuildEngineConfiguration method performs subgraph composition. This composition is done using the Cosmo library, which generates a serializable data structure known as the router config in the Cosmo library.

As subgraphs grow larger, the time complexity and memory usage of the composition process can become significantly higher. However, if we know when the structure of a subgraph changes, we can reuse the router config to build the EngineConfiguration without recomposing the subgraph.

In this PR, we enable the serialization of the router config (referred to as the intermediate config in graphql-go-tools) used in Cosmo, allowing it to be reused when constructing the EngineConfiguration.

By serializing the router config, we can execute the EngineConfiguration at a lower cost when there are no changes to the subgraph. This is particularly useful during server startup or when refreshing a GraphQL gateway.

@ikawaha ikawaha changed the title Enhance GraphQL Federation Efficiency by Reusing Router Config in Subgraph Composition feat: Enhance GraphQL Federation Efficiency by Reusing Router Config in Subgraph Composition Aug 21, 2024

// RouterConfig is an intermediate data that holds the result of the composition
// and can be saved to a file to configure the router data sources when creating an engine config.
type RouterConfig struct {
Copy link
Member

@devsergiy devsergiy Aug 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ikawaha

We probably could use proto types directly
Is there any special need for the wrapping structure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your feedback. I initially wrapped nodev1.RouterConfig because it was hidden, and my goal was to make it serializable. However, I agree that using the proto types directly would be clearer and more straightforward. I've made the necessary adjustments to avoid the wrapping structure and now utilize nodev1.RouterConfig directly.

I've pushed the changes—does this look better to you? 24b4a97

@devsergiy devsergiy changed the title feat: Enhance GraphQL Federation Efficiency by Reusing Router Config in Subgraph Composition feat: expose compose method of engine federation config factory Aug 22, 2024
@devsergiy devsergiy closed this in 95e943e Aug 22, 2024
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.

2 participants