Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gentics/graphql-java-filter
GraphQL Filter Library for GraphQL-Java
https://github.com/gentics/graphql-java-filter
graphql graphql-java
Last synced: 9 days ago
JSON representation
GraphQL Filter Library for GraphQL-Java
- Host: GitHub
- URL: https://github.com/gentics/graphql-java-filter
- Owner: gentics
- License: apache-2.0
- Created: 2018-02-23T14:42:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-10T10:42:06.000Z (7 months ago)
- Last Synced: 2024-05-01T22:47:59.456Z (7 months ago)
- Topics: graphql, graphql-java
- Language: Java
- Homepage:
- Size: 150 KB
- Stars: 13
- Watchers: 20
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[![](https://jitpack.io/v/gentics/graphql-java-filter.svg)](https://jitpack.io/#gentics/graphql-java-filter)
# GraphQL Filter
Enhance your GraphQL API with filters.Use this library to let the user filter through the results of a GraphQL query.
## Live Demo
[Here is an implementation of this library.](https://demo.getmesh.io/api/v1/demo/graphql/browser)Try this query:
```graphql
{
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](src/test/java/com/gentics/graphqlfilter/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](src/test/java/com/gentics/graphqlfilter/filter/NodeFilter.java) as an example filter implementation.