walmartlabs / lacinia-pedestal

Expose Lacinia GraphQL as Pedestal endpoints
http://lacinia-pedestal.readthedocs.io/en/latest/
Other
200 stars 63 forks source link

Pluggable JSON library? #125

Open orestis opened 2 years ago

orestis commented 2 years ago

I was investigating various JSON parsers in use in our app code, and I realised lacinia-pedestal hard-codes Cheshire in two places: parsing incoming requests (query, vars) and encoding outgoing responses. Obviously I can replace those interceptors with my own version, but since the Cheshire namespaces are still required, they still need to be present in the class path.

(Lacinia core does the same with data.json for the introspection part).

Would it make sense to have a protocol that applications can implement? Or perhaps use some other load-time machinery to load a particular json library? It would be nice to have a single dependency in a codebase.

hlship commented 2 years ago

I'm open to this and, yes, we don't actually use cheshire in production at Walmart so coming up with a pluggable way to replace it would be fine. I suspect a simple protocol for a JSON Driver, and a default implementation that uses Cheshire, but does it in a way (using explicit calls to requiring-resolve) that allows Cheshire to be an optional dependency.