GraphQL Filter

Library to let the user filter through the results of a GraphQL query

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.github.aoudiamoncef
ArtifactId

ArtifactId

graphql-java-filter
Last Version

Last Version

1.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

GraphQL Filter
Library to let the user filter through the results of a GraphQL query
Project URL

Project URL

https://github.com/aoudiamoncef/graphql-java-filter
Project Organization

Project Organization

Gentics Software
Source Code Management

Source Code Management

https://github.com/aoudiamoncef/graphql-java-filter

Download graphql-java-filter

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.aoudiamoncef/graphql-java-filter/ -->
<dependency>
    <groupId>com.github.aoudiamoncef</groupId>
    <artifactId>graphql-java-filter</artifactId>
    <version>1.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.aoudiamoncef/graphql-java-filter/
implementation 'com.github.aoudiamoncef:graphql-java-filter:1.2.0'
// https://jarcasting.com/artifacts/com.github.aoudiamoncef/graphql-java-filter/
implementation ("com.github.aoudiamoncef:graphql-java-filter:1.2.0")
'com.github.aoudiamoncef:graphql-java-filter:jar:1.2.0'
<dependency org="com.github.aoudiamoncef" name="graphql-java-filter" rev="1.2.0">
  <artifact name="graphql-java-filter" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.aoudiamoncef', module='graphql-java-filter', version='1.2.0')
)
libraryDependencies += "com.github.aoudiamoncef" % "graphql-java-filter" % "1.2.0"
[com.github.aoudiamoncef/graphql-java-filter "1.2.0"]

Dependencies

compile (2)

Group / Artifact Type Version
com.graphql-java : graphql-java jar 15.0
commons-io : commons-io jar 2.7

test (4)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-engine jar 5.6.2
org.assertj : assertj-core jar 3.16.1
org.slf4j : slf4j-api jar 1.7.30
org.slf4j : slf4j-simple jar 1.7.30

Project Modules

There are no modules declared in this project.

GraphQL Filter

CircleCI Download Codacy Badge Known Vulnerabilities FOSSA Status License

Enhance your GraphQL API with filters.

Use this library to let the user filter through the results of a GraphQL query.

Getting Started

  1. Add Graphql Java filter to your project's dependencies:
   <dependency>
       <groupId>com.github.aoudiamoncef</groupId>
       <artifactId>graphql-java-filter</artifactId>
       <version>1.2.0</version>
   </dependency>

Live Demo

Here is an implementation of this library.

Try this query:

{
  nodes(filter: {
    schema: { is: vehicle },
    fields: {
      vehicle: {
        price: {
          lt: 2000000
        }
      }
    }
  }) {
    elements {
      fields {
        ... on vehicle {
          name
          price
        }
      }
    }
  }
}

Play around with the autocompletion to see whats possible.

Usage

Create your filter by implementing the Filter interface or by extending one of the predefined abstract filters. It is best to create your filter by composing the small predefined filters.

See AbstractFilterTest.java to see an example of how to integrate this library in your environment.

Overview

Interfaces

  • Filter The main Filter interface. Every filter implements this.
  • FilterField can be used to create filters that can easily be nested in other filters.
  • StartFilter is used to easily create the argument object for graphql-java

Helper filters

  • MainFilter A filter that does not filter directly and instead contains a collection of other filters.
  • StartMainFilter Same as above but additionally implements StartFilter.
  • MappedFilter Used to map a type into another type using another Filter
  • CommonFilters Provides common filters which can be used for all types. This includes these logical operations of filters: and, or and not.

Predefined filters

The following filters can be used to filter primitive types: BooleanFilter, DateFilter, NumberFilter, StringFilter.

Examples

See NodeFilter.java as an example filter implementation.

Versions

Version
1.2.0
1.1.1