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

Remapping root fields from query to mutation with wrap tools #2559

Open
Tracked by #5201 ...
karibertils opened this issue Feb 6, 2021 · 2 comments
Open
Tracked by #5201 ...

Remapping root fields from query to mutation with wrap tools #2559

karibertils opened this issue Feb 6, 2021 · 2 comments
Labels
feature New addition or enhancement to existing solutions

Comments

@karibertils
Copy link

Hello

I am working with schema generated from REST endpoint using swagger-to-graphql. It works fine, but all GET operations are mapped as queries, and POST operations as mutations in the graphql schema. Many of those GET operations do things like remove or update items. And many POST operations do things like search for results.

Working with it in apollo is a bit weird, so I was hoping to be able to remap some of the queries to mutations, and some mutations to queries using @graphql-tools/wrap.

I have looked at the docs and tried various functions but I'm unable find solution to do this in an easy way. Is this supported, or is it possible to add support for this use case ?

@gmac
Copy link
Contributor

gmac commented Feb 20, 2021

@karibertils – sounds like you should just throw away swagger-to-graphql and build your own GraphQL schema with resolvers that wrap REST methods. While it's not auto-magical, it's going to server you way better in the long run than trying to normalize an auto-magical solution using hacks. Otherwise, check out the ExpandPath and HoistField transforms, which do something along the lines of what you're talking about. Still, using those tools to normalize an automated schema just strikes me as a bad idea with nuances compounding atop of nuances.

@yaacovCR
Copy link
Collaborator

yaacovCR commented Apr 7, 2021

Agree. We should have transform to change root field type, though, seems useful, might break if root types are ever nested, have to think about that more

@ardatan ardatan added the feature New addition or enhancement to existing solutions label Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New addition or enhancement to existing solutions
Projects
None yet
Development

No branches or pull requests

4 participants