Skip to content

Generate map defaults for object values on Map-typed scalars - #983

Open
nboisnea wants to merge 1 commit into
Netflix:masterfrom
nboisnea:fix/object-default-on-map-scalar
Open

nboisnea wants to merge 1 commit into
Netflix:masterfrom
nboisnea:fix/object-default-on-map-scalar

Conversation

@nboisnea

@nboisnea nboisnea commented Oct 8, 2026

Copy link
Copy Markdown
  • Object literal default values on input fields typed as a scalar mapped to Map (or Object / Any) now generate a map initializer instead of failing with NoSuchElementException:
    • Java: Collections.emptyMap() for {}, otherwise new LinkedHashMap<K, V>(){{put(...);}}
    • Kotlin: emptyMap() / mapOf("key" to value, ...) (mutableMapOf for MutableMap)
  • Nested object and list values are generated recursively, using the map's value type
  • List defaults now pass the element type to their elements, so lists of maps are supported too ([JSON] = [{}])
  • Object literals on any other non-input type fail with an explicit message (X cannot be created from ObjectValue{...}, expected an input type or a Map), similarly to BigDecimal/Currency/Locale checks
  • Java: string values are now also generated for Object targets, so {name: "x"} doesn't become put("name", null)

Fixes #982

Object literal defaults on input fields whose type is a Map (or Object/Any) now generate a map initializer instead of failing with NoSuchElementException. Other non-input types fail with an explicit message. List defaults now pass the element type, so lists of maps are supported too.

Fixes Netflix#982

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Object literal default value on a custom scalar fails with NoSuchElementException

1 participant