Open maximkrouk opened 2 years ago
To encode a response with a different encoder, you can register one the same way you would register one with Vapor. For incoming decoding, Graphiti 1.0.0 adds native support for custom decoders. As mentioned in #15 the underlying Graphiti packages has support for custom encoders. So, in my opinion, writing an additional wrapper around isn't useful enough. Do you think the same functionality could be achieved with the graphiti-1.0.0 branch instead?
Seems like it cannot be achieved with Graphiti, at least my implementation encodes GraphQLResult to a specific Vapor type. The problem is that currently, you can only override the encoder for a specific mediatype globally, I couldn't find another way to override it only for GQL routes.
I couldn't reproduce the behavior in tests, but responses may be encoded in the wrong order because
JSONEncoder
uses aDictionary
under the hood, butGraphQLJSONEncoder
usesOrderedDictionary
and always encodesGraphQLResult
correctly.