/create-graphql-app

Boilerplate for a monorepo with a graphql server

Primary LanguageTypeScript

Create Graphql App

Boilerplate for quick scaffolding of a Typescript GraphQL Apollo server in a monorepo, with automatic typescript type generation via the Graphql code generator and code formatting via prettier.

That GraphQL schema is stitched together from multiple microservices in a gateway using Apollo Federation. These microservices are bootstrapped using Lerna

Usage

Fork/clone the repo and cd into the root folder:

nvm use
yarn

cd graphql
yarn
yarn dev-all-services

This should start all the graphql microservices. Then, in another terminal:

cp .env.test .env

This creates the .env file you need for the GraphQL gateway to know where each microservice lives. Finally, run:

yarn dev

This should get the gateway running, and you will be able to see the playground on http://localhost:3010 🚀

The project will auto recompile and reload on every code change in any microservice or the gateway itself. Give it a whirl!

This is where the web project connects, using Apollo Client. You may start that one by going into its directory and running yarn dev, then hitting http://localhost:3011 to see some sample UI.

Testing

There is a sample test for the sample resolver using Jest to get you going; substitute your own and run tests with:

yarn test # single run all the tests

yarn test --watch # auto-reloading run of relevant tests

Deployment

Since my projects nowadays are so commonly deployed to Google App Engine, there's some minimal configuration to deploy the graphql server as the default service of an App Engine project. Substitute your own and it should "just work". Well, if you have deployed something to google app engine before, or have setup Google Cloud Build.

Contributing

This is by no means the way to get a project like this started. It's not the perfect way to write your schemas, nor the perfect way to write your resolvers, nor the perfect way to generate your types. It is the best way I know how to do it, and would heartily welcome any help and input to make it even better!