leangen / graphql-spqr

Build a GraphQL service in seconds
Apache License 2.0
1.09k stars 179 forks source link

Mark the gson-java8-datatype dependency as optional #493

Open Balf opened 1 month ago

Balf commented 1 month ago

Since the Gson dependency itself is marked as optional we should also mark this library as optional.

kaqqao commented 1 month ago

It used to be like this, but... people would just add Gson and it would work for a while until they'd use a "wrong" type and things would blow up... So I intentionally left the extra data types as "mandatory" hoping an astute developer would override that manually if they're bothered. With that said... Perhaps you're right. Maybe it's time to rethink that decision as most people seem to use Jackson anyway (due to it being the default in Spring as well). I'll give it a think.

Balf commented 1 month ago

I see where you're coming from, but I would still make it optional. We should however make an explicit mention that this library is required when using Gson rather than Jackson. On that note: Is it enough to add the Gson library to a project to use Gson over Jackson, or is additional configuration required?

kaqqao commented 1 month ago

SPQR first checks for Jackson on the classpath and prefers that if available. If not, it checks for Gson, and uses that. So additional config is only needed if both libraries are available but Gson is preferred:

generator.withValueMapperFactory(new GsonValueMapperFactory())