-
Notifications
You must be signed in to change notification settings - Fork 40
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
Map a complex class to a scalar #251
Comments
How would it be decided for which types this would be done, via a separate annotation? And should it always be a string scalar? Theoretically, boolean and numbers would also be possible (or any other scalar-type). |
I assume that hardly anybody really wants to have wrapper classes showing up in the Schema; so I'm in favor of doing it for any class that matches the criteria. If that's a problem, we could add a config option containing a list of fully qualified class names that should be converted automatically. And if this configuration is Other types would work, too, but Strings are the 99,99% case ;-) Instead of |
I'm not sure if there are clear criteria to identify such wrapper classes. A config option would be a possibility for this, but I personally would prefer an annotation for this. Do you see any disadvantages with an annotation for that?
I can imagine some cases where string is not enough, e.g. something like Velocity, Weight, Length. But for the start string is probably enough. |
You're right, the Team example may not be what a user would expect. It's clear for MP Config or even the GraphQL Client, but not for generating schemas. The constructor methods would be clear, though, wouldn't they? I'm perfectly fine with an annotation like
I think these would generally also require a unit. But you're right there will be use-cases. Maybe it's not 99,99% but only 99,9% ;-) |
* Transform types when a transformation is required instead of keeping a list of types to transform * Specify concrete types for transformations. Makes code simpler (eg, use numbers directly instead of formatting->parsing->formatting->parsing) and more explicit * Handle chars correctly, char-inputs didn't work before * Handle BigInteger/BigDecimal correctly, previously those didn't work correctly if formatted (truncated to double or simply failing) * Handle arrays of formatted types correctly, didn't worked before * Build a foundation for eclipse/microprofile-graphql#251 Signed-off-by: Yannick Bröker <[email protected]>
Constructor methods should be clear (well, I'd be surprised if there isn't a code base somewhere where Maybe it is enough for a first implementation to use only If an annotation is used, annotating third party libs should be possible with #111 once this is solved. |
I am in favour of a more explicit approach, by adding an annotation. And for the case where these classes is in a 3rd party libs, this is an existing case, that we need to solve, and this should be solved the same way. See #111 |
Okay. I'm fine with that. |
* Transform types when a transformation is required instead of keeping a list of types to transform * Specify concrete types for transformations. Makes code simpler (eg, use numbers directly instead of formatting->parsing->formatting->parsing) and more explicit * Handle chars correctly, char-inputs didn't work before * Handle BigInteger/BigDecimal correctly, previously those didn't work correctly if formatted (truncated to double or simply failing) * Handle arrays of formatted types correctly, didn't worked before * Build a foundation for eclipse/microprofile-graphql#251 Signed-off-by: Yannick Bröker <[email protected]>
* Transform types when a transformation is required instead of keeping a list of types to transform * Specify concrete types for transformations. Makes code simpler (eg, use numbers directly instead of formatting->parsing->formatting->parsing) and more explicit * Handle chars correctly, char-inputs didn't work before * Handle BigInteger/BigDecimal correctly, previously those didn't work correctly if formatted (truncated to double or simply failing) * Handle arrays of formatted types correctly, didn't worked before * Build a foundation for eclipse/microprofile-graphql#251 Signed-off-by: Yannick Bröker <[email protected]>
This needs special consideration for |
This would not be usable for numbers anyway (at least on the server side). The mapping from string to number is only necessary if the number is formatted, and then a NumberFormatter must be used anyway. |
This is now supported (per field) in SmallRye with |
This is an issue split out of the discussion in #94, as we where talking about separate issues (see meeting notes from today).
In Java we often use types that only have a single String field. Something like:
An
email
field inSuperHero
should be represented as aString
in the Schema; to convert it to a String, use thetoString
method; to convert it from a String, use either a constructorpublic Email(String value)
or a static constructor methodpublic static Email valueOf(String value)
. ThevalueOf
method could also be namedparse
orof
. This logic is the same as used in MP Config for Automatic Converters.The very welcome side effect would be that we wouldn't need the special handling for
LocalDate
,Integer
, and many more standard classes any more.The text was updated successfully, but these errors were encountered: