diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 732d35fe0..97b06373b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,11 +3,11 @@ name: CI on: workflow_dispatch: push: - branches: [ "master" ] + branches: [ "0.5.x" ] paths-ignore: - '**/README.md' pull_request: - branches: [ "master" ] + branches: [ "0.5.x" ] paths-ignore: - '**/README.md' diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ce9f777a..b90faf3da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,26 @@ # Change Log -## 0.5.5-SNAPSHOT +## 0.5.6-SNAPSHOT +* Fix incorrect query intermittent results due to result list proxies (#379) [ee57b69](https://github.com/introproventures/graphql-jpa-query/commit/ee57b696b9ea699ba700cf08f7dba93fb1e1b8c8) +* chore(deps): bump evo-inflector from 1.2.2 to 1.3 (#346) [f7fbd31](https://github.com/introproventures/graphql-jpa-query/commit/f7fbd31920fe4c2ac149dad6a716ae1834d74199) +* fix: update release.yml dependencies emojii [d0afde4](https://github.com/introproventures/graphql-jpa-query/commit/d0afde4f955e2cb944d8334afb5c655a76194737) +* chore(deps): bump maven-gpg-plugin from 1.4 to 3.0.1 (#335) [56e4caa](https://github.com/introproventures/graphql-jpa-query/commit/56e4caa08d56d0a3b3c67ddda435679b5a834de2) +* Bump maven-assembly-plugin from 2.3 to 3.4.2 (#329) [334c6b3](https://github.com/introproventures/graphql-jpa-query/commit/334c6b3545c80209ef76e748b9f825975bea9b52) +* Bump maven-surefire-plugin from 2.12 to 3.0.0-M7 (#326) [11fab40](https://github.com/introproventures/graphql-jpa-query/commit/11fab40a9d656fcca1bda50f558280053c9c346f) +* Bump maven-javadoc-plugin from 3.1.0 to 3.4.1 (#330) [692455b](https://github.com/introproventures/graphql-jpa-query/commit/692455beff2848191b519db4f5bc680b8b36d42d) +* Bump maven-dependency-plugin from 2.10 to 3.4.0 (#323) [9096df4](https://github.com/introproventures/graphql-jpa-query/commit/9096df443570ac6e960bc48d47f6b592ca58f7d2) +* Bump maven-compiler-plugin from 3.8.0 to 3.10.1 (#327) [e02fc14](https://github.com/introproventures/graphql-jpa-query/commit/e02fc14c6d0976d9f55246041735fe5c823236ab) +* chore(deps): bump nexus-staging-maven-plugin from 1.6.7 to 1.6.13 (#334) [acf663b](https://github.com/introproventures/graphql-jpa-query/commit/acf663b72cdaa7bf678cdda8f07c80a4f366ef32) +* Bump maven-release-plugin from 2.5.1 to 2.5.3 (#328) [eea64e3](https://github.com/introproventures/graphql-jpa-query/commit/eea64e3a63761fea429a7aaafb2a6ed0b2452e9a) +* Bump jacoco-maven-plugin from 0.8.7 to 0.8.8 (#324) [e912091](https://github.com/introproventures/graphql-jpa-query/commit/e912091aebb02a559404576d822531052620b7c8) +* Bump maven-jar-plugin from 2.4 to 3.3.0 (#322) [d906b4f](https://github.com/introproventures/graphql-jpa-query/commit/d906b4f10a83aff9eda84dacea1418c64de21946) +* Update spring-boot-dependencies from 2.7.6 to 2.7.7 (#332) [858b63b](https://github.com/introproventures/graphql-jpa-query/commit/858b63b10d681a89a2595921401c4263ee439d4b) +* fix: update .github/release.yml titles with emoji [0f812a0](https://github.com/introproventures/graphql-jpa-query/commit/0f812a001aff50d7d8974545572bcdeb9a84dba6) +* fix: move release.yml to .github folder [0fa3acd](https://github.com/introproventures/graphql-jpa-query/commit/0fa3acd97f943478c6f398bf8e8154e989376f0f) +* fix: add github release notes changelog template [fdffe2d](https://github.com/introproventures/graphql-jpa-query/commit/fdffe2d2797f7a6e201b330acfe7cd145e0a7db8) +* chore: add Github dependabot [d6b5b86](https://github.com/introproventures/graphql-jpa-query/commit/d6b5b863fcaaa8f1502bc3d9fc084bdca6895677) +* Update issue templates (#321) [4d4b8e9](https://github.com/introproventures/graphql-jpa-query/commit/4d4b8e9d4fa067a5e19056544cd211e968680a16) +* fix: add support for jdk 17 build (#320) [9539a7e](https://github.com/introproventures/graphql-jpa-query/commit/9539a7e5f9f905254dc5b5412a89c1d3d668f282) * fix: add spring-graphql to graphq-jpa-query autoconfigure module (#315) [9809aef](https://github.com/introproventures/graphql-jpa-query/commit/9809aef503255b11852723c8e20aa7018adcf7fe) * fix: update spring-boot-dependencies to 2.7.6 (#319) [e7dbbce](https://github.com/introproventures/graphql-jpa-query/commit/e7dbbcefb3748e11a7665828e436f1697f4a96f1) * feat: add scalar builder method to graphql query schema builder (#318) [56be363](https://github.com/introproventures/graphql-jpa-query/commit/56be363e6f9b78c7b993cc933858ff0a2742e530) diff --git a/graphql-jpa-query-annotations/pom.xml b/graphql-jpa-query-annotations/pom.xml index 39f200f34..b31ba08c5 100644 --- a/graphql-jpa-query-annotations/pom.xml +++ b/graphql-jpa-query-annotations/pom.xml @@ -6,7 +6,7 @@ com.introproventures graphql-jpa-query-dependencies - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-dependencies diff --git a/graphql-jpa-query-autoconfigure/pom.xml b/graphql-jpa-query-autoconfigure/pom.xml index 556a80a9c..41ca71ad6 100644 --- a/graphql-jpa-query-autoconfigure/pom.xml +++ b/graphql-jpa-query-autoconfigure/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build graphql-jpa-query-autoconfigure @@ -32,6 +32,10 @@ org.springframework.boot spring-boot-autoconfigure + + org.springframework + spring-orm + javax.validation validation-api diff --git a/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLJpaQueryGraphQlExecutionAutoConfiguration.java b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLJpaQueryGraphQlExecutionAutoConfiguration.java index 9a346518d..8838bd65c 100644 --- a/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLJpaQueryGraphQlExecutionAutoConfiguration.java +++ b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLJpaQueryGraphQlExecutionAutoConfiguration.java @@ -1,9 +1,6 @@ package com.introproventures.graphql.jpa.query.autoconfigure; import graphql.GraphQL; -import org.dataloader.DataLoaderOptions; -import org.dataloader.MappedBatchLoaderWithContext; -import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -13,9 +10,6 @@ import org.springframework.graphql.ExecutionGraphQlService; import org.springframework.graphql.execution.BatchLoaderRegistry; import org.springframework.graphql.execution.GraphQlSource; -import reactor.core.publisher.Mono; - -import static com.introproventures.graphql.jpa.query.schema.impl.BatchLoaderRegistry.newDataLoaderRegistry; @AutoConfiguration(after = GraphQlAutoConfiguration.class) @ConditionalOnClass({GraphQL.class, GraphQlSource.class}) @@ -35,20 +29,4 @@ ExecutionGraphQlService executionGraphQlService(ListableBeanFactory beanFactory, return new GraphQlAutoConfiguration(beanFactory).executionGraphQlService(graphQlSource, batchLoaderRegistry); } - - @Bean - InitializingBean batchLoaderRegistryConfigurer(BatchLoaderRegistry batchLoaderRegistry) { - return () -> { - DataLoaderOptions options = DataLoaderOptions.newOptions() - .setCachingEnabled(false); - newDataLoaderRegistry(options) - .getDataLoadersMap() - .entrySet() - .stream() - .forEach(entry -> batchLoaderRegistry.forName(entry.getKey()) - .withOptions(options) - .registerMappedBatchLoader((keys, env) -> - Mono.fromCompletionStage(((MappedBatchLoaderWithContext) entry.getValue()).load(keys, env)))); - }; - } } diff --git a/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaBuilderAutoConfiguration.java b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaBuilderAutoConfiguration.java index 6e405afcd..64529a90a 100644 --- a/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaBuilderAutoConfiguration.java +++ b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaBuilderAutoConfiguration.java @@ -1,10 +1,11 @@ package com.introproventures.graphql.jpa.query.autoconfigure; -import javax.persistence.EntityManagerFactory; import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder; import com.introproventures.graphql.jpa.query.schema.RestrictedKeysProvider; import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder; import graphql.GraphQL; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -13,6 +14,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.context.annotation.Bean; +import org.springframework.orm.jpa.SharedEntityManagerCreator; @AutoConfiguration( before = {GraphQLSchemaAutoConfiguration.class, GraphQLJpaQueryGraphQlSourceAutoConfiguration.class}, @@ -28,7 +30,8 @@ public class GraphQLSchemaBuilderAutoConfiguration { GraphQLJpaSchemaBuilder defaultGraphQLJpaSchemaBuilder(EntityManagerFactory entityManagerFactory, GraphQLJpaQueryProperties properties, ObjectProvider restrictedKeysProvider) { - GraphQLJpaSchemaBuilder builder = new GraphQLJpaSchemaBuilder(entityManagerFactory.createEntityManager()); + EntityManager entityManager = SharedEntityManagerCreator.createSharedEntityManager(entityManagerFactory); + GraphQLJpaSchemaBuilder builder = new GraphQLJpaSchemaBuilder(entityManager); builder.name(properties.getName()) .description(properties.getDescription()) diff --git a/graphql-jpa-query-autoconfigure/src/test/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfigurationTest.java b/graphql-jpa-query-autoconfigure/src/test/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfigurationTest.java index 4efcee2a2..5a55c74a9 100644 --- a/graphql-jpa-query-autoconfigure/src/test/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfigurationTest.java +++ b/graphql-jpa-query-autoconfigure/src/test/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfigurationTest.java @@ -1,17 +1,15 @@ package com.introproventures.graphql.jpa.query.autoconfigure; -import java.io.File; -import java.io.IOException; -import java.time.Duration; -import java.time.Instant; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; +import static graphql.annotations.AnnotationsSchemaCreator.newAnnotationsSchema; +import static graphql.schema.FieldCoordinates.coordinates; +import static graphql.schema.GraphQLCodeRegistry.newCodeRegistry; +import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition; +import static graphql.schema.GraphQLObjectType.newObject; +import static graphql.schema.GraphQLSchema.newSchema; +import static graphql.schema.idl.RuntimeWiring.newRuntimeWiring; +import static java.util.Collections.emptyMap; +import static org.assertj.core.api.Assertions.assertThat; + import com.introproventures.graphql.jpa.query.autoconfigure.support.AdditionalGraphQLType; import com.introproventures.graphql.jpa.query.autoconfigure.support.MutationRoot; import com.introproventures.graphql.jpa.query.autoconfigure.support.QueryRoot; @@ -41,6 +39,18 @@ import graphql.schema.idl.SchemaGenerator; import graphql.schema.idl.SchemaParser; import graphql.schema.idl.TypeDefinitionRegistry; +import java.io.File; +import java.io.IOException; +import java.time.Duration; +import java.time.Instant; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.junit.Test; import org.junit.runner.RunWith; import org.reactivestreams.Publisher; @@ -58,16 +68,6 @@ import reactor.core.publisher.Flux; import reactor.test.StepVerifier; -import static graphql.annotations.AnnotationsSchemaCreator.newAnnotationsSchema; -import static graphql.schema.FieldCoordinates.coordinates; -import static graphql.schema.GraphQLCodeRegistry.newCodeRegistry; -import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition; -import static graphql.schema.GraphQLObjectType.newObject; -import static graphql.schema.GraphQLSchema.newSchema; -import static graphql.schema.idl.RuntimeWiring.newRuntimeWiring; -import static java.util.Collections.emptyMap; -import static org.assertj.core.api.Assertions.assertThat; - @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment=WebEnvironment.NONE) public class GraphQLSchemaAutoConfigurationTest { @@ -77,11 +77,11 @@ public class GraphQLSchemaAutoConfigurationTest { @Autowired private GraphQLJpaQueryProperties graphQLJpaQueryProperties; - + @SpringBootApplication @EnableGraphQLJpaQuerySchema(basePackageClasses = TestEntity.class) static class Application { - + @Configuration static class GraphQLAnnotationsSchemaConfigurer implements GraphQLSchemaConfigurer { @Autowired(required = false) @@ -383,6 +383,4 @@ public void defaultConfigurationProperties() { assertThat(graphQLJpaQueryProperties.isUseDistinctParameter()).isFalse(); assertThat(graphQLJpaQueryProperties.isToManyDefaultOptional()).isTrue(); } - - } diff --git a/graphql-jpa-query-boot-starter-graphql/pom.xml b/graphql-jpa-query-boot-starter-graphql/pom.xml index 22a4038aa..9257f4ea9 100644 --- a/graphql-jpa-query-boot-starter-graphql/pom.xml +++ b/graphql-jpa-query-boot-starter-graphql/pom.xml @@ -7,7 +7,7 @@ com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-boot-starter-graphql/src/test/java/com/introproventures/graphql/jpa/query/boot/test/boot/autoconfigure/GraphQLJpaQueryGraphQlSourceAutoConfigurationTest.java b/graphql-jpa-query-boot-starter-graphql/src/test/java/com/introproventures/graphql/jpa/query/boot/test/boot/autoconfigure/GraphQLJpaQueryGraphQlSourceAutoConfigurationTest.java index db5a86591..5c49cf386 100644 --- a/graphql-jpa-query-boot-starter-graphql/src/test/java/com/introproventures/graphql/jpa/query/boot/test/boot/autoconfigure/GraphQLJpaQueryGraphQlSourceAutoConfigurationTest.java +++ b/graphql-jpa-query-boot-starter-graphql/src/test/java/com/introproventures/graphql/jpa/query/boot/test/boot/autoconfigure/GraphQLJpaQueryGraphQlSourceAutoConfigurationTest.java @@ -15,6 +15,8 @@ */ package com.introproventures.graphql.jpa.query.boot.test.boot.autoconfigure; +import static org.assertj.core.api.Assertions.assertThat; + import com.introproventures.graphql.jpa.query.autoconfigure.EnableGraphQLJpaQuerySchema; import com.introproventures.graphql.jpa.query.autoconfigure.JavaScalarsRuntimeWiringConfigurer; import com.introproventures.graphql.jpa.query.boot.test.starter.model.Author; @@ -22,7 +24,6 @@ import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder; import graphql.schema.GraphQLObjectType; import graphql.schema.GraphQLSchema; -import org.dataloader.DataLoaderRegistry; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -35,10 +36,6 @@ import org.springframework.graphql.execution.RuntimeWiringConfigurer; import org.springframework.test.context.junit4.SpringRunner; -import static graphql.GraphQLContext.newContext; -import static org.assertj.core.api.Assertions.assertThat; -import static org.dataloader.DataLoaderRegistry.newRegistry; - @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) public class GraphQLJpaQueryGraphQlSourceAutoConfigurationTest { @@ -81,11 +78,5 @@ public void contextIsAutoConfigured() { .extracting(GraphQLObjectType::getName, GraphQLObjectType::getDescription) .containsExactly("GraphQLBooks", "GraphQL Books Schema Description"); - DataLoaderRegistry dataLoaderRegistry = newRegistry().build(); - batchLoaderRegistry.registerDataLoaders(dataLoaderRegistry, newContext().build()); - - assertThat(dataLoaderRegistry.getDataLoadersMap()) - .isNotEmpty() - .containsOnlyKeys("Author.books", "Book.author"); } -} \ No newline at end of file +} diff --git a/graphql-jpa-query-boot-starter/pom.xml b/graphql-jpa-query-boot-starter/pom.xml index 40feef98d..21bbad4fc 100644 --- a/graphql-jpa-query-boot-starter/pom.xml +++ b/graphql-jpa-query-boot-starter/pom.xml @@ -7,7 +7,7 @@ com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-build/pom.xml b/graphql-jpa-query-build/pom.xml index b4f1ee455..6fc834cff 100644 --- a/graphql-jpa-query-build/pom.xml +++ b/graphql-jpa-query-build/pom.xml @@ -1,10 +1,9 @@ - + 4.0.0 com.introproventures graphql-jpa-query-dependencies - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-dependencies graphql-jpa-query-build @@ -20,7 +19,7 @@ spring-milestones Spring Milestones - http://repo.spring.io/milestone + https://repo.spring.io/milestone true diff --git a/graphql-jpa-query-dependencies/pom.xml b/graphql-jpa-query-dependencies/pom.xml index be34816f7..fce1655ed 100644 --- a/graphql-jpa-query-dependencies/pom.xml +++ b/graphql-jpa-query-dependencies/pom.xml @@ -1,10 +1,9 @@ - + 4.0.0 com.introproventures graphql-jpa-query - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT .. graphql-jpa-query-dependencies diff --git a/graphql-jpa-query-example-merge/pom.xml b/graphql-jpa-query-example-merge/pom.xml index 27a1e01a0..f575726c1 100644 --- a/graphql-jpa-query-example-merge/pom.xml +++ b/graphql-jpa-query-example-merge/pom.xml @@ -7,7 +7,7 @@ com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-example-merge/src/main/java/com/introproventures/graphql/jpa/query/example/Application.java b/graphql-jpa-query-example-merge/src/main/java/com/introproventures/graphql/jpa/query/example/Application.java index 17a110eb0..a07c8a8f3 100644 --- a/graphql-jpa-query-example-merge/src/main/java/com/introproventures/graphql/jpa/query/example/Application.java +++ b/graphql-jpa-query-example-merge/src/main/java/com/introproventures/graphql/jpa/query/example/Application.java @@ -17,25 +17,25 @@ import static graphql.schema.visibility.DefaultGraphqlFieldVisibility.DEFAULT_FIELD_VISIBILITY; +import graphql.GraphQLContext; +import graphql.execution.instrumentation.Instrumentation; +import graphql.execution.instrumentation.SimpleInstrumentation; +import graphql.execution.instrumentation.tracing.TracingInstrumentation; +import graphql.schema.visibility.BlockedFields; +import graphql.schema.visibility.GraphqlFieldVisibility; import java.util.function.Supplier; - import javax.servlet.http.HttpServletRequest; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; +import org.springframework.data.transaction.ChainedTransactionManager; +import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.web.context.annotation.RequestScope; -import graphql.GraphQLContext; -import graphql.execution.instrumentation.Instrumentation; -import graphql.execution.instrumentation.SimpleInstrumentation; -import graphql.execution.instrumentation.tracing.TracingInstrumentation; -import graphql.schema.visibility.BlockedFields; -import graphql.schema.visibility.GraphqlFieldVisibility; - /** * GraphQL JPA Query Example with Spring Boot Autoconfiguration * @@ -79,5 +79,13 @@ public Supplier instrumentation(HttpServletRequest request) { ? new TracingInstrumentation() : SimpleInstrumentation.INSTANCE; } - + + + @Primary + PlatformTransactionManager transactionManager( + PlatformTransactionManager bookTransactionManager, + PlatformTransactionManager starWarsTransactionManager + ) { + return new ChainedTransactionManager(bookTransactionManager, starWarsTransactionManager); + } } diff --git a/graphql-jpa-query-example-model-books/pom.xml b/graphql-jpa-query-example-model-books/pom.xml index 240e2d42f..03d1c7375 100644 --- a/graphql-jpa-query-example-model-books/pom.xml +++ b/graphql-jpa-query-example-model-books/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build graphql-jpa-query-example-model-books diff --git a/graphql-jpa-query-example-model-starwars/pom.xml b/graphql-jpa-query-example-model-starwars/pom.xml index 3cf766da6..a3c4c5889 100644 --- a/graphql-jpa-query-example-model-starwars/pom.xml +++ b/graphql-jpa-query-example-model-starwars/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-example-relay/pom.xml b/graphql-jpa-query-example-relay/pom.xml index 42e2eae80..291f483c9 100644 --- a/graphql-jpa-query-example-relay/pom.xml +++ b/graphql-jpa-query-example-relay/pom.xml @@ -6,7 +6,7 @@ com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-example-simple/pom.xml b/graphql-jpa-query-example-simple/pom.xml index e4c0eb9cf..36d72e30e 100644 --- a/graphql-jpa-query-example-simple/pom.xml +++ b/graphql-jpa-query-example-simple/pom.xml @@ -7,7 +7,7 @@ com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-example-spring-graphql/pom.xml b/graphql-jpa-query-example-spring-graphql/pom.xml index 3164b1dae..4ba6e3c97 100644 --- a/graphql-jpa-query-example-spring-graphql/pom.xml +++ b/graphql-jpa-query-example-spring-graphql/pom.xml @@ -7,7 +7,7 @@ com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-graphiql/pom.xml b/graphql-jpa-query-graphiql/pom.xml index f91ee2de7..2874ab328 100644 --- a/graphql-jpa-query-graphiql/pom.xml +++ b/graphql-jpa-query-graphiql/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build graphql-jpa-query-graphiql diff --git a/graphql-jpa-query-introspection/pom.xml b/graphql-jpa-query-introspection/pom.xml index b8d3c2474..36a0714d5 100644 --- a/graphql-jpa-query-introspection/pom.xml +++ b/graphql-jpa-query-introspection/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build graphql-jpa-query-introspection diff --git a/graphql-jpa-query-scalars/pom.xml b/graphql-jpa-query-scalars/pom.xml index 70d1d1184..7fbf5ba1a 100644 --- a/graphql-jpa-query-scalars/pom.xml +++ b/graphql-jpa-query-scalars/pom.xml @@ -1,12 +1,11 @@ - + graphql-jpa-query-scalars graphql-jpa-query-scalars com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-schema/pom.xml b/graphql-jpa-query-schema/pom.xml index 5aa49c50d..a85eb5ca6 100644 --- a/graphql-jpa-query-schema/pom.xml +++ b/graphql-jpa-query-schema/pom.xml @@ -1,12 +1,11 @@ - + graphql-jpa-query-schema graphql-jpa-query-schema com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaQueryFactory.java b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaQueryFactory.java index dbb62b88c..ab616e3a1 100644 --- a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaQueryFactory.java +++ b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaQueryFactory.java @@ -15,6 +15,53 @@ */ package com.introproventures.graphql.jpa.query.schema.impl; +import static com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder.SELECT_DISTINCT_PARAM_NAME; +import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.getObjectField; +import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.isAfterArgument; +import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.isDistinctArgument; +import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.isFirstArgument; +import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.isLogicalArgument; +import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.isPageArgument; +import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.isWhereArgument; +import static graphql.introspection.Introspection.SchemaMetaFieldDef; +import static graphql.introspection.Introspection.TypeMetaFieldDef; +import static graphql.introspection.Introspection.TypeNameMetaFieldDef; +import static java.util.stream.Collectors.groupingBy; + +import com.introproventures.graphql.jpa.query.annotation.GraphQLDefaultOrderBy; +import com.introproventures.graphql.jpa.query.introspection.ReflectionUtil; +import com.introproventures.graphql.jpa.query.schema.JavaScalars; +import com.introproventures.graphql.jpa.query.schema.RestrictedKeysProvider; +import com.introproventures.graphql.jpa.query.schema.impl.EntityIntrospector.EntityIntrospectionResult; +import com.introproventures.graphql.jpa.query.schema.impl.EntityIntrospector.EntityIntrospectionResult.AttributePropertyDescriptor; +import com.introproventures.graphql.jpa.query.schema.impl.PredicateFilter.Criteria; +import com.introproventures.graphql.jpa.query.support.GraphQLSupport; +import graphql.GraphQLException; +import graphql.execution.CoercedVariables; +import graphql.execution.MergedField; +import graphql.execution.ValuesResolver; +import graphql.language.Argument; +import graphql.language.ArrayValue; +import graphql.language.BooleanValue; +import graphql.language.EnumValue; +import graphql.language.Field; +import graphql.language.FloatValue; +import graphql.language.IntValue; +import graphql.language.NullValue; +import graphql.language.ObjectField; +import graphql.language.ObjectValue; +import graphql.language.SelectionSet; +import graphql.language.StringValue; +import graphql.language.Value; +import graphql.language.VariableReference; +import graphql.schema.DataFetchingEnvironment; +import graphql.schema.GraphQLArgument; +import graphql.schema.GraphQLFieldDefinition; +import graphql.schema.GraphQLList; +import graphql.schema.GraphQLObjectType; +import graphql.schema.GraphQLScalarType; +import graphql.schema.GraphQLSchema; +import graphql.schema.GraphQLType; import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; @@ -60,56 +107,9 @@ import javax.persistence.metamodel.PluralAttribute; import javax.persistence.metamodel.SingularAttribute; import javax.persistence.metamodel.Type; -import com.introproventures.graphql.jpa.query.annotation.GraphQLDefaultOrderBy; -import com.introproventures.graphql.jpa.query.introspection.ReflectionUtil; -import com.introproventures.graphql.jpa.query.schema.JavaScalars; -import com.introproventures.graphql.jpa.query.schema.RestrictedKeysProvider; -import com.introproventures.graphql.jpa.query.schema.impl.EntityIntrospector.EntityIntrospectionResult; -import com.introproventures.graphql.jpa.query.schema.impl.EntityIntrospector.EntityIntrospectionResult.AttributePropertyDescriptor; -import com.introproventures.graphql.jpa.query.schema.impl.PredicateFilter.Criteria; -import com.introproventures.graphql.jpa.query.support.GraphQLSupport; -import graphql.GraphQLException; -import graphql.execution.CoercedVariables; -import graphql.execution.MergedField; -import graphql.execution.ValuesResolver; -import graphql.language.Argument; -import graphql.language.ArrayValue; -import graphql.language.BooleanValue; -import graphql.language.EnumValue; -import graphql.language.Field; -import graphql.language.FloatValue; -import graphql.language.IntValue; -import graphql.language.NullValue; -import graphql.language.ObjectField; -import graphql.language.ObjectValue; -import graphql.language.SelectionSet; -import graphql.language.StringValue; -import graphql.language.Value; -import graphql.language.VariableReference; -import graphql.schema.DataFetchingEnvironment; -import graphql.schema.GraphQLArgument; -import graphql.schema.GraphQLFieldDefinition; -import graphql.schema.GraphQLList; -import graphql.schema.GraphQLObjectType; -import graphql.schema.GraphQLScalarType; -import graphql.schema.GraphQLSchema; -import graphql.schema.GraphQLType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder.SELECT_DISTINCT_PARAM_NAME; -import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.getObjectField; -import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.isAfterArgument; -import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.isDistinctArgument; -import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.isFirstArgument; -import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.isLogicalArgument; -import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.isPageArgument; -import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.isWhereArgument; -import static graphql.introspection.Introspection.SchemaMetaFieldDef; -import static graphql.introspection.Introspection.TypeMetaFieldDef; -import static graphql.introspection.Introspection.TypeNameMetaFieldDef; -import static java.util.stream.Collectors.groupingBy; - /** * Provides implemetation for GraphQL JPA Query Factory * @@ -121,6 +121,26 @@ public final class GraphQLJpaQueryFactory { private static final String DESC = "DESC"; private final static Logger logger = LoggerFactory.getLogger(GraphQLJpaQueryFactory.class); + private static Function unproxy; + + static { + try { + Class hibernateClass =Class.forName("org.hibernate.Hibernate"); + Method unproxyMethod = hibernateClass.getDeclaredMethod("unproxy", Object.class); + + unproxy = proxy -> { + try { + return unproxyMethod.invoke(null, proxy); + } catch (Exception ignored) {} + + return proxy; + }; + + } catch (Exception ignored) { + unproxy = Function.identity(); + } + + } protected static final String WHERE = "where"; protected static final String OPTIONAL = "optional"; @@ -260,13 +280,13 @@ protected Stream getResultStream(TypedQuery query, if (resultStream) { return query.getResultStream() - .peek(entityManager::detach); + .map(this::applyUnproxy); } // Let's execute query and wrap result into stream return query.getResultList() .stream() - .peek(entityManager::detach); + .map(this::applyUnproxy); } protected Object querySingleResult(final DataFetchingEnvironment environment) { @@ -289,13 +309,9 @@ protected Object querySingleResult(final DataFetchingEnvironment environment) { logger.info("\nGraphQL JPQL Single Result Query String:\n {}", getJPQLQueryString(query)); } - Object result = query.getSingleResult(); - - if (result != null) { - entityManager.detach(result); - } - - return result; + return Optional.ofNullable(query.getSingleResult()) + .map(this::applyUnproxy) + .orElse(null); } return null; @@ -417,9 +433,8 @@ protected Map> loadOneToMany(DataFetchingEnvironment enviro List resultList = getResultList(query); Map> batch = resultList.stream() - .peek(t -> entityManager.detach(t[1])) .collect(groupingBy(t -> t[0], - Collectors.mapping(t -> t[1], + Collectors.mapping(t -> this.applyUnproxy(t[1]), GraphQLSupport.toResultList()))); Map> resultMap = new LinkedHashMap<>(keys.size()); @@ -442,9 +457,7 @@ protected Map loadManyToOne(DataFetchingEnvironment environment, Map resultMap = new LinkedHashMap<>(resultList.size()); - resultList.stream() - .peek(t -> entityManager.detach(t[1])) - .forEach(item -> resultMap.put(item[0], item[1])); + resultList.forEach(item -> resultMap.put(item[0], this.applyUnproxy(item[1]))); return resultMap; } @@ -1871,6 +1884,10 @@ protected boolean hasAnySelectionOrderBy(Field field) { } + private T applyUnproxy(T entity) { + return (T) unproxy.apply(entity); + } + /** * Creates builder to build {@link GraphQLJpaQueryFactory}. * @return created builder diff --git a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToManyDataFetcher.java b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToManyDataFetcher.java index eeb9b0bc6..0bf53a3cb 100644 --- a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToManyDataFetcher.java +++ b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToManyDataFetcher.java @@ -16,25 +16,20 @@ package com.introproventures.graphql.jpa.query.schema.impl; +import com.introproventures.graphql.jpa.query.support.GraphQLSupport; +import graphql.language.Argument; +import graphql.language.Field; +import graphql.schema.DataFetcher; +import graphql.schema.DataFetchingEnvironment; +import graphql.schema.GraphQLNamedType; import java.util.List; import java.util.Optional; - import javax.persistence.metamodel.PluralAttribute; - -import graphql.schema.GraphQLNamedType; import org.dataloader.DataLoader; import org.dataloader.DataLoaderOptions; import org.dataloader.DataLoaderRegistry; import org.dataloader.MappedBatchLoaderWithContext; -import com.introproventures.graphql.jpa.query.support.GraphQLSupport; -import graphql.GraphQLContext; -import graphql.language.Argument; -import graphql.language.Field; -import graphql.schema.DataFetcher; -import graphql.schema.DataFetchingEnvironment; -import graphql.schema.GraphQLType; - /** * One-To-Many DataFetcher that uses where argument to filter collection attributes * @@ -79,8 +74,7 @@ public Object get(DataFetchingEnvironment environment) { protected DataLoader> getDataLoader(DataFetchingEnvironment environment, String dataLoaderKey) { - GraphQLContext context = environment.getContext(); - DataLoaderRegistry dataLoaderRegistry = context.get("dataLoaderRegistry"); + DataLoaderRegistry dataLoaderRegistry = environment.getDataLoaderRegistry(); if (!dataLoaderRegistry.getKeys() .contains(dataLoaderKey)) { diff --git a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToManyMappedBatchLoader.java b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToManyMappedBatchLoader.java index 279fdde66..93fffdf5a 100644 --- a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToManyMappedBatchLoader.java +++ b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToManyMappedBatchLoader.java @@ -1,16 +1,14 @@ package com.introproventures.graphql.jpa.query.schema.impl; +import graphql.schema.DataFetchingEnvironment; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; - import org.dataloader.BatchLoaderEnvironment; import org.dataloader.MappedBatchLoaderWithContext; -import graphql.schema.DataFetchingEnvironment; - // a batch loader function that will be called with N or more keys for batch loading class GraphQLJpaToManyMappedBatchLoader implements MappedBatchLoaderWithContext> { @@ -26,7 +24,7 @@ public CompletionStage>> load(Set keys, BatchLo DataFetchingEnvironment context = (DataFetchingEnvironment) environment.getKeyContexts() .get(key); - return CompletableFuture.supplyAsync(() -> queryFactory.loadOneToMany(context, keys)); + return CompletableFuture.supplyAsync(() -> queryFactory.loadOneToMany(context, keys), Runnable::run); } diff --git a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToOneDataFetcher.java b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToOneDataFetcher.java index 72e96322a..9536c108d 100644 --- a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToOneDataFetcher.java +++ b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToOneDataFetcher.java @@ -18,23 +18,18 @@ import static javax.persistence.metamodel.Attribute.PersistentAttributeType.EMBEDDED; +import graphql.language.Argument; +import graphql.language.Field; +import graphql.schema.DataFetcher; +import graphql.schema.DataFetchingEnvironment; +import graphql.schema.GraphQLNamedType; import java.util.Optional; - import javax.persistence.metamodel.SingularAttribute; - -import graphql.schema.GraphQLNamedType; import org.dataloader.DataLoader; import org.dataloader.DataLoaderOptions; import org.dataloader.DataLoaderRegistry; import org.dataloader.MappedBatchLoaderWithContext; -import graphql.GraphQLContext; -import graphql.language.Argument; -import graphql.language.Field; -import graphql.schema.DataFetcher; -import graphql.schema.DataFetchingEnvironment; -import graphql.schema.GraphQLType; - /** * One-To-Many DataFetcher that uses where argument to filter collection attributes * @@ -81,8 +76,7 @@ public Object get(DataFetchingEnvironment environment) { protected DataLoader getDataLoader(DataFetchingEnvironment environment, String dataLoaderKey) { - GraphQLContext context = environment.getContext(); - DataLoaderRegistry dataLoaderRegistry = context.get("dataLoaderRegistry"); + DataLoaderRegistry dataLoaderRegistry = environment.getDataLoaderRegistry(); if (!dataLoaderRegistry.getKeys() .contains(dataLoaderKey)) { diff --git a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToOneMappedBatchLoader.java b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToOneMappedBatchLoader.java index 93fb4668b..c19479032 100644 --- a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToOneMappedBatchLoader.java +++ b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaToOneMappedBatchLoader.java @@ -1,15 +1,13 @@ package com.introproventures.graphql.jpa.query.schema.impl; +import graphql.schema.DataFetchingEnvironment; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; - import org.dataloader.BatchLoaderEnvironment; import org.dataloader.MappedBatchLoaderWithContext; -import graphql.schema.DataFetchingEnvironment; - // a batch loader function that will be called with N or more keys for batch loading class GraphQLJpaToOneMappedBatchLoader implements MappedBatchLoaderWithContext { @@ -25,6 +23,6 @@ public CompletionStage> load(Set keys, BatchLoaderEn DataFetchingEnvironment context = (DataFetchingEnvironment) environment.getKeyContexts() .get(key); - return CompletableFuture.supplyAsync(() -> queryFactory.loadManyToOne(context, keys)); + return CompletableFuture.supplyAsync(() -> queryFactory.loadManyToOne(context, keys), Runnable::run); } }; diff --git a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/converter/GraphQLJpaConverterTests.java b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/converter/GraphQLJpaConverterTests.java index 27d0e406f..4d0746516 100644 --- a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/converter/GraphQLJpaConverterTests.java +++ b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/converter/GraphQLJpaConverterTests.java @@ -18,10 +18,20 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.introproventures.graphql.jpa.query.AbstractSpringBootTestSupport; +import com.introproventures.graphql.jpa.query.converter.model.JsonEntity; +import com.introproventures.graphql.jpa.query.converter.model.TaskEntity; +import com.introproventures.graphql.jpa.query.converter.model.TaskVariableEntity; +import com.introproventures.graphql.jpa.query.converter.model.VariableValue; +import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor; +import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder; +import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor; +import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder; import java.util.Collections; import java.util.List; import java.util.Map; - import javax.persistence.EntityManager; import javax.persistence.Query; import javax.persistence.criteria.CriteriaBuilder; @@ -31,26 +41,12 @@ import javax.persistence.criteria.Root; import javax.persistence.criteria.Subquery; import javax.transaction.Transactional; - import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.introproventures.graphql.jpa.query.AbstractSpringBootTestSupport; -import com.introproventures.graphql.jpa.query.converter.model.JsonEntity; -import com.introproventures.graphql.jpa.query.converter.model.TaskEntity; -import com.introproventures.graphql.jpa.query.converter.model.TaskVariableEntity; -import com.introproventures.graphql.jpa.query.converter.model.VariableValue; -import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor; -import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder; -import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor; -import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder; - @SpringBootTest(properties = { "spring.sql.init.data-locations=GraphQLJpaConverterTests.sql", @@ -895,4 +891,29 @@ public void testGraphqlTasksQueryWithNENullValues() { assertThat(result.toString()).isEqualTo(expected); } -} \ No newline at end of file + @Test + public void testGraphqlTasksQueryWithEmbeddedVariablesWhereCriteria() throws InterruptedException { + // @formatter:off + String query = + "query getTasks {" + + " Tasks(where: {businessKey: {EQ: \"bk1\"}}) {" + + " select {" + + " businessKey" + + " variables(where: {name: {EQ: \"variable1\"}}) {" + + " name" + + " value" + + " }" + + " }" + + " }" + + "}"; + // @formatter:on + + Object result = executor.execute(query) + .getData(); + + String expected = "{Tasks={select=[{businessKey=bk1, variables=[{name=variable1, value=data}]}]}}"; + + assertThat(result.toString()).isEqualTo(expected); + } + +} diff --git a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/support/StarwarsQueryExecutorTestsSupport.java b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/support/StarwarsQueryExecutorTestsSupport.java index 19af2ff2f..af44f376c 100644 --- a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/support/StarwarsQueryExecutorTestsSupport.java +++ b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/support/StarwarsQueryExecutorTestsSupport.java @@ -16,6 +16,14 @@ package com.introproventures.graphql.jpa.query.support; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.tuple; + +import com.introproventures.graphql.jpa.query.AbstractSpringBootTestSupport; +import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor; +import com.introproventures.graphql.jpa.query.schema.model.starwars.Character; +import com.introproventures.graphql.jpa.query.schema.model.starwars.Droid; +import com.introproventures.graphql.jpa.query.schema.model.starwars.Human; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -24,19 +32,11 @@ import javax.persistence.EntityManager; import javax.persistence.Query; import javax.transaction.Transactional; -import com.introproventures.graphql.jpa.query.AbstractSpringBootTestSupport; -import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor; -import com.introproventures.graphql.jpa.query.schema.model.starwars.Character; -import com.introproventures.graphql.jpa.query.schema.model.starwars.Droid; -import com.introproventures.graphql.jpa.query.schema.model.starwars.Human; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.support.TransactionTemplate; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.AssertionsForClassTypes.tuple; - public abstract class StarwarsQueryExecutorTestsSupport extends AbstractSpringBootTestSupport { @Autowired @@ -2116,6 +2116,7 @@ public void queryWithInLineExplicitOptionalFalseForSingularAttributeAndWhereSear // https://github.com/introproventures/graphql-jpa-query/issues/273 @Test + @Transactional public void testGH273Plural() { //given: diff --git a/graphql-jpa-query-web/pom.xml b/graphql-jpa-query-web/pom.xml index a38413e25..00a062bef 100644 --- a/graphql-jpa-query-web/pom.xml +++ b/graphql-jpa-query-web/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT ../graphql-jpa-query-build graphql-jpa-query-web diff --git a/graphql-jpa-query-web/src/main/java/com/introproventures/graphql/jpa/query/web/GraphQLController.java b/graphql-jpa-query-web/src/main/java/com/introproventures/graphql/jpa/query/web/GraphQLController.java index eab1d6016..480f85893 100644 --- a/graphql-jpa-query-web/src/main/java/com/introproventures/graphql/jpa/query/web/GraphQLController.java +++ b/graphql-jpa-query-web/src/main/java/com/introproventures/graphql/jpa/query/web/GraphQLController.java @@ -20,11 +20,18 @@ import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor; import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor; import graphql.ExecutionResult; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.UncheckedIOException; +import java.util.HashMap; +import java.util.Map; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import org.springframework.http.MediaType; -import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -34,15 +41,6 @@ import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter.SseEventBuilder; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.UncheckedIOException; -import java.util.HashMap; -import java.util.Map; - /** * Spring Boot GraphQL Query Rest Controller with HTTP mapping endpoints for GraphQLExecutor relay * @@ -50,7 +48,6 @@ * */ @RestController -@Transactional public class GraphQLController { private static final String PATH = "${spring.graphql.jpa.query.web.path:/graphql}"; diff --git a/pom.xml b/pom.xml index 1b5d10bc3..ee05ed7cf 100644 --- a/pom.xml +++ b/pom.xml @@ -1,11 +1,10 @@ - + 4.0.0 com.introproventures graphql-jpa-query - 0.5.5-SNAPSHOT + 0.5.6-SNAPSHOT pom GraphQL JPA Query