I'm newbie with graphql and spqr. I would like to serialize my dates with personal format. How I can do it?
Asked
Active
Viewed 256 times
0
-
Please read about Spring's `@InitBinder` annotation, it would help you – Dilip Chauhan May 21 '19 at 08:07
1 Answers
0
The best answer I'd offer is: don't! SPQR serializes all temporal scalars as ISO 8601 strings in UTC zone for a reason. It is the most portable format, that any client can easily parse and understand, and any conversion and display logic is better left to the client itself.
If this is for some reason impossible (e.g. backwards compatibility with a legacy client), your best bet is providing your own scalar implementations. In the future there might be a feature to avoid this, but currently you have to implement your own scalars and a TypeMapper
that will map the desired Java types to those scalars. See the existing ScalarMapper
for inspiration. Once you have the mapper, register it via generator.withTypeMappers
.

kaqqao
- 12,984
- 10
- 64
- 118