Giter Club home page Giter Club logo

fastify-graphql-nexus-prisma's Introduction

GraphQL Server with Fastify, Mercurius, Prisma, and Nexus Example

This repo shows how to build a GraphQL server with TypeScript and the following technologies:

  • Fastify: Fast and low overhead web framework, for Node.js
  • Mercurius: GraphQL adapter for Fastify
  • Nexus: Declarative, Code-First GraphQL Schemas for JavaScript/TypeScript
  • Prisma: Next-generation ORM for type-safe interaction with the database
  • PostgreSQL: powerful, open source object-relational database system with over 30 years of active development.
  • Sentry: an error tracking and monitoring tool.
  • Altair GraphQL: GraphQL Web Client (similar to GraphQL Playground)

The project is written in TypeScript and attempts to maintain a high degree of type-safety by leveraging Prisma and GraphQL.

Play with a deployed version of this API: https://fastify-prisma.up.railway.app/altair

Deploy it! ๐Ÿšข

Deploy on Railway ๐ŸšŠ

DB Schema

The database schema is defined using the Prisma schema which defines 3 models:

  • User
  • Post
  • Comment

GraphQL schema

The GraphQL schema is defined with Nexus using the code-first approach.

The relevant files are:

Getting started

Prerequisites

  • A PostgreSQL DB

Steps

  1. clone repo
  2. create .env file and define DATABASE_URL and SENTRY_DSN
  3. npm install
  4. npm run migrate:dev to run shcema migrations with Prisma Migrate
  5. npm run dev to start dev server and run the API

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.