Skip to content

⚑️Build powerful, efficient GraphQL servers with Fastify, Prisma, Nexus & Jest! πŸš€ Jumpstart your project with this high-performance TypeScript starter!πŸ’»

License

Notifications You must be signed in to change notification settings

nimatra/Fastify-Prisma-Nexus-Graphql-Starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

The Ultimate High-Performance TypeScript Server Starter 🏎️

License: MIT Node.js Version GitHub Workflow Status Test Coverage GitHub Stars GitHub Forks

πŸš€ Welcome to the Fastify-Prisma-Nexus-GraphQL-Jest Boilerplate! πŸŽ‰

This boilerplate provides you with a solid foundation to build amazing and professional GraphQL servers using Fastify, Prisma, Nexus, GraphQL, and Jest!

πŸ“‹ Requirements

To get started, make sure you have the following installed:

Check the engines and dependencies sections in the package.json for the specific versions of required packages.

πŸ› οΈ Installation

Follow these simple steps to set up the project:

  1. Clone the repository: git clone https://github.com/nimatra/fastify-prisma-nexus-graphql-jest.git πŸ“¦
  2. Change to the project directory: cd fastify-prisma-nexus-graphql-jest πŸ“
  3. Install dependencies: yarn install or npm install 🧩
  4. Set up environment variables by creating a .env file in the project root, based on the provided .env.example file. πŸ”‘
  5. Update the prisma/schema.prisma file with your database connection details. πŸ—ƒοΈ
  6. Run database migrations: yarn migrate:dev or npm run migrate:dev 🚧
  7. Start the development server: yarn dev or npm run dev πŸš€

πŸ’‘ Bonus: You can use the included Docker Compose file in /dockers/db-compose.yml to quickly set up a local PostgreSQL database. 🐳

Now you're ready to build your next amazing GraphQL server! Let's get started! πŸŽ‰

🌟 Features

This boilerplate comes packed with a variety of features to help you kickstart your GraphQL server:

πŸ” Authentication

The project includes built-in authentication using Fastify, Passport, and bcryptjs. You can easily integrate your preferred authentication provider or extend the current implementation to suit your needs.

πŸ—ƒοΈ Migration

Effortlessly manage your database schema using Prisma migrations. This boilerplate includes scripts for running, resetting, and deploying migrations, ensuring that your database schema remains in sync with your code.

πŸ› οΈ Others

🧬 Sample Schema

The boilerplate comes with a sample schema that demonstrates how to define your GraphQL types and resolvers using Nexus. This schema covers the models listed below and includes relationships between them. You can easily customize the schema to match your application's needs.

The template includes sample code for the following models:

  • Users πŸ‘₯
  • Tasks πŸ“‹
  • Comments πŸ’¬
  • UserTasks πŸ‘€πŸ“‹
  • TaskRoles πŸ“Œ

prisma-erd-generator generates an informative ERD diagram that is helpful for developer discussions. πŸ“Š

🌱 Seeding Data into Production 🌱

To bootstrap your production database with initial data, you can use the provided seed file located in the prisma/seed.ts directory. Modify it to include your desired seed data and run the db:push script to populate your production database. πŸš€

πŸ§ͺ Test πŸ§ͺ

The boilerplate includes a comprehensive testing setup using Jest with a pre-configured jest.config.js file. You'll find sample tests for the included models in the tests directory. These tests cover various aspects of the application, such as resolvers, middleware, and utility functions. The custom configuration for Jest includes:

  • TypeScript support with the ts-jest preset.
  • A dedicated test environment, using Node.js.
  • Global setup and teardown scripts for test initialization and cleanup.
  • Test environment variables set to load from a separate .env.test file.

To run the tests, simply execute the test or test:all script. 🚦

Every test run will create a new test database and seed the test/seed.ts data into the database. It's recommended to use the Docker-based database. 🐳

πŸ“Š Test Coverage πŸ“Š

Keep track of your project's test coverage with Jest's built-in coverage reporting. The boilerplate is pre-configured to generate coverage reports when running the tests. You can view the coverage report in the coverage directory after running the tests. πŸ“ˆ

πŸ”„ Github Action πŸ”„

The included Github action, named "Run Tests for Modified Files", ensures high code quality by automatically running tests for modified files in your pull requests. The action is triggered when a pull request is opened, updated, or labeled on the main branch.

Here's what the action does:

  1. Runs on the latest Ubuntu environment.
  2. Sets up a PostgreSQL 15 service with a test database and user.
  3. Checks out your repository.
  4. Sets up Node.js with version 19 and caches the Yarn dependencies.
  5. Installs dependencies using the yarn install --frozen-lockfile command.
  6. Gets the list of modified files in the pull request with a .test.ts extension.
  7. Runs Jest tests only for the modified files, using the yarn test --findRelatedTests command.

The action makes use of environment variables to configure the test database connection. This ensures a seamless and efficient testing process for every commit to the repository. βœ…

🀝 Contributing 🀝

We welcome contributions to this open-source boilerplate! If you have any ideas or suggestions, please feel free to open an issue or submit a pull request. We'll review your changes and work with you to ensure that this boilerplate remains a top choice for developers building Fastify GraphQL servers. πŸ’‘

πŸ“œ License πŸ“œ

This project is licensed under the MIT License. See the LICENSE file for more information. πŸ“„

πŸ™Œ Acknowledgments πŸ™Œ

We'd like to thank the developers and maintainers of Fastify, Prisma, Nexus, GraphQL, and Jest for their excellent work on these libraries. This boilerplate wouldn't be possible without their efforts. πŸŽ‰

About

⚑️Build powerful, efficient GraphQL servers with Fastify, Prisma, Nexus & Jest! πŸš€ Jumpstart your project with this high-performance TypeScript starter!πŸ’»

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published