Skip to content

Interfaces - having multiple interfaces in schema generates errors on startup #45

Closed

Description

@Silvatre

Issue
If schema has multiple interfaces, then the app fails to start.

Reproduction
Given the following example schema and its corresponding java classes:

type Query {
    query1(resource: NamedResourceImpl): [Long!]
    query2(resource: VersionedResourceImpl): [Long!]
}


interface NamedResource {
    name: String!
}

interface VersionedResource {
    version: Int!
}

type NamedResourceImpl implements NamedResource {
    name: String!
}

type VersionedResourceImpl implements VersionedResource {
    version: Int!
}

When the application is starting,

The following exception is being thrown:

Caused by: com.coxautodev.graphql.tools.SchemaClassScannerError: Error creating bimap of type => class
	at com.coxautodev.graphql.tools.SchemaClassScanner.validateAndCreateParser(SchemaClassScanner.kt:141) ~[graphql-java-tools-3.2.1.jar:na]
	at com.coxautodev.graphql.tools.SchemaClassScanner.scanForClasses(SchemaClassScanner.kt:124) ~[graphql-java-tools-3.2.1.jar:na]

Caused by: java.lang.IllegalArgumentException: value already present: null
	at com.google.common.collect.HashBiMap.put(HashBiMap.java:287) ~[guava-21.0.jar:na]
	at com.google.common.collect.HashBiMap.put(HashBiMap.java:262) ~[guava-21.0.jar:na]
	at com.coxautodev.graphql.tools.SchemaClassScanner.validateAndCreateParser(SchemaClassScanner.kt:138) ~[graphql-java-tools-3.2.1.jar:na]
	... 81 common frames omitted

Activity

  1. apottere commented on Jul 27, 2017

    @apottere
    Collaborator

    I think I know what's causing this, and a workaround till I get it fixed might be to create dummy fields that return the interface type.

    Since there are no actual fields that return the interfaces, it doesn't know what class to map them to. It should be filtering them out, and I'll fix that as soon as I can.

  2. added a commit that references this issue on Jul 28, 2017
    1cc289d
  3. added a commit that references this issue on Jul 28, 2017
    72e6389
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions