Skip to content

SchemaGenerator: improve exception when the wrong type is provided #425

Closed

Description

@andimarek

Currently when you try to build a schema and an InputType is expected you get a ClassCastException.

This should be improved by a better Exception, which tells the user what type to expect.
There should also be a test to verify it.

Example:

type MutationType {
    addCharacter(character: CharacterInput): 
}
# CharacterInput must be an input, but is a type
type CharacterInput {
    firstName: String
    lastName: String
    family: Boolean
}
type MutationResult {
   success: Boolean
}

Java:

 SchemaCompiler schemaCompiler = new SchemaCompiler();
 TypeDefinitionRegistry compiledSchema = schemaCompiler.compile(schemaString);
  SchemaGenerator schemaGenerator = new SchemaGenerator();
 schemaGenerator.makeExecutableSchema(compiledSchema, buildRuntimeWiring());

Code hints:
https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/schema/idl/SchemaGenerator.java#L210

https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/schema/idl/SchemaGenerator.java#L244

Activity

  1. changed the title [-]improve exception when the wrong type is provided[/-] [+]SchemaGenerator: improve exception when the wrong type is provided[/+] on May 12, 2017
  2. dh94 commented on May 12, 2017

    @dh94
    Contributor

    i'll take a crack at it

  3. added this to the 3.0.0 milestone on May 13, 2017
  4. andimarek commented on May 13, 2017

    @andimarek
    MemberAuthor

    done with #429

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions