Skip to content

qubitam/graphql-rails-blog

Repository files navigation

GraphQL Rails Blog

This application can be used as starter kit if you want to get started building an app with Rails, React, and GraphQL. This is a simple blog engine using ordinary features which can be found in most web applications.

Technologies

Frontend

  • React - A JavaScript library for building user interfaces. It introduces many great concepts, such as, Virtual DOM, Data flow, etc.
  • Babel - Babel is a JavaScript compiler which allows you to use next generation, ES6/ES7, JavaScript... today.
  • Sass - Sass is an extension of CSS, adding nested rules, variables, mixins, selector inheritance, and more.
  • Redux - Redux is a predictable state container for JavaScript apps
  • Redux Form - A Higher Order Component using react-redux to keep form state in a Redux store.
  • Apollo - A flexible, fully-featured GraphQL client for every platform.
  • Webpack 2 (with hot reloading) - webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser. Yet it is also capable of transforming, bundling, or packaging just about any resource or asset.
  • ESlint - ESlint is a pluggable linting utility for JavaScript, and JSX.

Backend

  • Ruby 2.3
  • Rails 5
  • Devise - Devise is a flexible authentication solution for Rails based on Warden.
  • Active admin - Active Admin is a Ruby on Rails plugin for generating administration style interfaces.
  • GraphQL-Ruby - GraphQL-Ruby is a Ruby implementation of GraphQL.
  • GraphQL-batch - GraphQL-batch is a query batching executor for the graphql gem.
  • Graphiql - Graphiql is an in-browser IDE for exploring GraphQL.
  • Rack CORS - Rack Middleware for handling Cross-Origin Resource Sharing (CORS), which makes cross-origin AJAX possible.
  • Optics Agent - Optics Agent for GraphQL Monitoring
  • SQLite3 for development and PostgreSQL for production.

Features

  • CRUD (create / read / update / delete) on posts
  • Creating comments on post page
  • Pagination on posts listing
  • Searching on posts
  • Authentication with Devise and authorizations (visitors, users, admins)
  • Creating user account
  • Update user profile and changing password
  • Setup dev tools
  • Application ready for production

GraphQL Using

  • Queries et mutations
  • FetchMore for pagination
  • Integrating with Redux and updating store
  • Optimistic UI
  • Colocate data / component with fragments
  • Validation management and integration with Redux Form
  • Authentication and authorizations
  • Protect queries and mutations on GraphQL API
  • Batching of SQL queries side backend

Prerequisites

  • Ruby 2.3
  • Node.js v6 or newer + Yarn package manager
  • SQLite3

Getting Started

  • Install Bundler

        $ gem install bundler
    
  • Checkout the graphql-rails-blog git tree from Github

        $ git clone https://github.com/MatthieuSegret/graphql-rails-blog.git
        $ cd graphql-rails-blog
        graphql-rails-blog$
    
  • Run Bundler to install/bundle gems needed by the project:

        graphql-rails-blog$ bundle
    
  • Create the database:

        graphql-rails-blog$ rails db:migrate
    
  • Load sample records:

        graphql-rails-blog$ rails db:seed
    
  • Run the Rails server in development mode

        graphql-rails-blog$ rails server
    
  • Run Yarn to install javascript package in other terminal:

        graphql-rails-blog$ cd client
        graphql-rails-blog/client$ yarn
    
  • Start client in development mode. You should be able to go to http://localhost:8080 :

        graphql-rails-blog/client$ npm start
    

Next step

  • Upgrade to last version of Apollo. Until now I had to downgrade to version 0.5.21 because of a bug on updatequeries (apollographql/apollo-client#1129)
  • Use query batching in Apollo. Until now GraphQL-Ruby does not support this functionality in a simple way
  • Parallelism in GraphQL-Ruby

Screens

Listing posts

Listing posts

Creating comments

Creating comments

Post page

Post page

License

MIT © Matthieu Segret

About

Blog App built with Rails 5, React and GraphQL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 57.4%
  • Ruby 39.9%
  • CSS 1.4%
  • Other 1.3%