Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
desiderati opened this issue Feb 28, 2025 · 0 comments
Open

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

desiderati opened this issue Feb 28, 2025 · 0 comments
Assignees
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@desiderati
Copy link

desiderati commented Feb 28, 2025

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 28, 2025
@bclozel bclozel self-assigned this Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants