Issue Description
sanitizeValues() tries to mutate the input settings data, which is visible mostly for customAnnotationsMapping and directiveAnnotationsMapping; if the input data is immutable (e.g. supplied via mapOf() etc.), the result is a not-too-helpful UnsupportedOperationException.
The solution would be for the sanitization method to produce a mutated copy of the whole map instead, and re-assign that copy via mappingConfig.setDirectiveAnnotationsMapping() etc. instead of trying to mutate in place.
A worse solution would be to explicitly require a mutable input parameter (e.g. mutable map) in the affected cases, although this would be a serious code smell IMVHO.
Steps to Reproduce
directiveAnnotationsMapping = mapOf(
"foo" to listOf(
"@bar",
),
)
with Kotlin DSL e.g.
Expected Result
Should work.
Actual Result
UnsupportedOperationException due to attempted entry.setValue() on the map.
Your Environment and Setup
- graphql-java-codegen version: 5.8.0
- Build tool: Gradle 8.4
- Mapping Config: see above
Issue Description
sanitizeValues()tries to mutate the input settings data, which is visible mostly forcustomAnnotationsMappinganddirectiveAnnotationsMapping; if the input data is immutable (e.g. supplied viamapOf()etc.), the result is a not-too-helpfulUnsupportedOperationException.The solution would be for the sanitization method to produce a mutated copy of the whole map instead, and re-assign that copy via
mappingConfig.setDirectiveAnnotationsMapping()etc. instead of trying to mutate in place.A worse solution would be to explicitly require a mutable input parameter (e.g. mutable map) in the affected cases, although this would be a serious code smell IMVHO.
Steps to Reproduce
with Kotlin DSL e.g.
Expected Result
Should work.
Actual Result
UnsupportedOperationExceptiondue to attemptedentry.setValue()on the map.Your Environment and Setup