https://github.com/redis-field-engineering/redis-graphql
GraphQL Service for Redisearch
https://github.com/redis-field-engineering/redis-graphql
Last synced: about 1 month ago
JSON representation
GraphQL Service for Redisearch
- Host: GitHub
- URL: https://github.com/redis-field-engineering/redis-graphql
- Owner: redis-field-engineering
- License: other
- Created: 2021-12-20T19:30:10.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-23T20:04:35.000Z (almost 3 years ago)
- Last Synced: 2025-04-12T08:08:33.050Z (about 1 month ago)
- Language: Go
- Size: 7.73 MB
- Stars: 9
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GraphQL-Redis
A [GraphQL](https://graphql.org/) server backed by Redis
## Features
- Query Redis data using GraphQL
- Full text search on fields in Redis Data
- Numeric range queries
- Negative and optional matches
- Aggregate data for reporting
- Geographic matching
- Only minimal configuration required## How this works
The GraphQL server queries RediSearch for the search schema then dynamically builds the GraphQL schema.

### Data Formatting
Data is stored in a [Redis Hash data structure](https://redis.io/docs/manual/data-types/#hashes)
For example we have a list of gaming users and we want to be able to search these users by fields
#### user:jennifer82
|Field|Example Value|
|---|---|
|username|jennifer82|
|location|41.09822,120.74792|
|rating|591|
|playstyle|stationary,sniper|
|email|[email protected]|```
HSET user:jennifer82 username jennifer82 rating 591 email [email protected] playstyle stationary,sniper location 122.4194,37.7749
```### Create an Index on the fields you wish to search
```
FT.CREATE Gamers ON HASH PREFIX 1 user: SCHEMA username TEXT location GEO SORTABLE rating NUMERIC SORTABLE playstyle TAG email TAG
```Note: Please do not use ```:``` or ```-``` in the Index name. ```_``` is acceptable.
See [Tips and Tricks](./docs/SchemaTipsAndTricks.md) for more detailed information on creating a Redisearch schema
### Run the GraphQL server and point at the the Redis instance
```
./redis-graphql --redis-host localhost --redis-port 6379
```### View the auto generated documents in browser
http://localhost:8080/docs
### Run a query
```
curl -s -X POST -H "Content-Type: application/json" --data '{"query": "{ Gamers(username:\"jennifer82\") {username,email,rating}}"}' http://localhost:8080/graphql
{
"data": {
"Gamers": [
{
"email": "[email protected]",
"rating": 591,
"username": "jennifer82"
}
]
}
}
```See [Querying](./docs/Queries.md) and [Aggregations](./docs/Aggregations.md) for more detailed query examples
## Utilities
Example [Prometheus/Grafana Setup](./utils/grafana/README.md) is available