Skip to content

Error while inspecting properties without read method for a type #1139

@desiderati

Description

@desiderati

Version: Spring GraphQL 1.3.1

Let's suppose you have defined a type called TestObject:

type TestObject {
   id: ID!
   name: String
}

And for some reason, you mistyped the name property or forgot to define a getter method for name, which is private. The Spring GraphQL Framework will generate the following error if property spring.graphql.schema.inspection.enabled: true:

Caused by: java.lang.IllegalArgumentException: Method must not be null
    at org.springframework.util.Assert.notNull(Assert.java:172)
    at org.springframework.core.ResolvableType.forMethodReturnType(ResolvableType.java:1272)
    at org.springframework.graphql.execution.SchemaMappingInspector.checkFieldsContainer(SchemaMappingInspector.java:173)
    at org.springframework.graphql.execution.SchemaMappingInspector.checkField(SchemaMappingInspector.java:235)

And this error does not show much about the problem. It would be nice if we instead of calling:

line: 173 > checkField(fieldContainer, field, ResolvableType.forMethodReturnType(descriptor.getReadMethod()));

We could call a function that translates this IllegalArgumentException into a more friendly error message, like: "Type: TestObject, property: name does not have a reader method defined!"

Thanks guys.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues related to config and core supportstatus: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions