You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unify field and field_link. Field and Link are needlessly different, while often being used in the same context.
Link often requires customly created private Field for low-level graph access optimizations. This spams graph definition with lots of Fields that are basically parts of corresponding Links and are otherwise useless for API clients. Possible solution: for link replace requires with the second resolver, common for all fields (similar to current field funcs).
Fields usually share one common resolver, which gives ability to make super efficient queries and is generally one of the things that makes hiku a great tool. BUT it also gives a few problems: never ending if field_name == 'someName': ... statements, which complicate application logic; and the inablity to attach any out-of-the-box typecheckers to field resolvers. Possible solution: for field add a new field-specific resolver (similar to current link funcs).
With proposed solutions there is not quite clear difference between two resolvers (common for all fields and field-specific), which may introduce problems in the future. This should be discussed.
Add dataclass-typed Options and change field resolvers to accept them. Same option classes can be used in both resolver annotations and graph declaration.
Require explicit Node key declaration (value returned from link funcs and recieved by field resolvers). This will make typechecking of such types easier and improve understanding of hiku type resolvers.
Return lightweight objects from link functions instead of scalars. Something like Article.link(1) will be much easier to typecheck, will make resolvers for union and interface types much more intuitive, and will remove need for custom Nothing constant in favour of None.
Typecheck field resolvers for return and argument types.
Send context into every resolver. This will greatly simplify internal code, but may impact performance.
Find alternative for @define functions: S.this constructs are not easy to understand and decorators use strings which are prone to errors.
The text was updated successfully, but these errors were encountered:
Fields usually share one common resolver, which gives ability to make super efficient queries and is generally one of the things that makes hiku a great tool. BUT it also gives a few problems: never ending if field_name == 'someName': ... statements, which complicate application logic; and the inablity to attach any out-of-the-box typecheckers to field resolvers. Possible solution: for field add a new field-specific resolver (similar to current link funcs).
One thing that comes into mind, is to use specific resolvers for fields, but mark that all of them bound somehow, for example:
in future class-based definition it will be much easier to generate (or call implicitly ) the same code
@hiku.nodeclassUser:
id: intname: stremail: str# nothing prevents us from implicitly iterate over each user and call `getattr(user, field)` which is the same as defining a # function for each field which will return just the same attribute explicitly
Cons:
in plain-old hiku field mapper, if you want to apply custom logic to field, you just do it in an if statement, but in my prototype each custom field handler is automatically a separate function
more function calls (though it is not clear if it actually will harm perf since we actually calling get_field private function for each field which is mostly the same )
more iterations over users collection
possible solution - accept user instead of users and do iteration in hiku internally
field
andfield_link
.Field
andLink
are needlessly different, while often being used in the same context.Link
often requires customly created privateField
for low-level graph access optimizations. This spams graph definition with lots ofField
s that are basically parts of correspondingLink
s and are otherwise useless for API clients. Possible solution: forlink
replacerequires
with the second resolver, common for all fields (similar to current field funcs).Field
s usually share one common resolver, which gives ability to make super efficient queries and is generally one of the things that makes hiku a great tool. BUT it also gives a few problems: never endingif field_name == 'someName': ...
statements, which complicate application logic; and the inablity to attach any out-of-the-box typecheckers to field resolvers. Possible solution: forfield
add a new field-specific resolver (similar to current link funcs).Option
s and change field resolvers to accept them. Same option classes can be used in both resolver annotations and graph declaration.Article.link(1)
will be much easier to typecheck, will make resolvers for union and interface types much more intuitive, and will remove need for customNothing
constant in favour ofNone
.@define
functions:S.this
constructs are not easy to understand and decorators use strings which are prone to errors.The text was updated successfully, but these errors were encountered: