Developer Jahia 8.2

How to create a GraphQL mutation?

Question

How to create a GraphQL mutation? I try to create one by using GraphQl-java.annotations.
In which file do I have to write this: 

GraphQLSchema schema = AnnotationsSchemaCreator.newAnnotationsSchema()
.mutation(Mutation.class) // to create your mutation object
.build();

 

Answer

This code should not be necessary to create a new GraphQL mutation. You need to implement a class implementing DXGraphQLExtensionsProvider, which will return a list of types to add to the schemas. The types are generated from plain Java classes annotated with graphql-java-annotations (cf. this documentation).

Here are also some examples of source code: