diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f101b9ae4..8cfed46b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,11 +3,11 @@ name: CI on: workflow_dispatch: push: - branches: [ "master" ] + branches: [ "1.1.x" ] paths-ignore: - '**/README.md' pull_request: - branches: [ "master" ] + branches: [ "1.1.x" ] paths-ignore: - '**/README.md' diff --git a/CHANGELOG.md b/CHANGELOG.md index 9167c1d7b..35dd287cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,21 @@ # Change Log -## 1.1.4-SNAPSHOT +## 1.1.7-SNAPSHOT +* Backport fix variable value conversion for array of values (#428) (#431) [3fb339c](https://github.com/introproventures/graphql-jpa-query/commit/3fb339cbd042627ade4d0cb1e8526b11e2e996b5) +* update plugin versions [144ebc4](https://github.com/introproventures/graphql-jpa-query/commit/144ebc492c734554ce25bf8f9be2a02c3283f306) +* Backport fix for auto configuration to use operation's default execution strategy delegate (#412) [cc68c04](https://github.com/introproventures/graphql-jpa-query/commit/cc68c04c66f0acfb4c07e1d545c4d8d9d3bb44e9) +* update maven-javadoc-plugin config to use java.version (#398) [2888d39](https://github.com/introproventures/graphql-jpa-query/commit/2888d394f1c1da5327368eb628a2bb3a7d1e0a77) +* update prettier-maven-plugin.version to 0.21 (#396) [c6b25ab](https://github.com/introproventures/graphql-jpa-query/commit/c6b25ab150a83f6fa00e5a8a4e56d68bd8a74abe) +* chore(deps): bump org.apache.maven.plugins:maven-gpg-plugin (#395) [11a6ee7](https://github.com/introproventures/graphql-jpa-query/commit/11a6ee7902592a7a2d0f1162ed5254ab664fcd78) +* chore(deps): bump org.apache.maven.plugins:maven-surefire-plugin (#394) [cd15d96](https://github.com/introproventures/graphql-jpa-query/commit/cd15d96960eac7c178eec8c2944e6181829d0301) +* chore(deps): bump org.jacoco:jacoco-maven-plugin from 0.8.8 to 0.8.11 (#392) [781004a](https://github.com/introproventures/graphql-jpa-query/commit/781004abe7fb25b866b01ab1bd2bbffbc72e9b47) +* update spring-boot.version to 3.1.6 (#391) [d462752](https://github.com/introproventures/graphql-jpa-query/commit/d46275288e535ee90434e176dd90f4bf632bfb90) +* chore(deps): bump actions/checkout from 3 to 4 (#386) [d72a194](https://github.com/introproventures/graphql-jpa-query/commit/d72a1942e47e4b37fcbf62dc50f8447dae7486cb) +* chore(deps): bump com.graphql-java:graphql-java-extended-scalars (#383) [a42aac8](https://github.com/introproventures/graphql-jpa-query/commit/a42aac89d7d73097a3bedab0d666ec605c5ae879) +* chore(deps): bump org.apache.maven.plugins:maven-javadoc-plugin (#384) [abc9e96](https://github.com/introproventures/graphql-jpa-query/commit/abc9e96c9ceb22c0a11d5be2f59564f70e2c775b) +* chore(deps): bump org.apache.maven.plugins:maven-enforcer-plugin (#385) [daabbd1](https://github.com/introproventures/graphql-jpa-query/commit/daabbd1046c5e78457cf81631e838e5e841ef273) +* chore(deps): bump org.apache.maven.plugins:maven-dependency-plugin (#382) [e88c1f7](https://github.com/introproventures/graphql-jpa-query/commit/e88c1f705dd9fa006a818c84cf4ca25d56633702) +* Update hibernate.version to 6.2.13.Final (#389) [64a0ea7](https://github.com/introproventures/graphql-jpa-query/commit/64a0ea75fb32121c33b7750dc59ba4442946181f) * bump activiti-cloud.version to 8.1.0 (#388) [be548ae](https://github.com/introproventures/graphql-jpa-query/commit/be548ae4ed8f0baf61f8fa1f1a001a66ed4c2e31) * Add support for lazy loaded attribute fetching with JPA entity graph query hint (#387) [715021d](https://github.com/introproventures/graphql-jpa-query/commit/715021ded185956ad40a481c9d270532c0950e79) * chore(deps): bump maven-compiler-plugin from 3.10.1 to 3.11.0 (#369) [17120b6](https://github.com/introproventures/graphql-jpa-query/commit/17120b6c0cd908ab5619193cf0ff25c53b736a8d) diff --git a/annotations/pom.xml b/annotations/pom.xml index 9a0281071..9dadeda04 100644 --- a/annotations/pom.xml +++ b/annotations/pom.xml @@ -6,7 +6,7 @@ com.introproventures graphql-jpa-query-dependencies - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../dependencies diff --git a/autoconfigure/pom.xml b/autoconfigure/pom.xml index d36e889cf..b3349ba25 100644 --- a/autoconfigure/pom.xml +++ b/autoconfigure/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../build graphql-jpa-query-autoconfigure diff --git a/autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaBuilderAutoConfiguration.java b/autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaBuilderAutoConfiguration.java index fdb4f330f..e120cfd88 100644 --- a/autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaBuilderAutoConfiguration.java +++ b/autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaBuilderAutoConfiguration.java @@ -6,6 +6,8 @@ import com.introproventures.graphql.jpa.query.schema.RestrictedKeysProvider; import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder; import graphql.GraphQL; +import graphql.execution.AsyncExecutionStrategy; +import graphql.execution.SubscriptionExecutionStrategy; import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManagerFactory; import org.slf4j.Logger; @@ -51,7 +53,8 @@ QueryExecutionStrategyProvider queryExecutionStrategy( var transactionTemplate = graphQLSchemaTransactionTemplate.get(); transactionTemplate.setReadOnly(true); - return () -> newTransactionalExecutionStrategy(transactionTemplate).build(); + return () -> + newTransactionalExecutionStrategy(transactionTemplate).delegate(new AsyncExecutionStrategy()).build(); } @Bean @@ -63,7 +66,8 @@ MutationExecutionStrategyProvider mutationExecutionStrategy( var transactionTemplate = graphQLSchemaTransactionTemplate.get(); transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); - return () -> newTransactionalExecutionStrategy(transactionTemplate).build(); + return () -> + newTransactionalExecutionStrategy(transactionTemplate).delegate(new AsyncExecutionStrategy()).build(); } @Bean @@ -74,8 +78,12 @@ SubscriptionExecutionStrategyProvider subscriptionExecutionStrategy( ) { var transactionTemplate = graphQLSchemaTransactionTemplate.get(); transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS); + transactionTemplate.setReadOnly(true); - return () -> newTransactionalExecutionStrategy(transactionTemplate).build(); + return () -> + newTransactionalExecutionStrategy(transactionTemplate) + .delegate(new SubscriptionExecutionStrategy()) + .build(); } @Bean diff --git a/boot-starter/pom.xml b/boot-starter/pom.xml index 0f031c3a7..e6f11e38f 100644 --- a/boot-starter/pom.xml +++ b/boot-starter/pom.xml @@ -12,7 +12,7 @@ com.introproventures graphql-jpa-query-dependencies - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../dependencies diff --git a/build/pom.xml b/build/pom.xml index 98294e831..685bb0e4a 100644 --- a/build/pom.xml +++ b/build/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-dependencies - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../dependencies graphql-jpa-query-build diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 6e37e3545..206f69054 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../pom.xml graphql-jpa-query-dependencies diff --git a/examples/pom.xml b/examples/pom.xml index 414be9c66..9d59ee41e 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -4,7 +4,7 @@ com.introproventures graphql-jpa-query-build - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../build diff --git a/examples/spring-graphql-web/pom.xml b/examples/spring-graphql-web/pom.xml index c90e6f0d6..d602efbdb 100644 --- a/examples/spring-graphql-web/pom.xml +++ b/examples/spring-graphql-web/pom.xml @@ -7,7 +7,7 @@ com.introproventures graphql-jpa-query-examples - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../pom.xml diff --git a/introspection/pom.xml b/introspection/pom.xml index 481f0fba9..98c9407b7 100644 --- a/introspection/pom.xml +++ b/introspection/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../build graphql-jpa-query-introspection diff --git a/pom.xml b/pom.xml index 9205ae26b..e9b0e53f0 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.introproventures graphql-jpa-query - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT pom GraphQL JPA Query @@ -216,7 +216,7 @@ maven-javadoc-plugin - 3.6.2 + 2.9.1 ${java.version} @@ -246,7 +246,7 @@ maven-source-plugin - 2.1.2 + 2.2.1 attach-sources @@ -398,7 +398,7 @@ sonatype-nexus-staging https://oss.sonatype.org/ - true + false ${skipStaging} @@ -420,7 +420,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.0.1 sign-artifacts diff --git a/scalars/pom.xml b/scalars/pom.xml index 1f5de62a4..0d7faac4a 100644 --- a/scalars/pom.xml +++ b/scalars/pom.xml @@ -9,7 +9,7 @@ com.introproventures graphql-jpa-query-build - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../build diff --git a/schema/pom.xml b/schema/pom.xml index 5896822db..9b41d9745 100644 --- a/schema/pom.xml +++ b/schema/pom.xml @@ -9,7 +9,7 @@ com.introproventures graphql-jpa-query-build - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../build diff --git a/schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaQueryFactory.java b/schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaQueryFactory.java index b312832a2..0bb910d3e 100644 --- a/schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaQueryFactory.java +++ b/schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaQueryFactory.java @@ -53,6 +53,7 @@ import graphql.language.StringValue; import graphql.language.Value; import graphql.language.VariableReference; +import graphql.schema.Coercing; import graphql.schema.DataFetchingEnvironment; import graphql.schema.GraphQLArgument; import graphql.schema.GraphQLFieldDefinition; @@ -1507,22 +1508,30 @@ protected Object convertValue(DataFetchingEnvironment environment, Argument argu // Return provided StringValue return ((StringValue) value).getValue(); } - } else if (value instanceof VariableReference) { + } else if (value instanceof VariableReference variableReference) { Class javaType = getJavaType(environment, argument); - Object argumentValue = environment.getVariables().get(VariableReference.class.cast(value).getName()); + Object argumentValue = environment.getVariables().get(variableReference.getName()); + if (javaType.isEnum()) { - if (argumentValue instanceof Collection) { + if (argumentValue instanceof Collection argumentValues) { List values = new ArrayList<>(); - Collection.class.cast(argumentValue) - .forEach(it -> values.add(Enum.valueOf(javaType, it.toString()))); + argumentValues.forEach(it -> values.add(Enum.valueOf(javaType, it.toString()))); + return values; } else { return Enum.valueOf(javaType, argumentValue.toString()); } } else { - // Get resolved variable in environment arguments - return argumentValue; + Coercing coercing = JavaScalars.of(javaType).getCoercing(); + Function valueConverter = it -> javaType.isInstance(it) ? it : coercing.parseValue(it); + + if (argumentValue instanceof Collection argumentValues) { + return argumentValues.stream().map(valueConverter).toList(); + } else { + // Get resolved variable in environment arguments + return valueConverter.apply(argumentValue); + } } } else if (value instanceof ArrayValue) { Collection arrayValue = environment.getArgument(argument.getName()); diff --git a/schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/JpaPredicateBuilder.java b/schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/JpaPredicateBuilder.java index e0a434d57..511ab5037 100644 --- a/schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/JpaPredicateBuilder.java +++ b/schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/JpaPredicateBuilder.java @@ -794,7 +794,7 @@ private Predicate getTypedPredicate(From from, Path field, PredicateFil Class type = filter.getJavaType(); Object value = filter.getValue(); Set criterias = filter.getCriterias(); - Attribute attribute = filter.getAttribute(); + Attribute attribute = filter.getAttribute(); if (value == null) { return cb.disjunction(); diff --git a/schema/src/test/java/com/introproventures/graphql/jpa/query/schema/GraphQLExecutorTests.java b/schema/src/test/java/com/introproventures/graphql/jpa/query/schema/GraphQLExecutorTests.java index 7a29deb83..bf5588a33 100644 --- a/schema/src/test/java/com/introproventures/graphql/jpa/query/schema/GraphQLExecutorTests.java +++ b/schema/src/test/java/com/introproventures/graphql/jpa/query/schema/GraphQLExecutorTests.java @@ -195,6 +195,25 @@ public void queryForThingByIdViaWhereIN() { assertThat(result.toString()).isEqualTo(expected); } + @Test + public void queryForThingByIdViaWhereINVariables() { + //given: + + String query = "query things($ids: [UUID]!){ Things(where: {id: {IN: $ids}}) { select { id }}}"; + String expected = "{Things={select=[{id=2d1ebc5b-7d27-4197-9cf0-e84451c5bbb1}]}}"; + + //when: + Object result = executor + .execute( + query, + Map.of("ids", List.of("2d1ebc5b-7d27-4197-9cf0-e84451c5bbb1", "2d1ebc5b-7d27-4197-9cf0-e84451c5bbb1")) + ) + .getData(); + + //then: + assertThat(result.toString()).isEqualTo(expected); + } + @SuppressWarnings({ "rawtypes", "unchecked", "serial" }) @Test public void queryForThingByIdViaWhereNE() { diff --git a/tests/boot-starter/pom.xml b/tests/boot-starter/pom.xml index 6da1d07f4..afebd1037 100644 --- a/tests/boot-starter/pom.xml +++ b/tests/boot-starter/pom.xml @@ -6,7 +6,7 @@ com.introproventures graphql-jpa-query-tests - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../pom.xml diff --git a/tests/gatling/pom.xml b/tests/gatling/pom.xml index 17f80098c..48d3e3019 100644 --- a/tests/gatling/pom.xml +++ b/tests/gatling/pom.xml @@ -4,7 +4,7 @@ com.introproventures graphql-jpa-query-tests - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../pom.xml diff --git a/tests/models/books/pom.xml b/tests/models/books/pom.xml index c8308848d..171b7ff0e 100644 --- a/tests/models/books/pom.xml +++ b/tests/models/books/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-test-models - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../pom.xml diff --git a/tests/models/pom.xml b/tests/models/pom.xml index a2776238c..20de99f80 100644 --- a/tests/models/pom.xml +++ b/tests/models/pom.xml @@ -4,7 +4,7 @@ com.introproventures graphql-jpa-query-tests - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../pom.xml diff --git a/tests/models/starwars/pom.xml b/tests/models/starwars/pom.xml index 8d2db1225..40d092dc1 100644 --- a/tests/models/starwars/pom.xml +++ b/tests/models/starwars/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-test-models - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../pom.xml diff --git a/tests/multiple-datasources/pom.xml b/tests/multiple-datasources/pom.xml index 1042e15d6..644583959 100644 --- a/tests/multiple-datasources/pom.xml +++ b/tests/multiple-datasources/pom.xml @@ -6,7 +6,7 @@ com.introproventures graphql-jpa-query-tests - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../pom.xml diff --git a/tests/pom.xml b/tests/pom.xml index b5b0821aa..66537733c 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -4,7 +4,7 @@ com.introproventures graphql-jpa-query-build - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../build diff --git a/tests/relay/pom.xml b/tests/relay/pom.xml index 471f7c473..122680d2c 100644 --- a/tests/relay/pom.xml +++ b/tests/relay/pom.xml @@ -7,7 +7,7 @@ com.introproventures graphql-jpa-query-tests - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../pom.xml diff --git a/tests/starwars/pom.xml b/tests/starwars/pom.xml index e4b2f0fe8..30bbd1d66 100644 --- a/tests/starwars/pom.xml +++ b/tests/starwars/pom.xml @@ -6,7 +6,7 @@ com.introproventures graphql-jpa-query-tests - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../pom.xml diff --git a/tests/web/pom.xml b/tests/web/pom.xml index 40ccb4d60..4db3c4a04 100644 --- a/tests/web/pom.xml +++ b/tests/web/pom.xml @@ -4,7 +4,7 @@ com.introproventures graphql-jpa-query-tests - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../pom.xml diff --git a/web/pom.xml b/web/pom.xml index 938569c0f..d4fade8dd 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 1.1.4-SNAPSHOT + 1.1.7-SNAPSHOT ../build graphql-jpa-query-web