graphql-kotlin icon indicating copy to clipboard operation
graphql-kotlin copied to clipboard

GraphQLContext.plus(map: Map<*, Any?>) throws graphql.AssertException for null values

Open agatan opened this issue 1 year ago • 0 comments

Library Version 7.1.4

Describe the bug GraphQLContext.plus(map: Map<*, Any?>) has a signature that suggests it can accept null values, but passing null actually throws an AssertException.

https://github.com/ExpediaGroup/graphql-kotlin/blob/d038e2e4aa8229e53e24c9046aa16c0c1a2378a6/generator/graphql-kotlin-schema-generator/src/main/kotlin/com/expediagroup/graphql/generator/extensions/GraphQLContextExtensions.kt#L65-L66

To Reproduce

GraphQLContext.newContext().build().plus(mapOf("X" to null))

will throw graphql.AssertException: Object required to be not null.

Expected behavior

One of the following should be addressed:

  • Change the signature to prevent null values from being passed. For example, change plus(map: Map<, Any?>) to plus(map: Map<, Any>).
  • Update the implementation to exclude entries where the value is null.

agatan avatar Aug 06 '24 01:08 agatan