Skip to content

Boilerplate for building a GraphQL API using Apollo Server 2, Webpack4, ESLint and more

Notifications You must be signed in to change notification settings

TAnas0/Apollo-Server-Boilerplate

Repository files navigation

Commitizen friendly

Please note that this is Work In Progress. Feel free to open issues, contribute or give feedback.

Requirements:

  • Docker
  • Docker Compose
  • Prisma CLI (npm install -g prisma)
  • Node and NPM

Quick start

  1. Install dependencies: npm install
  2. Launch the Postgres database and Prisma server: docker-compose up -d
  3. Deploy your models to Prisma and generate the client: prisma generate && prisma deploy
  4. Run the API for development: npm run dev
  5. Access the playground of your Graphql API at http://localhost:4000

Features

  • Prisma as an ORM
  • GraphQL Modules
  • Authentication: using GraphQL Shield or as a GraphQL module

GraphQL Modules

The backend is organized into GraphQL modules More information in this Medium post

Each module merges its types and resolvers in order to export a GraphQLModule instance. These modules are then imported and merged into a single GraphQLModule module in the file src/api/modules/index.js. This object holds, among others, the schema and context which are fed to the ApolloServer instance in src/api/index.js

GraphQL modules offers extensibility of your code base and forces/helps you organize your SDL types by domain/feature rather than by type.

Prisma

TODO

Branches

This project contains two more branches with additional features compared to the backend:

  • graphql-shield: authentication implemented using the GraphQL shield package
  • nuxt-frontend: minimal frontend built using Nuxt with Auth0 authentication configured. Its purpose is to give a working example of the front side of authentication

Contributing

In order to keep the graphql-shield and nuxt-frontend branches in sync with the master branch, all modifications related to the backend must be implemented first in the master branch then merged into the branch in question. Only then can additional modifications of the backend, specific to that branch, be added.

Please use the alias npm run commit for Commitizen friendly commits.

Todos and roadmap

NodeJS best practices checklist:

  • 1.5 Use environment aware, secure and hierarchical config

Using the [node-config] package with Webpack. See

  • Clean datasources
  • Documentation and references
  • GrahQL CLI scaffolding support

About

Boilerplate for building a GraphQL API using Apollo Server 2, Webpack4, ESLint and more

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published