Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom encoders support for router #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maximkrouk
Copy link
Contributor

I couldn't reproduce the behavior in tests, but responses may be encoded in the wrong order because JSONEncoder uses a Dictionary under the hood, but GraphQLJSONEncoder uses OrderedDictionary and always encodes GraphQLResult correctly.

Btw the implementation requires a bit higher version of GraphQL than was specified in Package.resolved

@alexsteinerde
Copy link
Owner

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?

@maximkrouk
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants