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

Workaround for graphql performance issue when using generic input types #836

Closed
wants to merge 5 commits into from

Conversation

dancoates
Copy link
Contributor

At the moment there is a issue with strawberry graphql which causes performance issues in cases where the field type for a large result set uses a generic input type. There is an outline of this issue here: strawberry-graphql/strawberry#3544 and a stripped down reproduction case here https://github.com/dancoates/strawberry-generic-input-repro/blob/main/schema.py.

This PR introduces a workaround to this issue by making input types concrete before they are used in the GraphQL schema. This does introduce some code duplication, but IMO is worth it for the speed up, in my testing it has made requests 3-5x faster.

This works around an issue in strawberry graphql where using generic
input types on fields that may return many items causes severe
performance degredation.
@dancoates dancoates requested a review from illusional June 24, 2024 07:53
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.27%. Comparing base (7717ebe) to head (d41a483).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #836      +/-   ##
==========================================
+ Coverage   79.17%   79.27%   +0.10%     
==========================================
  Files         161      161              
  Lines       13615    13684      +69     
==========================================
+ Hits        10779    10848      +69     
  Misses       2836     2836              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dancoates
Copy link
Contributor Author

Closing in favour of #841

@dancoates dancoates closed this Jun 26, 2024
@dancoates dancoates deleted the graphql-performance-fixes branch October 28, 2024 05:13
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