diff --git a/graphql/boot-graphql-webflux/mvnw b/graphql/boot-graphql-webflux/mvnw old mode 100644 new mode 100755 diff --git a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/config/ApplicationProperties.java b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/config/ApplicationProperties.java index 42d3c85dd..edddb22b4 100644 --- a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/config/ApplicationProperties.java +++ b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/config/ApplicationProperties.java @@ -1,11 +1,6 @@ package com.example.graphql.config; -import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; -@Data @ConfigurationProperties("application") -public class ApplicationProperties { - private String endpointUri; - private String region; -} +public record ApplicationProperties(String endpointUri, String region) {} diff --git a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/config/Initializer.java b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/config/Initializer.java index 7c1f7c7ae..d3531b5c5 100644 --- a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/config/Initializer.java +++ b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/config/Initializer.java @@ -1,19 +1,21 @@ package com.example.graphql.config; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; @Component -@RequiredArgsConstructor -@Slf4j public class Initializer implements CommandLineRunner { - + private static final Logger log = LoggerFactory.getLogger(Initializer.class); private final ApplicationProperties properties; + public Initializer(ApplicationProperties properties) { + this.properties = properties; + } + @Override public void run(String... args) { - log.info("Running Initializer.....@ {}", properties.getEndpointUri()); + log.info("Running Initializer.....@ {}", properties.endpointUri()); } } diff --git a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/controller/CustomerGraphQLController.java b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/controller/CustomerGraphQLController.java index 12e6e1f06..a067fea90 100644 --- a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/controller/CustomerGraphQLController.java +++ b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/controller/CustomerGraphQLController.java @@ -7,7 +7,6 @@ import jakarta.validation.constraints.Positive; import java.util.List; import java.util.Map; -import lombok.RequiredArgsConstructor; import org.springframework.graphql.data.method.annotation.Argument; import org.springframework.graphql.data.method.annotation.BatchMapping; import org.springframework.graphql.data.method.annotation.MutationMapping; @@ -19,11 +18,14 @@ @Controller @Validated -@RequiredArgsConstructor public class CustomerGraphQLController { private final CustomerGraphQLService customerGraphQLService; + public CustomerGraphQLController(CustomerGraphQLService customerGraphQLService) { + this.customerGraphQLService = customerGraphQLService; + } + // @SchemaMapping(typeName = "Query", field = "customers") or @QueryMapping Flux customers() { diff --git a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/dtos/Customer.java b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/dtos/Customer.java index 61c500c12..20e27d1cf 100644 --- a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/dtos/Customer.java +++ b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/dtos/Customer.java @@ -1,6 +1,5 @@ package com.example.graphql.dtos; -import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.annotation.Id; -public record Customer(@JsonProperty("id") @Id Integer id, @JsonProperty("name") String name) {} +public record Customer(@Id Integer id, String name) {} diff --git a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/dtos/Orders.java b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/dtos/Orders.java index 35747be38..2f490d539 100644 --- a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/dtos/Orders.java +++ b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/dtos/Orders.java @@ -1,6 +1,5 @@ package com.example.graphql.dtos; -import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.annotation.Id; -public record Orders(@JsonProperty("id") @Id Integer id, @JsonProperty("customerId") Integer customerId) {} +public record Orders(@Id Integer id, Integer customerId) {} diff --git a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/service/CustomerGraphQLServiceImpl.java b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/service/CustomerGraphQLServiceImpl.java index 2814fc472..0a957e1f5 100644 --- a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/service/CustomerGraphQLServiceImpl.java +++ b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/service/CustomerGraphQLServiceImpl.java @@ -8,19 +8,22 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @Service -@RequiredArgsConstructor public class CustomerGraphQLServiceImpl implements CustomerGraphQLService { private final CustomerRepository customerRepository; private final OrdersRepository ordersRepository; + public CustomerGraphQLServiceImpl(CustomerRepository customerRepository, OrdersRepository ordersRepository) { + this.customerRepository = customerRepository; + this.ordersRepository = ordersRepository; + } + @Override public Flux findAllCustomers() { return this.customerRepository.findAll(); diff --git a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/utils/AppConstants.java b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/utils/AppConstants.java index bed02d820..7d8db36b6 100644 --- a/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/utils/AppConstants.java +++ b/graphql/boot-graphql-webflux/src/main/java/com/example/graphql/utils/AppConstants.java @@ -1,12 +1,13 @@ package com.example.graphql.utils; -import lombok.experimental.UtilityClass; - -@UtilityClass public final class AppConstants { public static final String PROFILE_LOCAL = "local"; public static final String PROFILE_PROD = "prod"; public static final String PROFILE_NOT_PROD = "!" + PROFILE_PROD; public static final String PROFILE_TEST = "test"; public static final String PROFILE_IT = "integration-test"; + + private AppConstants() { + throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); + } }