Skip to content

"Expected type <type.name> to be a GraphQLOutputType" error parsing interface with complex type. #86

@jakubkluz

Description

@jakubkluz

Having this simple schema:

schema {
    query: Query
}

type Query {
    animal: Animal
}

interface Animal {
    type: ComplexType
}

type Dog implements Animal {
    type: ComplexType
}

type ComplexType {
    id: String
}

and data classes:

class QueryResolver implements GraphQLQueryResolver {
    Animal animal(){}
}
interface Animal {
    ComplexType type
}
class Dog implements Animal {
    
}
class ComplexType {
    String id
}

This error pop up when building the schema:

Caused by: com.coxautodev.graphql.tools.SchemaError: Expected type 'ComplexType' to be a GraphQLOutputType, 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:248)
	at com.coxautodev.graphql.tools.SchemaParser.determineOutputType(SchemaParser.kt:234)
	at com.coxautodev.graphql.tools.SchemaParser.createField(SchemaParser.kt:206)
	at com.coxautodev.graphql.tools.SchemaParser.access$createField(SchemaParser.kt:48)
	at com.coxautodev.graphql.tools.SchemaParser$createInterfaceObject$$inlined$forEach$lambda$1.apply(SchemaParser.kt:179)
	at com.coxautodev.graphql.tools.SchemaParser$createInterfaceObject$$inlined$forEach$lambda$1.apply(SchemaParser.kt:48)
	at graphql.schema.GraphQLInterfaceType$Builder.field(GraphQLInterfaceType.java:136)
	at com.coxautodev.graphql.tools.SchemaParser.createInterfaceObject(SchemaParser.kt:179)
	at com.coxautodev.graphql.tools.SchemaParser.parseSchemaObjects(SchemaParser.kt:78)
	at com.coxautodev.graphql.tools.SchemaParser.makeExecutableSchema(SchemaParser.kt:103)
	at com.coxautodev.graphql.tools.SchemaParserInterface.should parse interface with complex type(SchemaParserInterface.groovy:40)

It went well when after changing Animal from interface to type in schema.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions