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

[GraphQL] Custom mutations on collections / return type #2947

Open
lukasluecke opened this issue Jul 23, 2019 · 4 comments
Open

[GraphQL] Custom mutations on collections / return type #2947

lukasluecke opened this issue Jul 23, 2019 · 4 comments

Comments

@lukasluecke
Copy link
Contributor

Similar to collection_query there should be collection_mutation for mutations that operate on multiple Resources, e.g. deleting multiple items in a single request by passing an array of IDs.

@lukasluecke
Copy link
Contributor Author

Another possible solution might be to allow specifying the return type, similar to the way args works with custom types (#2824).

@lukasluecke lukasluecke changed the title [GraphQL] Custom mutations on collections [GraphQL] Custom mutations on collections / return type Jul 23, 2019
@alanpoulain
Copy link
Member

I don't think the second solution is OK for this specific need (but it could be another enhancement) because the used resolver is only for queries, not mutations.
I'm not sure about this feature though. In GraphQL you can do it by using multiple mutations in one request.

@lukasluecke
Copy link
Contributor Author

because the used resolver is only for queries, not mutations.

Could you explain what you mean?

And yes, you can send multiple mutations - but that would require you to dynamically build the mutations in the client side (which might involve a lot of work or be impossible depending on the libraries or client you use) - while having one mutation with an array argument will allow you to use the same mutation with different variables.

Also there will probably be other use cases for a custom return type (e.g. mutations that should just return a single value, like a number or boolean) - just as the args option is an "alternative" to Input Classes, the result option could be an "alternative" to Output Classes?

@brettins
Copy link

So the situation we are wanting to use this for is "claimBooks", where a user claims any books that have been associated with their phone number at a checkout, but they signed up as a user afterwards and gave their phone number.

In this case, we are updating multiple books to have their owner be the user, and would like to return that collection from the mutation. At the moment, this does not seem to be possible.

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

No branches or pull requests

3 participants