0

I'm newbie with graphql and spqr. I would like to serialize my dates with personal format. How I can do it?

sanyassh
  • 8,100
  • 13
  • 36
  • 70
atoua
  • 31
  • 2
  • 10

1 Answers1

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