diff --git a/.gitignore b/.gitignore
index 96c30aa6e..6e379656e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
#.project
.settings/
build/
+.factorypath
# Intellij
.idea/
diff --git a/README.md b/README.md
index abfa1f819..20d682136 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ For GraphQL JPA Annotations use:
For GraphQL JPA Schema Builder use:
- com.github.introproventures.graphql-jpa-query
+ com.introproventures
graphql-jpa-query-schema
0.3.0
@@ -215,7 +215,7 @@ Will Return:
Reverse Query
-------------
-You can execute an inverse query to fitler results with a join in many-to-one association with some limitations. If you do this, be aware that only static parameter binding are supported in `where` criteria expressions.
+You can execute an inverse query to fitler results with a join in many-to-one association in one query with parameter bindings support added in 0.3.1
For Example:
diff --git a/graphql-jpa-query-annotations/.project b/graphql-jpa-query-annotations/.project
index 8d822c188..f2fb92024 100644
--- a/graphql-jpa-query-annotations/.project
+++ b/graphql-jpa-query-annotations/.project
@@ -20,8 +20,19 @@
+
+ org.springframework.ide.eclipse.core.springbuilder
+
+
+
+
+ org.springframework.ide.eclipse.boot.validation.springbootbuilder
+
+
+
+ org.springframework.ide.eclipse.core.springnature
org.eclipse.m2e.core.maven2Nature
org.eclipse.wst.common.project.facet.core.nature
org.eclipse.jdt.core.javanature
diff --git a/graphql-jpa-query-boot-starter/.classpath b/graphql-jpa-query-boot-starter/.classpath
index f871363c7..343f809b8 100644
--- a/graphql-jpa-query-boot-starter/.classpath
+++ b/graphql-jpa-query-boot-starter/.classpath
@@ -1,42 +1,47 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/graphql-jpa-query-boot-starter/.project b/graphql-jpa-query-boot-starter/.project
index 7beb87bfb..58102b1fd 100644
--- a/graphql-jpa-query-boot-starter/.project
+++ b/graphql-jpa-query-boot-starter/.project
@@ -20,8 +20,19 @@
+
+ org.springframework.ide.eclipse.core.springbuilder
+
+
+
+
+ org.springframework.ide.eclipse.boot.validation.springbootbuilder
+
+
+
+ org.springframework.ide.eclipse.core.springnature
org.eclipse.m2e.core.maven2Nature
org.eclipse.wst.common.project.facet.core.nature
org.eclipse.jdt.core.javanature
diff --git a/graphql-jpa-query-example/.project b/graphql-jpa-query-example/.project
index 82cdea2b9..ece02844d 100644
--- a/graphql-jpa-query-example/.project
+++ b/graphql-jpa-query-example/.project
@@ -20,8 +20,19 @@
+
+ org.springframework.ide.eclipse.core.springbuilder
+
+
+
+
+ org.springframework.ide.eclipse.boot.validation.springbootbuilder
+
+
+
+ org.springframework.ide.eclipse.core.springnature
org.eclipse.m2e.core.maven2Nature
org.eclipse.wst.common.project.facet.core.nature
org.eclipse.jdt.core.javanature
diff --git a/graphql-jpa-query-schema/.project b/graphql-jpa-query-schema/.project
index 3a017fc4f..9bb0cfaaa 100644
--- a/graphql-jpa-query-schema/.project
+++ b/graphql-jpa-query-schema/.project
@@ -20,8 +20,19 @@
+
+ org.springframework.ide.eclipse.core.springbuilder
+
+
+
+
+ org.springframework.ide.eclipse.boot.validation.springbootbuilder
+
+
+
+ org.springframework.ide.eclipse.core.springnature
org.eclipse.m2e.core.maven2Nature
org.eclipse.wst.common.project.facet.core.nature
org.eclipse.jdt.core.javanature
diff --git a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaExecutor.java b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaExecutor.java
index a50dd5f8d..24a82bbab 100644
--- a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaExecutor.java
+++ b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaExecutor.java
@@ -16,6 +16,7 @@
package com.introproventures.graphql.jpa.query.schema.impl;
+import java.util.Collections;
import java.util.Map;
import javax.transaction.Transactional;
@@ -62,10 +63,21 @@ public ExecutionResult execute(String query) {
@Override
@Transactional(TxType.SUPPORTS)
public ExecutionResult execute(String query, Map arguments) {
+
+ // Need to inject variables in context to support parameter bindings in reverse queries
+ Map context = Collections.singletonMap("variables", arguments);
+
+// ExecutionInput executionInput = ExecutionInput.newExecutionInput()
+// .query(query)
+// .variables(arguments)
+// .root(context)
+// .context(context)
+// .build();
+
if (arguments == null)
return graphQL.execute(query);
else
- return graphQL.execute(query, (Object) null, arguments);
+ return graphQL.execute(query, context, arguments);
}
}
diff --git a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/QraphQLJpaBaseDataFetcher.java b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/QraphQLJpaBaseDataFetcher.java
index 7a4f7a221..aacfd43b1 100644
--- a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/QraphQLJpaBaseDataFetcher.java
+++ b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/QraphQLJpaBaseDataFetcher.java
@@ -282,6 +282,11 @@ protected Predicate getPredicate(CriteriaBuilder cb, Root> from, From,?> pat
From,?> join = getCompoundJoin(path, argument.getName(), false);
Argument where = new Argument("where", argument.getValue());
+ Map variables = Optional.ofNullable(environment.getContext())
+ .filter(it -> it instanceof Map)
+ .map(it -> (Map) it)
+ .map(it -> (Map) it.get("variables"))
+ .orElse(Collections.emptyMap());
GraphQLFieldDefinition fieldDef = getFieldDef(
environment.getGraphQLSchema(),
@@ -290,7 +295,7 @@ protected Predicate getPredicate(CriteriaBuilder cb, Root> from, From,?> pat
);
Map arguments = (Map) new ValuesResolver()
- .getArgumentValues(fieldDef.getArguments(), Collections.singletonList(where), Collections.emptyMap())
+ .getArgumentValues(fieldDef.getArguments(), Collections.singletonList(where), variables)
.get("where");
return getWherePredicate(cb, from, join, new WherePredicateEnvironment(environment, arguments), where);
diff --git a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/JavaScalarsTest.java b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/JavaScalarsTest.java
index 075555c2f..127c0ef94 100644
--- a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/JavaScalarsTest.java
+++ b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/JavaScalarsTest.java
@@ -34,7 +34,7 @@ public class JavaScalarsTest {
@Test
public void long2LocalDateTime() {
//given
- Coercing coercing = JavaScalars.of(LocalDateTime.class).getCoercing();
+ Coercing,?> coercing = JavaScalars.of(LocalDateTime.class).getCoercing();
LocalDateTime localDateTime = LocalDateTime.of(2017, 02, 02, 12, 30, 15);
long input = localDateTime.toEpochSecond(ZoneId.systemDefault().getRules().getOffset(localDateTime));
@@ -58,7 +58,7 @@ public void long2LocalDateTime() {
@Test
public void string2LocalDateTime() {
//given
- Coercing coercing = JavaScalars.of(LocalDateTime.class).getCoercing();
+ Coercing,?> coercing = JavaScalars.of(LocalDateTime.class).getCoercing();
final String input = "2017-02-02T12:30:15";
//when
@@ -79,7 +79,7 @@ public void string2LocalDateTime() {
public void long2LocalDate() {
// given
- Coercing coercing = JavaScalars.of(LocalDate.class).getCoercing();
+ Coercing,?> coercing = JavaScalars.of(LocalDate.class).getCoercing();
LocalDateTime localDateTime = LocalDateTime.of(2017, 02, 02, 0, 0, 0);
long input = localDateTime.toEpochSecond(ZoneId.systemDefault().getRules().getOffset(localDateTime));
@@ -98,7 +98,7 @@ public void long2LocalDate() {
public void string2LocalDate() {
//given
- Coercing coercing = JavaScalars.of(LocalDate.class).getCoercing();
+ Coercing,?> coercing = JavaScalars.of(LocalDate.class).getCoercing();
final String input = "2017-02-02";
//when
diff --git a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/StarwarsQueryExecutorTests.java b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/StarwarsQueryExecutorTests.java
index 19d9790f3..50e992b71 100644
--- a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/StarwarsQueryExecutorTests.java
+++ b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/StarwarsQueryExecutorTests.java
@@ -126,6 +126,24 @@ public void queryManyToOneJoinById() {
assertThat(result.toString()).isEqualTo(expected);
}
+ @SuppressWarnings("serial")
+ @Test
+ public void queryManyToOneJoinByIdWithVariables() {
+ //given:
+ String query = "query($id: String!) { Humans { select { name, homePlanet, favoriteDroid(where: {id: {EQ: $id}}) { name} } } }";
+ Map variables = new HashMap() {{
+ put("id", "2001");
+ }};
+
+ String expected = "{Humans={select=[{name=Darth Vader, homePlanet=Tatooine, favoriteDroid={name=R2-D2}}]}}";
+
+ //when:
+ Object result = executor.execute(query,variables).getData();
+
+ //then:
+ assertThat(result.toString()).isEqualTo(expected);
+ }
+
@Test
public void queryOneToManyJoinByID() {
//given: