Skip to content

GraphQlTester: Type inference issues with Kotlin #112

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

Closed
koenpunt opened this issue Aug 19, 2021 · 3 comments
Closed

GraphQlTester: Type inference issues with Kotlin #112

koenpunt opened this issue Aug 19, 2021 · 3 comments
Labels
for: external-project Needs a change in external project

Comments

@koenpunt
Copy link
Contributor

Similar to the type inference issues that were present with the WebTestClient.BodySpec, there are now also issues here with the GraphQlTester.EntitySpec.

So for example, the following code will not compile;

graphQlTester
  .query(query)
  .execute()
  .path("merchants.edges[0].node.id")
  .entity(String::class.java)
  .isEqualTo<String>(id)

It will instead result it the following error:

Type argument is not within its bounds.
Expected: Nothing!
Found: String!

Changing String to Nothing satisfies the compiler, but errors out at runtime with a KotlinNothingValueException.

graphQlTester
  .query(query)
  .execute()
  .path("merchants.edges[0].node.id")
  .entity(String::class.java)
  .isEqualTo<Nothing>(id)

The expected/preferred kotlin api would be something like:

graphQlTester
  .query(query)
  .execute()
  .path("merchants.edges[0].node.id")
  .entity<String>()
  .isEqualTo(id)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 19, 2021
@jisensee
Copy link

Running into the same issue, didn't find a way to make this work either.
FWIW, one can use the get method on the EntitySpec to obtain the result and do manual assertions as a workaround.

@sdeleuze
Copy link

sdeleuze commented Sep 8, 2021

Fixed on Kotlin side, see this blog post for more details. This is available via a flag in Kotlin 1.5.30 and by default in the upcoming Kotlin 1.6 release.

@rstoyanchev rstoyanchev added for: external-project Needs a change in external project and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 8, 2021
@rstoyanchev
Copy link
Contributor

Closing this in light of that. Thanks @sdeleuze for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project Needs a change in external project
Projects
None yet
Development

No branches or pull requests

5 participants