Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: Limit built-in scalars to the ones defined by the spec #158

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

stuebingerb
Copy link
Owner

@stuebingerb stuebingerb commented Jan 12, 2025

Partially resolves #83 by splitting up the current BuiltInScalars into two:

  • The actual built-in scalars as defined by the spec
  • Some extended scalars supported by KGraphQL

BREAKING CHANGE: Those extended scalars are no longer automatically added to a schema but must be manually included using extendedScalars() if needed.

BREAKING CHANGE: Shorts are returned as numeric value, no longer as string.

@stuebingerb stuebingerb force-pushed the fix/fix-sdl-for-scalars branch 2 times, most recently from 349f10f to 2331c76 Compare January 12, 2025 12:41
@@ -140,6 +141,12 @@ class SchemaBuilder internal constructor() {
booleanScalar(T::class, block)
}

fun extendedScalars() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there tests specifying that with not invoking this, the additional scalars are not present?

Copy link
Owner Author

@stuebingerb stuebingerb Jan 13, 2025

Choose a reason for hiding this comment

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

I've seen all tests fail that I adjusted but it would make sense to have it validated explicitly. Will update but I have found some strange behavior with the implemented coercions that I want to analyze first.

Copy link
Owner Author

Choose a reason for hiding this comment

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

This looks more complicated: #160

But I have at least added some validation

Partially resolves #83 by splitting up the current `BuiltInScalars`
into two:

- The actual built-in scalars as defined by the spec
- Some extended scalars supported by KGraphQL

BREAKING CHANGE: Those extended scalars are no longer automatically
added to a schema but must be manually included using `extendedScalars()`
if needed.

BREAKING CHANGE: Shorts are returned as numeric value, no longer as
string.
@stuebingerb stuebingerb force-pushed the fix/fix-sdl-for-scalars branch from 2331c76 to 5bcffd4 Compare January 13, 2025 12:10

val response = deserialize(schema.executeBlocking("{ int float double string boolean }"))
assertThat(response.extract<Int>("data/int"), equalTo(1))
assertThat(response.extract<Float>("data/float"), equalTo(2.0))
Copy link
Owner Author

Choose a reason for hiding this comment

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

IMHO this should be equalTo(2.0f) but haven't found out why that doesn't work.


val response = deserialize(schema.executeBlocking("{ long short }"))
assertThat(response.extract<Long>("data/long"), equalTo(9223372036854775807L))
assertThat(response.extract<Int>("data/short"), equalTo(2))
Copy link
Owner Author

Choose a reason for hiding this comment

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

IMHO this should be extract<Short> and equalTo(2.toShort()) but haven't found out why that doesn't work. There is also a cast in TestUtils.extract that apparently successfully casts an Int to a Short, which shouldn't be possible. Hopefully that will all become clearer during work on #160.

@stuebingerb stuebingerb merged commit bbbe697 into main Jan 14, 2025
4 checks passed
@stuebingerb stuebingerb deleted the fix/fix-sdl-for-scalars branch January 14, 2025 09:19
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.

Incorrect built-in scalars
2 participants