tsoisauce / rails-graphql-persisted-queries

Persist GraphQL queries to utilize HTTP caching.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rails GraphQL Persisted Queries

Ruby on Rails project to demo HTTP caching strategies. Persisted queries allows Apollo Client to refernce cached queries with a hash. Apollo Client will attempt to make a query with a GET method before attempting a POST request for the data.

Note: master branch will not utalize active record to persist data. All data will be static for demostration purposes.

Installation

  • Bundle install: bundle
  • Webpack install: rails webpacker:install
  • Yarn install: yarn
  • GraphQL install: rails generate graphql:install

GraphiQL

Make sure the following is included in app/assets/config/manifest.js

//= link graphiql/rails/application.js
//= link graphiql/rails/application.css

Adding new Type Definitions with GraphQL Generator

rails g graphql:object <object-name>

This will generate Type Defition to describe the shape of your data in app/graphql/types/<object-name>_type.rb

Run Server

To start Rails server: rails s

visit localhost:3000/graphiql for GraphiQL visit localhost:3000 for React App

About

Persist GraphQL queries to utilize HTTP caching.


Languages

Language:Ruby 71.4%Language:JavaScript 15.6%Language:HTML 11.2%Language:CSS 1.8%