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
Is your feature request related to a problem? Please describe.
I'm always frustrated when I have to explicitly set required a List field, or any field for that matter. It makes for really frustrating usage of our APIs that rely on typescript types generated by our graphene schema. We have to constantly add unnecessary checks and write more obtuse code just to satisfy our types. On top of that, the way that this typing is done both in python(pyright and I believe others) and in typescript are the exact opposite, you explicitly define that something can be optional. This makes it extremely unintuitive and hard to spot issues until the api starts getting use from our typescript apps.
Describe the solution you'd like
A setting at the root level to have required default to true always se we have to explicitly set required to false. This would also apply to NonNull for list queries which might need a Nullable, or Optional, or allow the required argument for type to work with the list.
Describe alternatives you've considered
I can build new types that extend the existing types and add a linter to make sure none of the original types are being used in future development. It's doable, and I'll end up doing it, but the solution I'm suggesting doesn't feel that farfetched to put in for others who may have this frustration.
Additional context
In typescript if I want to type as an array I can use Array, or [], and it will be an array, it wont expect null and it wont expect undefined. I have to be explicit if the value is nullable or undefined. Similarly in python, with pyright at least, you also have to be making sure to be explicit that the type is optional or nullable.
I'm at the very least curious why required is defaulted to false in the first place.
The text was updated successfully, but these errors were encountered:
Messaging to hopefully get a response. I'm happy to put up a PR but if it's not going to be accepted from the get-go then I won't waste my time. It wouldn't break existing functionality, allowing the user to opt in to defaulting to optional or required.
Hey there, sorry for the wait. I think this would be a great Quality of Life improvement for many users. We should discuss where this is best implemented. Cleanest option would probably be an argument of the Schema class. However, that might create issues in the field initialization phase. I haven't had the time to look into it yet. Happy discuss any ideas you come up with!
@erikwrede thanks for responding!! I have an idea and would love your opinion.
I could maybe doing some sort of global settings module that one could set at the start of their program. Then updating the Fieldinit required param to required=None and if the value is none, set the value based on the settings default.
The global settings could also be useful for other global options or options similar to this if they've been requested
Is your feature request related to a problem? Please describe.
I'm always frustrated when I have to explicitly set required a List field, or any field for that matter. It makes for really frustrating usage of our APIs that rely on typescript types generated by our graphene schema. We have to constantly add unnecessary checks and write more obtuse code just to satisfy our types. On top of that, the way that this typing is done both in python(pyright and I believe others) and in typescript are the exact opposite, you explicitly define that something can be optional. This makes it extremely unintuitive and hard to spot issues until the api starts getting use from our typescript apps.
Describe the solution you'd like
A setting at the root level to have required default to true always se we have to explicitly set required to false. This would also apply to NonNull for list queries which might need a Nullable, or Optional, or allow the required argument for type to work with the list.
Describe alternatives you've considered
I can build new types that extend the existing types and add a linter to make sure none of the original types are being used in future development. It's doable, and I'll end up doing it, but the solution I'm suggesting doesn't feel that farfetched to put in for others who may have this frustration.
Additional context
In typescript if I want to type as an array I can use Array, or [], and it will be an array, it wont expect null and it wont expect undefined. I have to be explicit if the value is nullable or undefined. Similarly in python, with pyright at least, you also have to be making sure to be explicit that the type is optional or nullable.
I'm at the very least curious why required is defaulted to false in the first place.
The text was updated successfully, but these errors were encountered: