Skip to content
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

ClassCastException when walking over input types that have GraphQLTypeReferences #99

Open
edudar-chwy opened this issue Oct 29, 2024 · 1 comment

Comments

@edudar-chwy
Copy link

Describe the bug

java.lang.ClassCastException: class graphql.schema.GraphQLTypeReference cannot be cast to class graphql.schema.GraphQLUnmodifiedType (graphql.schema.GraphQLTypeReference and graphql.schema.GraphQLUnmodifiedType are in unnamed module of loader 'app')
  at graphql.schema.GraphQLTypeUtil.unwrapAll(GraphQLTypeUtil.java:194)
  at graphql.validation.util.DirectivesAndTypeWalker.walkInputType(DirectivesAndTypeWalker.java:23)
  at graphql.validation.util.DirectivesAndTypeWalker.isSuitable(DirectivesAndTypeWalker.java:19)

To Reproduce
I have an enum type that is used as non-null input

enum SlotType {
    AVAILABLE, UNAVAILABLE
}

type Employee {
  schedule(type: SlotType!): [Slot!]!
}

DirectivesAndTypeWalker uses GraphQLTypeUtil.unwrapAll(inputType) since #34 but unwrapAll specifically says that it does not support GraphQLTypeReference:

Unwraps all layers of the type or just returns the type again if it's not a wrapped type NOTE: This method does not support GraphQLTypeReference as input and will lead to a ClassCastException

and SlotType turns out to be one:

type = {GraphQLNonNull@17904} "SlotType!"
 originalWrappedType = {GraphQLTypeReference@17955} "GraphQLTypeReference{name='SlotType'}"
  name = "SlotType"
 replacedWrappedType = null
@dondonz
Copy link
Member

dondonz commented Nov 24, 2024

Hello, to help me understand the issue can you please provide a minimal test case as a pull request or reproduction of the bug in a repo? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants