-
-
Notifications
You must be signed in to change notification settings - Fork 787
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
[Refactor] Recipe Schema Types #2167
Comments
I think for recipes specifically the For |
I like Though to me
To me,
-- To be clear, I think these are all good ideas, and I'm mostly just thinking out loud, not trying to say I or you are wrong/right. At this point I'm mostly just trying to find a direction "language" to use to make intentions clear - cause right now (like any large codebase) we don't have consistent language around the types used |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The Current Recipe type in the schema directory does a poor job of representing the actually type of a Recipe. It includes many
{type} | None
fields that should never actually be null for a created recipe, but because of technical debt reasons, require a nullable property which makes the generated frontend types difficult to work with and adds unnecessary null checks or wacky type casting to use properly.More importantly, it creates distrust with the type system which I think leads to actual bugs where a developer assumes the type checker is wrong and casts to another.
I suggest we refactor the Recipe model into subtypes like
RecipeSummary
where they represent a subset or superset of the Recipe Representation.My general ideas is to have
RecipeMaybe
which represents a type with nullable properties which can be used as an intermediary type that is used for Import/Export or constructing a recipe before it is saved to the database.RecipeOut
which represents the full data transfer object of a single recipe with all fields. This will contain the least amount of nullable fieldsRecipeSummary
largely similar or the same to the existing model which represents just the basic details.RecipeIdentifier
- Not sure if this is necessary, but it could be an alternative to summary that is even slimmer and just contains the Name, Slug, and ID. Useful for a dropdown of a dropdown, or for a faster quick-search.I think we could apply these naming conventions to other objects as well, e.g.
CategoryMaybe
,CategoryOut
,CategorySummary
,CategoryIdentifier
if necessary. Specifically I am thinking in the context of search and filters where you need varying amounts of information and less is better.The text was updated successfully, but these errors were encountered: