Skip to content

Conversation

coleturner
Copy link
Contributor

@coleturner coleturner commented May 12, 2023

Resolves #1522

This change addresses an edge case in InputValueSerializer, where an input object's class may be assignable from a scalar's class. For example, if I register my ZoneId scalar, and my input object is actually a ZoneRegion extends ZoneId, our strict matching will not be able to parse this input object. With this change, the matching of scalars is opened up to allow input objects to match to scalars where the class is assignable.

@srinivasankavitha any concerns about backwards compatibility here? I can only imagine if folks were using typeMapping in ways that aren't intended.

Copy link
Contributor

@srinivasankavitha srinivasankavitha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@@ -81,8 +81,10 @@ class InputValueSerializer(private val scalars: Map<Class<*>, Coercing<*, *>> =
return input
}

if (input::class.java in scalars) {
return scalars.getValue(input::class.java).valueToLiteral(input)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@coleturner coleturner merged commit 2c85ef0 into master May 15, 2023
@coleturner coleturner changed the title fix(InputerValueSerializer): allow scalars to be assignable from class fix(InputValueSerializer): allow scalars to be assignable from class May 15, 2023
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.

bug: Cannot create custom scalar serializing from java.time.ZoneId
2 participants