stuebingerb / KGraphQL

Pure Kotlin GraphQL implementation
MIT License
4 stars 1 forks source link

Invalid input types may cause HTTP 500 errors #59

Closed stuebingerb closed 2 weeks ago

stuebingerb commented 3 weeks ago

With the provided examples/ktor application the following mutation results in an HTTP 500 error:

mutation {
  createUFOSighting(
    input: {
      country: { city: "", comments: "", country: "", state: "" }
      date: "2024-01-01"
      duration: 1.5
      latitude: 1.5
      longitude: 1.5
      shape: ""
    }
  ) {
    id
  }
}

Reason is that the country is in fact defined as a list of countries.

Expected 1: country should be defined as single country Expected 2: The above mutation should result in an appropriate error response

stuebingerb commented 3 weeks ago

Seems like the behavior is related to the list being part of a class, otherwise there is at least an exception (albeit not 100% useful):

mutation{List(value : 23)}

Returns

Invalid argument value '23' for type null

Expected 3: Invalid argument value '23' for type List

stuebingerb commented 3 weeks ago

Further testing also shows some missing string representations, e.g.

Invalid enum FakeEnum value. Expected one of [com.apurebase.kgraphql.schema.structure.EnumValue@da50a0b4, com.apurebase.kgraphql.schema.structure.EnumValue@2e8b019a]