graphql-java-tools
graphql-java-tools copied to clipboard
Usage of Input in List does not count as usage
With a schema like the following I get the error that ReferenceSportsClassInput is not of type GraphQLInputType, but it clearly is.
Debugging into com.coxautodev.graphql.tools.SchemaParser shows, that ReferenceSportsClassInput is listed in scanResult.unusedDefinitions and not in scanResult.definitions .
Referencing ReferenceSportsClassInput in another input directly (not as List) fixes the problem for the list-reference.
Schema:
type Mutation {
createPerson(input: CreatePersonInput!): Person!
}
type Person {
id: ID!
firstName: String!
name: String!
displayName: String!
birthDate: String!
emailAddress: String!
phoneNumber: String
postalAddress: PostalAddress!
sportsClasses(page:Int! = 0, pageSize: Int! = 50): SportsClassPage!
}
input CreatePersonInput {
firstName: String!
name: String!
displayName: String!
birthDate: String!
emailAddress: String!
phoneNumber: String
postalAddress: PostalAddressInput!
sportsClasses: [ReferenceSportsClassInput!]
}
input ReferenceSportsClassInput {
id: ID!
}
[...]
Exception:
Caused by: com.coxautodev.graphql.tools.SchemaError: Expected type 'ReferenceSportsClassInput' to be a GraphQLInputType, but it wasn't! Was a type only permitted for object types incorrectly used as an input type, or vice-versa?
at com.coxautodev.graphql.tools.SchemaParser.determineType(SchemaParser.kt:335)
at com.coxautodev.graphql.tools.SchemaParser.determineType(SchemaParser.kt:328)
at com.coxautodev.graphql.tools.SchemaParser.determineType(SchemaParser.kt:327)
at com.coxautodev.graphql.tools.SchemaParser.determineInputType(SchemaParser.kt:323)
Lib-versions: com.graphql-java-kickstart:graphql-spring-boot-starter:5.7.3 com.graphql-java-kickstart:graphql-java-tools:5.5.2
Same issue, tools v. 5.6.1. @nidomiro , have you found a solution?
Unfortunately not. My workaround is to create a dummy-Query and reference the type here explicitly.