GithubHelp home page GithubHelp logo

doc22940 / bootstrap-react-apollo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from graphile/bootstrap-react-apollo

1.0 1.0 0.0 1.64 MB

[WIP] A bootstrap for using PostGraphile with React and Apollo.

JavaScript 61.95% HTML 0.72% CSS 0.56% Shell 3.95% PLpgSQL 30.50% TSQL 2.33%

bootstrap-react-apollo's Introduction

PostGraphile Boilerplate - React & Apollo

๐ŸšจTemporarily unmaintained๐Ÿšจ This repo is currently not maintained and is out of date - Please make sure that you update the dependancies in your copy of these examples. For an up to date example, see the Graphile Starter. We rely on sponsorship from the Graphile community to continue our work in Open Source. By donating to our GitHub Sponsors or Patreon fund, you'll help us spend more time on Open Source, and this repo will be updated quicker. Thank you to all our sponsors ๐Ÿ™Œ

This repository will help you get started with PostGraphile quickly. It's currently a work in progress, but despite this it should be a good jumping-off point.

Goals:

Database:

  • Basic setup script to setup/reset database (yarn setup)
  • Basic migrations system with migrate/rollback commands (yarn db:migrate:dev / yarn db:rollback:dev)
  • Migration templating to support different role names
  • Dump database after every migration to ensure everyone's running the same

Server:

  • PostGraphile server, with Express
  • Development: GraphiQL (enhanced)
  • Development: watch DB for changes, no need to restart server
  • Development: maintain up-to-date GraphQL schema file (./data/schema.graphql)
  • Session-based authentication (cookies)
  • Database migrations framework (preferably flexible)
  • User accounts (registration, login)
  • OAuth support (login with GitHub, Twitter, Facebook, ... via Passport.js)
  • Double-submit token to avoid CSRF
  • Background worker
  • Server-side rendering (SSR)
  • Test suite

Client:

  • React app
  • Development mode has React hot loading
  • react-apollo GraphQL client
  • Send double-submit token (if present) with GraphQL requests (window.CSRF_TOKEN)
  • Routing via React Router
  • Register/login with social providers
  • Register with username/password
  • Login with username/password
  • Storybook for React component previews
  • Test suite
  • Automatic bundle splitting

General:

  • JavaScript linting
  • GraphQL linting
  • Prettier for code formatting
  • Ignore relevant files in GitHub PRs (gitattributes linguist-generated=true)
  • Production-optimised bundle

Deployment:

  • Procfile for Heroku
  • Dockerfile or similar

Layout

The project is split into the following folders:

  • /db - everything related to the database: migrations, unit tests, etc
  • /data - generated data, such as the GraphQL and database schema dumps
  • /client - everything related to the web browser: the react components, routes, etc
  • /server - everything related to running the server: the middlewares, PostGraphile configuration, SSR, integration tests, etc
  • /tasks - background tasks run by Graphile Worker

We currently use a root-level package.json between all of them. In future we might take a monorepo approach using yarn workspaces, but for now we figured simplicity wins.

Tools

We use the following tools to make our life easier

  • PostGraphile (obviously) to turn our database into a GraphQL API, and to output the GraphQL schema for other tools
  • Apollo Client to consume this GraphQL API and manage caching
  • React for rendering
  • Webpack to bundle everything up
  • ESLint for powerful linting and autocorrection
  • Prettier for consistent code formatting
  • Express.js to implement our server
  • db-migrate for performing migrations
  • graphile-worker for running background tasks

Getting Started

# Install dependencies:
yarn

# Create and configure database
yarn setup

# Start everything
yarn start

Then load http://localhost:5678

{TODO}

Environmental Variables

This package is configured through environmental variables. yarn setup creates a .env file for you which you can then customise.

Conventions

See db/CONVENTIONS.md.

{TODO}

Deploying

{TODO}

Database layout

  • public - this is where extensions are installed to, it also contains the migrations table. We will typically not add anything to this schema ourselves.
  • app_public - contains everything to be exposed over GraphQL
  • app_hidden - same permissions as app_public, but will not be exposed over GraphQL
  • app_private - database-owner-only storage, for storing things users should never have direct access to, like bcrypt password hashes.

Why the /data folder?

ESLint needs an up to date schema dump to correctly validate GraphQL queries.

When developing, you want to ensure that your database is identical to your colleagues - differences in /data/schema.sql indicate that your databases differ.

When performing Code Review, it's important to see the changes to both the database and the GraphQL schemas to ensure no breaking changes are introduced.

bootstrap-react-apollo's People

Contributors

benjie avatar dependabot[bot] avatar jemgillam avatar nicolad avatar plitzenberger avatar singingwolfboy avatar snyk-bot avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.