-
-
Notifications
You must be signed in to change notification settings - Fork 544
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
Move StrawberryConfig to a typed dict #2942
Comments
@patrick91 https://peps.python.org/pep-0705/ might be useful if it allows us to inherit from a base class that specifies the defaults |
As an alternative to TypedDict, which is pretty basic - the pydantic_settings module has an excellent configuration interface: https://docs.pydantic.dev/latest/usage/pydantic_settings/ It allows setting default values, enforces type/value validation, can take overrides from env vars by default, and be extended to read settings from a variety of different sources (config files, etc). |
@jgadling thanks for the suggestion! I think that would be neat, but I'd prefer to keep the base dependencies at a minimum if possible 😊 |
Hi @patrick91 , Changing |
as suggested in #2698 (comment)
we should change strawberry's schema config to be a type dictionary, I think this will make the dx a bit nicer, since you can do this:
which is a reduction of one import (and bit less characters) 😊
The main disadvantage for users it that they might not get autocompletion if their editor is not setup well.
The main disadvantage for us is that it might get a bit cumbersome to get values (or fallback to default values).
In any case if we do this, we should deprecate the old config, and write a codemod, which should be easy to do 😊
Upvote & Fund
The text was updated successfully, but these errors were encountered: