Distelli / graphql-apigen

Generate Java APIs with GraphQL Schemas
Apache License 2.0
66 stars 20 forks source link

Multiple mutations #27

Open dberna2 opened 6 years ago

dberna2 commented 6 years ago

@brimworks Seeing the example of the class GraphQLServlet see that it is has a queryRoot and a mutation such as MutatePosts, but for example, if you need have many mutations such as MutatePosts and "MutateAuthor", I see that it does not support it, is there any way to implement various mutations at the same time?

advance thanks and excellent help your contribution 👍

brimworks commented 6 years ago

Graphql always requires a single root for all queries and a single root for all mutations.

https://graphql.org/learn/schema/#the-query-and-mutation-types

Perhaps my example is misleading since it is named MutatePosts? Feel free to issue a PR if you want to change the documentation.

Thanks, -Brian

dberna2 commented 5 years ago

Hello again Brian,

Again I'm doing graphql and I still like the functionality that has been implemented, but I have a doubt and I hope you can help me. I have tried to return custom errors, but these are not shown in the response json. The maximum I have achieved is "Internal Server Error (s) while executing query". Is there any way to handle errors with your library?

This is my project if you want to see that I am always willing to improve.

https://github.com/dberna2/graphql-example-apigen

Thank you.

brimworks commented 5 years ago

@dberna2 do you have an example of your attempt at a custom error? Did you try following the instructions here?

https://www.howtographql.com/graphql-java/7-error-handling/

In particular the bit about defining the ExecutionStrategy#handleDataFetchingException method? Note that graphql-apigen simply generates POJO interfaces that make it easy to use graphql-java, so anything defined in graphql-java should work.