/redi2hack

Primary LanguageJavaMIT LicenseMIT

Realtime GraphQL using Redis Streams, and Redis Search

Showcases how to use Realtime GraphQL using Redis Streams and real-time search usingRedis Searchin Java

Previews

GraphQL playground tab3

image

GraphQL playground tab1

image

Start Redis and the Spring Boot Application in local dev env

Prerequisites:

  1. Start the Docker Compose application:

    cd redi2hack
    docker-compose up
    
  2. Run the Spring Boot app to build the application.

    ./mvnw clean -Dspring-boot.run.profiles=local spring-boot:run
    
  3. Goto: http://localhost:8080/playground

Architecture

Highlevel diagram

GraphQL is supported using Spring Boot which is backed by Redis enterprise data store.

archi-1

Dataflow diagram

The data flows from left to right - from GraphQL->Redis and Redis->GraphQL.

archi-2

  • createCustomer, updateCustomer, and deleteCustomer GraphQL mutations use Redis hash and stream data to store the state and push the events.

  • subscribeEvents (GraphQL subscription) uses Redis Stream to fetch all customer events or the latest customer events.

  • searchCustomers GraphQL query usesRedis Searchto search customers.

  • customers and findCustomer use Redis Hash to find the all or a particular customer.

How it works

This project shows how to use GraphQL Subscription to push event data from the server using Redis Streams and support real-time search using Redis Search.

  • RediStreams: to capture all the customer events
  • Redis Search: to support search customer capabilities
  • RediHash: to store customer data
  • GraphQL:
    • Subscription: to push real time customer events
    • Mutation: to create/update/delete the customer state
    • Query: to query/search customer information
  1. Goto: redi2hack.herokuapp.com

Note: The app comes with the necessary sample code to follow.

Deployment

To make deploys work, you need to create free account in https://redislabs.com/try-free/