Field of type UUID scalar on GraphQL Server #1842
Replies: 6 comments 13 replies
-
hi! Any thoughts, feedback, or ideas? |
Beta Was this translation helpful? Give feedback.
-
I don't think we have a way to add custom scalar types by the application, or do we, @phillip-kruger? |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, are there any news on this? I'm not that knowledgeable about this code base but maybe with some guidance I can work on that (?) |
Beta Was this translation helpful? Give feedback.
-
Hello, is there any update on this? https://smallrye.io/smallrye-graphql/2.5.0/typesafe-client-custom-scalars/ I will present a bit more context here. I implemented a coercing to translate the custom scalar. When I am serializing the value as a String it works fine. But as I said, I want to have type safety here and serialize the value as a BigDecimal. Another issue I have with the definition of method signatures given in the link above: I have to implement a toString method that handles serialization. I don't think this should be handled in that way. I think the serialization and deserialization must be handled differently. If you think one step further, and imagine using a third party library record as a custom scalar. How should you implement the serialization and register it? Also the methods "of", "valueOf" and "parse" are not defined in an interface somewhere. It feels like some reflection magic is happening, but I actually want to properly define the serialization. I would be grateful for any help or suggestions! |
Beta Was this translation helpful? Give feedback.
-
I've created a work-in-progress sketch of how we could integrate extended scalars: See Basically, how it would work is that the application would add just a configuration value, like
and that would import the UUID scalar from the extended-scalars library. Only UUID is implemented now, but we could add some more. It would be nicer to be able to register the scalar through some kind of SPI, but the problem is that Quarkus builds the schema during build time, and we want to avoid loading and calling application classes during build time, hence I came up with this other solution. Would this make sense? |
Beta Was this translation helpful? Give feedback.
-
Hey there! I am implementing a GraphQL server, using SmallRye GraphQL version 2.1.3.
I'm experiencing some problems with the UUID scalar, and in general with Custom Scalars (not clear to me how to declare new ones and see them appear under
https://<host>:<port>/graphql/schema.graphql
).Focusing on UUID, at the moment it doesn't seem possible to declare a field of a GraphQL Type as a UUID field. Indeed, this is always handled as a String, and shown as such on the autogenerated schema, as well as on the playground. This might not be an insurmountable problem, except that ideally the service should work in a federated context (therefore using GraphQL Federation), where keeping the same type of field shared between several subgraphs is crucial (link).
I tried to have a look at the source code, and I didn't understand exactly whether it is an intended choice to handle a UUID field as a String. Below is an example:
I've also tried playing with
@AdaptWith
and@AdaptToScalar
, but no way to achieve that for different reasons.Do you have any thoughts/considerations about this? Should this not be the 'desirable' behavior, I could try opening PR.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions