Client Queries fail on any nonNull perameters with coerced null value #1004
-
I've set up the graphql-kotlin client to be generated from file (no introspection, instead I copy from here is the signature of the kotlin function from which the failing parts of the schema is generated fun patient(pID: Int, authContext: GraphQLAuthContext): Patient.Companion.GraphQLPatient the relevant parts of the generated schema the .schema file I'm generating the client from
and the code that I call the client with @Test
internal fun testPatient() {
val patientsQuery = PatientQuery(client.value)
runBlocking {
val variables = PatientQuery.Variables(pID = 20)
val result = patientsQuery.execute(variables)
assert(result.errors.isNullOrEmpty()) { "errors is not null or empty: $result with the following variables: $variables" }
assert(result.data != null)
}
} which consistently throws the following (with my added debugging info from the assert)
And finally here's the graphql-koltin portions of gradle.build file (I'm using "4.0.0-alpha.10") dependencies {
implementation("com.expediagroup:graphql-kotlin-spring-server:${graphQLKotlin.version}")
implementation("com.expediagroup:graphql-kotlin-spring-client:${graphQLKotlin.version}")
} plugins {
id("com.expediagroup.graphql") version "4.0.0-alpha.10"
} val graphqlGenerateTestClient by tasks.getting(com.expediagroup.graphql.plugin.gradle.tasks.GraphQLGenerateClientTask::class) {
clientType.set(com.expediagroup.graphql.plugin.generator.GraphQLClientType.WEBCLIENT)
packageName.set("com.leftindust.mediq")
schemaFileName.set("${project.projectDir}/src/main/resources/schema.graphql")
queryFileDirectory.set("${project.projectDir}/src/main/resources/queries")
} Any help would be appreciated! if this actually unexpected behaviour I'll open up an issue, but I imagine I am just using the library incorrectly and this seems the place to put that. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@MarcusDunn Is there a github project you can link to as a demo? If not can you share the result of printing the server schema to verify what the server is using. |
Beta Was this translation helpful? Give feedback.
-
I fixed the issue by renaming test function: @Test
internal fun `test Patient does not throw`() {
val patientQuery = PatientQuery(client.value)
runBlocking {
val result = patientQuery.execute(
PatientQuery.Variables(
pid = 21953564
)
)
assert(result.errors.isNullOrEmpty()) { "result: $result" }
}
} query query patientQuery($pid: Int!) {
patient(pid: $pid) {
firstName
}
} a small portion of the schema type Query {
patient(pid: Int!): Patient!
} and the generating function signature fun patient(pid: Int, authContext: GraphQLAuthContext): GraphQLPatient |
Beta Was this translation helpful? Give feedback.
I fixed the issue by renaming
pID
, I topid
. I have no idea why that fixed it, my final query and schema were as follows:test function:
query
a small portion of the schema
and the gene…