Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GraphQL Java Class Generator [closed]

I want to dive into graphQL using Java. I want to query an existing graphQL Service. From what I have found so far are ways to generate the graphQL schemafiles either in JSON or IDL from your POJO classes, but not the other way round....? From what I have understood so far, I would have to create the java classes myself that "represent" the objects I would receive from a query. But the service I want to use has tons of endpoints and queries and the need of writing each pojo class myself sounds like I have missed something... I assume there must be a way to generate stubs like I am used to from REST API frameworks using swagger or yaml files? So... how can I generate the pojo classes automagically given only the schemafile? I have read the description of the schema-first approach at graphql-java but they also assume to write the pojo-classes by oneself.

thank you

like image 631
Yves030 Avatar asked Jul 23 '18 09:07

Yves030


1 Answers

You can use a plugin for your build tool to generate POJOs for GraphQL types/inputs/interfaces/enums/etc and interfaces for queries/mutations/subscriptions. All based on your GraphQL schema.

Link to the project: https://github.com/kobylynskyi/graphql-java-codegen

It has the following plugins for your build tool:

  • Maven plugin: https://github.com/kobylynskyi/graphql-java-codegen/tree/master/plugins/maven
  • Gradle plugin: https://github.com/kobylynskyi/graphql-java-codegen/tree/master/plugins/gradle
  • SBT plugin: https://github.com/kobylynskyi/graphql-java-codegen/tree/master/plugins/sbt
like image 124
Bogdan Kobylynskyi Avatar answered Oct 20 '22 10:10

Bogdan Kobylynskyi