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

Improve ability to override existing graphql models. #440

Merged
merged 7 commits into from
Jan 16, 2024

Conversation

tjeerddie
Copy link
Contributor

@tjeerddie tjeerddie commented Jan 10, 2024

  • Change register_graphql to re-create autogenerated models and update the graphql router schema.
  • add strawberry class override to change field resolvers of existing classes.
  • add unit tests for override_class function and add test that overrides Query.
  • move register_domain_models to create_graphql_router.
  • change register_domain_models to take existing models with a parameter instead of a global dict.
  • move StrawberryPydanticModel, StrawberryModelType and GRAPHQL_MODELS to graphql.schemas init.
  • create default Subscription inside the create_graphql_router to recreate it when interface is updated.

Fixes: #393, #310
Both fixed by the ability to update schema with running app.register_graphql multiple times.

Copy link

codecov bot commented Jan 10, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (fed5d8c) 71.33% compared to head (73ff838) 75.62%.

Files Patch % Lines
orchestrator/graphql/utils/override_class.py 87.50% 1 Missing and 1 partial ⚠️
orchestrator/graphql/schema.py 93.75% 0 Missing and 1 partial ⚠️
orchestrator/graphql/utils/is_query_detailed.py 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #440      +/-   ##
==========================================
+ Coverage   71.33%   75.62%   +4.29%     
==========================================
  Files         193      195       +2     
  Lines        9659     9703      +44     
  Branches     1316     1609     +293     
==========================================
+ Hits         6890     7338     +448     
+ Misses       2561     2130     -431     
- Partials      208      235      +27     

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

@Mark90
Copy link
Contributor

Mark90 commented Jan 11, 2024

  • move register_domain_models to create_graphql_router.
  • move StrawberryPydanticModel, StrawberryModelType and GRAPHQL_MODELS to graphql.schemas init.

Will orchestrator implementations need to adjust imports for this?

@tjeerddie tjeerddie force-pushed the improve-graphql-override branch 6 times, most recently from 321e5c4 to 70c89bb Compare January 15, 2024 08:28
Base automatically changed from customer-update to main January 15, 2024 14:45
tjeerddie and others added 5 commits January 16, 2024 12:22
- add strawberry class override to change field resolvers of existing classes.
- add unit tests for override_class function and add test that overrides `Query`.
- move register_domain_models to create_graphql_router.
- change register_domain_models to take existing models with a parameter instead of a global dict.
- move `StrawberryPydanticModel`, `StrawberryModelType` and `GRAPHQL_MODELS` to graphql.schemas init.
- create default `Subscription` inside the create_graphql_router to recreate it when interface is updated.
Co-authored-by: Mark Moes <mark_moes@live.nl>
- rename format_default_subscriptions to format_base_subscription.
- improve test_override_class.
- move `create_subscription_strawberry_type` out of `add_class_to_strawberry`.
- the override_class can make the mapping itself instead of needing to do duplicate naming in the field and in the mapping given to the override_class.
- change interface type in autoregistration to Type.
- change unit test github action to not run graphql separately
- update override_class function typing.

Fixes: #393, #310
Copy link
Collaborator

@dmarjenburgh dmarjenburgh left a comment

Choose a reason for hiding this comment

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

LGTM

@tjeerddie tjeerddie merged commit 228b1aa into main Jan 16, 2024
8 checks passed
@tjeerddie tjeerddie deleted the improve-graphql-override branch January 16, 2024 12:49
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.

Make it possible to run the graphql unit_tests with the entire suite
3 participants