Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GraphQL Query for JPA Entity Model
[![Maven Central](https://img.shields.io/maven-central/v/com.introproventures/graphql-jpa-query.svg)](https://mvnrepository.com/artifact/com.introproventures/graphql-jpa-query)
[![Jitpack.io](https://jitpack.io/v/introproventures/graphql-jpa-query.svg)](https://jitpack.io/#introproventures/graphql-jpa-query)

This library uses [graphql-java 6.0](https://github.com/andimarek/graphql-java) to derive and build the GraphQL schema from JPA Entity Schema provided by entity classes.
This library uses [graphql-java 9.4](https://github.com/andimarek/graphql-java) to derive and build the GraphQL schema from JPA Entity Schema provided by entity classes.

It implements a schema builder to generate GraphQL Schema using JPA EntityManager with JPA Query Data Fetchers that transform GraphQL queries into JPA queries with flexible type safe criteria expressions and user-friendly SQL query syntax semantics i.e. query by page, , where criteria expressions, select, order by etc.

Expand Down
4 changes: 2 additions & 2 deletions graphql-jpa-query-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query</artifactId>
<artifactId>graphql-jpa-query-dependencies</artifactId>
<version>0.3.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
<relativePath>../graphql-jpa-query-dependencies</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
4 changes: 2 additions & 2 deletions graphql-jpa-query-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query</artifactId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.3.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

<dependencies>
Expand Down
51 changes: 51 additions & 0 deletions graphql-jpa-query-build/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-dependencies</artifactId>
<version>0.3.8-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-dependencies</relativePath>
</parent>
<artifactId>graphql-jpa-query-build</artifactId>
<packaging>pom</packaging>

<dependencyManagement>
<dependencies>

<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>Brussels-SR6</version>
<type>pom</type>
<scope>import</scope>
</dependency>

</dependencies>

</dependencyManagement>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</project>
56 changes: 56 additions & 0 deletions graphql-jpa-query-dependencies/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query</artifactId>
<version>0.3.8-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>graphql-jpa-query-dependencies</artifactId>
<packaging>pom</packaging>

<properties>
<graphql-java.version>9.4</graphql-java.version>
<hibernate-jpa-2.1-api.version>1.0.0.Final</hibernate-jpa-2.1-api.version>
</properties>

<dependencyManagement>
<dependencies>

<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>${graphql-java.version}</version>
</dependency>

<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>${hibernate-jpa-2.1-api.version}</version>
</dependency>

<dependency>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-annotations</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-schema</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>

</dependencyManagement>

</project>
4 changes: 2 additions & 2 deletions graphql-jpa-query-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query</artifactId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.3.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

<properties>
Expand Down
109 changes: 55 additions & 54 deletions graphql-jpa-query-schema/pom.xml
Original file line number Diff line number Diff line change
@@ -1,66 +1,67 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>graphql-jpa-query-schema</artifactId>
<name>graphql-jpa-query-schema</name>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>graphql-jpa-query-schema</artifactId>
<name>graphql-jpa-query-schema</name>

<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query</artifactId>
<version>0.3.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>

<dependencies>
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.3.8-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

<dependency>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-annotations</artifactId>
</dependency>
<modelVersion>4.0.0</modelVersion>

<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
</dependency>
<dependencies>

<dependency>
<groupId>org.atteo</groupId>
<artifactId>evo-inflector</artifactId>
</dependency>
<dependency>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-annotations</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
</dependency>

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.atteo</groupId>
<artifactId>evo-inflector</artifactId>
</dependency>

<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>javax.interceptor</groupId>
<artifactId>javax.interceptor-api</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
</dependency>

<dependency>
<groupId>javax.interceptor</groupId>
<artifactId>javax.interceptor-api</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public Object get(DataFetchingEnvironment environment) {
environment.getFragmentsByName(),
environment.getExecutionId(),
environment.getSelectionSet(),
environment.getFieldTypeInfo()
environment.getFieldTypeInfo(),
environment.getExecutionContext()
)).orElse(environment);

queryField = new Field(fieldName, field.getArguments(), recordsSelection.get().getSelectionSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ private GraphQLFieldDefinition getObjectField(Attribute attribute) {

if (type instanceof GraphQLOutputType) {
List<GraphQLArgument> arguments = new ArrayList<>();
DataFetcher dataFetcher = new PropertyDataFetcher<>(attribute.getName());
DataFetcher dataFetcher = PropertyDataFetcher.fetching(attribute.getName());

// Only add the orderBy argument for basic attribute types
if (attribute instanceof SingularAttribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import graphql.language.FloatValue;
import graphql.language.IntValue;
import graphql.language.Node;
import graphql.language.NodeVisitor;
import graphql.language.ObjectField;
import graphql.language.ObjectValue;
import graphql.language.SelectionSet;
Expand All @@ -78,6 +79,8 @@
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLSchema;
import graphql.schema.GraphQLType;
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;

/**
* Provides base implemetation for GraphQL JPA Query Data Fetchers
Expand Down Expand Up @@ -318,7 +321,8 @@ protected Predicate getWherePredicate(CriteriaBuilder cb, Root<?> root, From<?,
environment.getFragmentsByName(),
environment.getExecutionId(),
environment.getSelectionSet(),
environment.getFieldTypeInfo()
environment.getFieldTypeInfo(),
environment.getExecutionContext()
), new Argument(Logical.AND.name(), whereValue)
);
}
Expand Down Expand Up @@ -420,7 +424,8 @@ private PredicateFilter getPredicateFilter(ObjectField objectField, DataFetching
environment.getFragmentsByName(),
environment.getExecutionId(),
environment.getSelectionSet(),
environment.getFieldTypeInfo()
environment.getFieldTypeInfo(),
environment.getExecutionContext()
),
new Argument(objectField.getName(), argument.getValue()), argument.getValue() );

Expand All @@ -444,7 +449,8 @@ public ArgumentEnvironment(DataFetchingEnvironment environment, String argumentN
environment.getFragmentsByName(),
environment.getExecutionId(),
environment.getSelectionSet(),
environment.getFieldTypeInfo()
environment.getFieldTypeInfo(),
environment.getExecutionContext()
);
}
}
Expand All @@ -465,7 +471,8 @@ public WherePredicateEnvironment(DataFetchingEnvironment environment, GraphQLFie
environment.getFragmentsByName(),
environment.getExecutionId(),
environment.getSelectionSet(),
environment.getFieldTypeInfo()
environment.getFieldTypeInfo(),
environment.getExecutionContext()
);
}
}
Expand Down Expand Up @@ -821,6 +828,18 @@ public List<Comment> getComments() {
public boolean isEqualTo(Node node) {
return node instanceof NullValue;
}

@Override
public TraversalControl accept(TraverserContext context, NodeVisitor visitor) {
// TODO Auto-generated method stub
return null;
}

@Override
public Value deepCopy() {
// TODO Auto-generated method stub
return null;
}
}


Expand Down
Loading