GraphQL + Rails @defer / @stream

A demo of GraphQL subscriptions and "exploratory" @defer and @stream directives with Ruby on Rails.

This uses a WIP branch of graphql-ruby and graphql-streaming

Stream & Defer

stream-defer

Subscription

subscription

About

  • Setup
    • install Ruby 2.2 or greater
    • $ gem install bundler (install Bundler, Ruby's package manager with)
    • $ bundle install (install this project's dependencies from Gemfile)
    • $ bundle exec rake db:create db:seed (setup the database and add seed data)
    • $ bundle exec rails server (start the development server)
    • $ open http://localhost:3000/ (visit the app)
  • ActionCable transports
    • Send GraphQL with ActionCable, Rails 5's new websocket library
    • http://localhost:3000/action_cable_transport
    • Server: app/channels/graphql_channel.rb
    • Client: GraphQLChannel from graphql-streaming
  • Transfer-Encoding: chunked transport