Skip to content

Service becomes null when using private @SchemaMapping #1084

@sydneyhenrard

Description

@sydneyhenrard

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
    ) {...}   
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions