Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/graphql/schema/idl/SchemaGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private <T extends GraphQLOutputType> T buildOutputType(BuildContext buildCtx, T
outputType = buildScalar(buildCtx, (ScalarTypeDefinition) typeDefinition);
} else {
// typeDefinition is not a valid output type
throw new NotAnOutputTypeError(typeDefinition);
throw new NotAnOutputTypeError(rawType, typeDefinition);
}

buildCtx.put(outputType);
Expand Down Expand Up @@ -340,7 +340,7 @@ private GraphQLInputType buildInputType(BuildContext buildCtx, Type rawType) {
inputType = buildScalar(buildCtx, (ScalarTypeDefinition) typeDefinition);
} else {
// typeDefinition is not a valid InputType
throw new NotAnInputTypeError(typeDefinition);
throw new NotAnInputTypeError(rawType, typeDefinition);
}

buildCtx.put(inputType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package graphql.schema.idl.errors;

import graphql.language.Type;
import graphql.language.TypeDefinition;

import static java.lang.String.format;

public class NotAnInputTypeError extends BaseError {

public NotAnInputTypeError(TypeDefinition typeDefinition) {
super(typeDefinition, format("expected InputType, but found %s type %s", typeDefinition.getName(), lineCol(typeDefinition)));
public NotAnInputTypeError(Type rawType, TypeDefinition typeDefinition) {
super(rawType, format("The type '%s' %s is not an input type, but was used as an input type %s", typeDefinition.getName(), lineCol(typeDefinition), lineCol(rawType)));
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package graphql.schema.idl.errors;

import graphql.language.Type;
import graphql.language.TypeDefinition;

import static java.lang.String.format;

public class NotAnOutputTypeError extends BaseError {

public NotAnOutputTypeError(TypeDefinition typeDefinition) {
super(typeDefinition, format("expected OutputType, but found %s type %s", typeDefinition.getName(), lineCol(typeDefinition)));
public NotAnOutputTypeError(Type rawType, TypeDefinition typeDefinition) {
super(rawType, format("The type '%s' %s is not an output type, but was used to declare the output type of a field %s", typeDefinition.getName(), lineCol(typeDefinition), lineCol(rawType)));
}
}
4 changes: 2 additions & 2 deletions src/test/groovy/graphql/schema/idl/SchemaGeneratorTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ class SchemaGeneratorTest extends Specification {

then:
def err = thrown(NotAnInputTypeError.class)
err.message == "expected InputType, but found CharacterInput type [@11:13]"
err.message == "The type 'CharacterInput' [@11:13] is not an input type, but was used as an input type [@7:42]"
}

def "InputType used as type should throw appropriate error #425"() {
Expand All @@ -659,7 +659,7 @@ class SchemaGeneratorTest extends Specification {

then:
def err = thrown(NotAnOutputTypeError.class)
err.message == "expected OutputType, but found CharacterInput type [@11:13]"
err.message == "The type 'CharacterInput' [@11:13] is not an output type, but was used to declare the output type of a field [@7:32]"
}

def "schema with subscription"() {
Expand Down