Boilerplate code for an Apollo Server with Typescript, TypeORM, Jest, Postgresql, Redis, and SendGrid.
This project provides a boilerplate codebase for building scalable and modular GraphQL APIs with Apollo Server. The boilerplate includes these features (which can be removed if desired)
- Basic user registration
- User registration through 3rd party OAuth providers
- Account email verification
- Login and session handling
GraphQL is self documenting, so for a full reference of the provided API, clone the project and run it locally with GraphQLPlayground (provided with the repo).
-
Make sure you have Postgresql and Redis installed on your local machine.
-
Fork or clone the repository
-
Run
yarn install
-
Make sure you have the following keys present in an
.env
file or as environmental variablesSENDGRID_API_KEY
(for sending emails)CODACY_PROJECT_TOKEN
(if you want to report testing coverage on a forked repo)SESSION_SECRET
(Used to secure session cookies)(TEST_)HOST
(your local (testing) host, i.e.https://localhost:4000
)GOOGLE_CLIENT_ID
your Google OAuth Client IDGOOGLE_CLIENT_SECRET
your Google OAuth Client SecretGOOGLE_AUTH_CALLBACK_URL
your application's OAuth callback url for Google to use
-
Run
yarn build && yarn start
(seepackage.json
for additional scripts)
The schema is divided into separate modules with the idea of being able to easily expand and add new modules to the overall system without needing to rewrite core functionality. All base system modules (such as authentication) can be found in the src/core
. These core modules provide functionality which new modules can reliably use. New modules can be structured however you like, but must have a top level folder (e.g. example-module
) with an index
file which exports { resolvers, typeDefs, permissions }
.
A GraphQL resolver map which corresponds to the exported typeDefs
The GraphQL type definitions for the new module. Any additions to the top level or core fields like Query
and Mutation
should extend the existing field like so: extend type Query {}
the GraphQL Shield permissions set for the new module. This should be an object matching the exported resolver map. A core set of rules can be found in src/rules
which can be imported by any modules permission set, or custom rules can be created. For more information on permission syntax, see the GraphQLShield documentation.
This project is not open to direct contributions at the moment, as it is still under heavy development. If you do find an issue or would like to raise a concern, please open an issue and I will address as soon as I can.