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

False positives in Schema inspection when using Lists in CompletableFuture #674

Closed
JamesPeters98 opened this issue Apr 24, 2023 · 3 comments
Assignees
Labels
in: core Issues related to config and core support type: bug A general bug
Milestone

Comments

@JamesPeters98
Copy link

I just got around to testing the new schema inspection #386 when upgrading to Spring Boot 3.1 RC1. I seem to be getting false positives for unmapped fields that have a java field.

I think it happens when the controller method is a CompletableFuture of a List of the object:

@Controller
public class ExampleQueryController {
  @QueryMapping
  public CompletableFuture<List<ExampleObject>> exampleObject(DataFetchingEnvironment env) {
    return CompletableFuture.completedFuture(List.of(new ExampleObject(1, "name")));
  }

}

GraphQL schema:

type ExampleObject {
  name: String,
  id: Int
}

type Query {
  exampleObject: [ExampleObject]
}

Object class:

public class ExampleObject {

  public String name;
  public int id;

  public ExampleObject(int id, String name) {
    this.id = id;
    this.name = name;
  }

  public Integer getId() {
    return id;
  }

  public String getName() {
    return name;
  }

}

This results in the schema inspection giving a false positive that name and id aren't mapped for ExampleObject.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 24, 2023
@bclozel bclozel self-assigned this Apr 24, 2023
@bclozel bclozel added type: bug A general bug in: core Issues related to config and core support and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 24, 2023
@bclozel bclozel added this to the 1.2.0 milestone Apr 24, 2023
@rstoyanchev rstoyanchev assigned rstoyanchev and unassigned bclozel Apr 25, 2023
rstoyanchev added a commit that referenced this issue Apr 26, 2023
Normally a multivalue Publisher is collected to a List, so we can treat
it as a match for a List field. For subscriptions, however, such a
Publisher is left as an infinite stream, and we should not treat as a
match for a List, but rather expect it to be a stream of List items.

Discovered while working on gh-674, which is closely related.
@rstoyanchev
Copy link
Contributor

@JamesPeters98, this should now be fixed. Please, take another look and let us know if you have further feedback. Also, note that in the latest version of this, the inspection does not run automatically. You need to enable it in GraphQlSource.Builder. The reference docs have been updated.

@JamesPeters98
Copy link
Author

@rstoyanchev Thanks, can confirm this is working for me now 👍

@rstoyanchev
Copy link
Contributor

Good to hear, and thanks for giving it a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues related to config and core support type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants