Code generation and field data fetchers #18
-
Hello, I'm yet to try out this new starter for making GraphQL servers. Will it always generate a Java POJO with all the fields listed in the GraphQL type? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
There are multiple relevant answers to this question, let me try to explain the different options. Yes, by default, the generated POJOs contain all fields of the types in the schema. Note that the structure of the POJO is unrelated to how you structure your data fetchers. Let's look at an example:
This would generate two POJOs: Independent of how the Show class looks, you can structure your data fetchers in different ways.
If however you would want to have a separate data fetcher for the actors field, you could still do that.
In the latter case, the However, if you really don't want to have a specific field, there is a |
Beta Was this translation helpful? Give feedback.
-
@paulbakker I wanna try it out with Kotlin but I didn't find gradle configuration to do this? How can implement the Code generation plugin with Kotlin Language? |
Beta Was this translation helpful? Give feedback.
There are multiple relevant answers to this question, let me try to explain the different options.
Yes, by default, the generated POJOs contain all fields of the types in the schema. Note that the structure of the POJO is unrelated to how you structure your data fetchers. Let's look at an example:
This would generate two POJOs:
Show
andActor
.The generated
Show
class has two fields,title
andactors
.Independent of how the Show class looks, you can structure your data fetchers in different ways.
For example you could have a single data fetcher which fully constructs a show…