DefaultValue Code Generation for InputObject When DefaultValue is given from Schema #2997
Labels
codegen
Issues related to or arising from code generation
enhancement
Issues outlining new things we want to do or things that will make our lives as devs easier
good first issue
Issues that are suitable for first-time contributors.
planned-next
Slated to be included in the next release
Milestone
Question
This is neither a bug or feature request but rather a small question/suggestion. 🙂
Backend team added a new field for an input object. In the schema, it is shown as below.
In this case, Apollo Code Gen doesn't set any default value. Looking at the test code, looks like it's an intended behavior.
https://github.com/apollographql/apollo-ios/blob/1.1.3/Tests/ApolloCodegenTests/CodeGeneration/Templates/InputObjectTemplateTests.swift#L466
It's not a big deal. We can just manually set the field when we call this InputObject. eg.
nullableWithDefault = nil
But the thing is, for this incident, IOS was the only platform having a build break after fetching GraphQL schema.
Web and Android, looks like they are setting the default value as null in this case and had no issue.
If field is Optional(Nullable) and defaultValue is given in the schema, they ignore the given defaultValue in the schema and defaults it to null.
Wouldn't it be better if we change the expected behavior as below? 🤔 Just for a consistency across platforms.
The text was updated successfully, but these errors were encountered: