graphql-java-tools icon indicating copy to clipboard operation
graphql-java-tools copied to clipboard

Usage of Input in List does not count as usage

Open nidomiro opened this issue 6 years ago • 2 comments

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

nidomiro avatar Apr 14 '19 15:04 nidomiro

Same issue, tools v. 5.6.1. @nidomiro , have you found a solution?

kemsar avatar Oct 23 '19 16:10 kemsar

Unfortunately not. My workaround is to create a dummy-Query and reference the type here explicitly.

nidomiro avatar Nov 01 '19 17:11 nidomiro