Add ability to generate nullable fields wrapped to Optional
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 217
- Forks
- 116
- PR merge metrics
- No merged PRs in 30d
Description
In my case I'm using client library to consume GraphQL API.
Server differentiate absents of the field in the query and explicitly passed null value.
I would like to have an ability to generate all nullable fields wrapped to an Optional.
So for the schema
type PersonUpdateInput {
id: Int!
name: String
}
type Mutation {
updatePerson(patient: PersonUpdateInput!): Person!
}
The class will be generated like
class PersonUpdateInput {
int id;
Optional<String> name;
setName(String name){
this.name = Optional.ofNullable(name);
}
}
This allow to explicitly set null value for 'name' field and server consume this value.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named. Start by locating the generator entry point for nullable GraphQL input fields, then use the PersonUpdateInput example to trace how generated Java fields and setters are produced. Done means nullable fields can represent both absence and an explicitly supplied null through Optional.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, java, kotlin
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100