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

Service becomes null when using private @SchemaMapping #1084

Open
sydneyhenrard opened this issue Nov 8, 2024 · 1 comment
Open

Service becomes null when using private @SchemaMapping #1084

sydneyhenrard opened this issue Nov 8, 2024 · 1 comment
Labels
status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged

Comments

@sydneyhenrard
Copy link

I faced a strange behavior. It might not be a bug, or it's something specific to my application but I figured it could help.

The query has 2 @SchemaMapping one is public and the other is private. No reason just inconsistency on my side. When running the query locally it works fine, but when deployed in dev, the facets part throws a NPE because productService is null. When switching the method from private to public it works.

JDK 21
SB 3.3.4

@Controller
public class ProductGraphQlController {

    private final ProductService productService;

    public ProductGraphQlController(ProductService productService) {
        this.productService = productService;
    }

    @QueryMapping
    public ProductSearch allProductsWithFacets(
        @Argument String tenant,
        ScrollSubrange subrange,
        GraphQLContext graphQLContext
    ) {...}   

    @SchemaMapping(field = "content")
    public Window<Product> content(
        ProductSearch productSearch,
        @ContextValue String tenant,
        @ContextValue ScrollSubrange subrange
    ) {...}   

    @SchemaMapping(field = "facets")
    private List<Facet> facets(
        ProductSearch productSearch,
        @ContextValue String tenant
    ) {...}   
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 8, 2024
@bclozel
Copy link
Member

bclozel commented Nov 8, 2024

I think there is more to this as the behavior you're describing doesn't make sense to me. Can you share a minimal sample application that we can take a look at?

@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants