All Projects → 2color → fastify-graphql-nexus-prisma

2color / fastify-graphql-nexus-prisma

Licence: other
GraphQL Server with Fastify, Mercurius, Prisma, and Nexus

Programming Languages

typescript
32286 projects
assembly
5116 projects
shell
77523 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to fastify-graphql-nexus-prisma

mrapi
A framework for rapid development of API or DAL applications.
Stars: ✭ 20 (-84%)
Mutual labels:  fastify, prisma
fullstack-graphql-app
An opinionated fullstack GraphQL monorepo boilerplate using pnpm, Turborepo, Prisma, GraphQL Yoga 2, Fastify, Nextjs, urql, and React
Stars: ✭ 90 (-28%)
Mutual labels:  fastify, prisma
fastify-prisma
Basic Fastify app using Prisma as an ORM
Stars: ✭ 26 (-79.2%)
Mutual labels:  fastify, prisma
fastify-cron
Run cron jobs alongside your Fastify server 👷
Stars: ✭ 32 (-74.4%)
Mutual labels:  fastify
nest-rest-typeorm-boilerplate
🍱 backend with nest (typescript), typeorm, and authentication
Stars: ✭ 142 (+13.6%)
Mutual labels:  fastify
Ararat
Ararat is the next-generation container/virtual machine control panel. It is your one-stop shop for single application containers, full system containers, and KVM instances
Stars: ✭ 21 (-83.2%)
Mutual labels:  prisma
fastify-vue
A nuxt.js fastify plugin
Stars: ✭ 27 (-78.4%)
Mutual labels:  fastify
prisma-ecommerce
No description or website provided.
Stars: ✭ 44 (-64.8%)
Mutual labels:  prisma
fastify-postgres
Fastify PostgreSQL connection plugin
Stars: ✭ 144 (+15.2%)
Mutual labels:  fastify
svelte-ssr-example
Svelte SSR example
Stars: ✭ 43 (-65.6%)
Mutual labels:  fastify
prismabuilder.io
Build your Prisma schema visually in this easy-to-use web based tool
Stars: ✭ 161 (+28.8%)
Mutual labels:  prisma
cms30
🙌 #CMS30 | Free 30 CMS templates
Stars: ✭ 23 (-81.6%)
Mutual labels:  prisma
react-chat-app
A real-time chat application with Node.js, Prisma, GraphQL, Next.js, React.js and Apollo.
Stars: ✭ 61 (-51.2%)
Mutual labels:  prisma
fastify-loader
The route loader for the cool kids!
Stars: ✭ 17 (-86.4%)
Mutual labels:  fastify
fastify-accepts
Add accepts parser to fastify
Stars: ✭ 51 (-59.2%)
Mutual labels:  fastify
nikolovlazar.com
My personal site's repo built using Next.js, Chakra UI, MDX, Prisma, PlanetScale.
Stars: ✭ 126 (+0.8%)
Mutual labels:  prisma
danestves.com
✨ My portfolio built with Remix, Tailwind, Prisma, and Fly.io.
Stars: ✭ 9 (-92.8%)
Mutual labels:  prisma
fastify-metrics
📊 Fastify plugin that integrates metrics collection and dispatch to statsd
Stars: ✭ 62 (-50.4%)
Mutual labels:  fastify
fullstack-nextjs-ecommerce
Fullstack Next.js E-Commerce made with NextAuth + Prisma, Docker + TypeScript + React Query + Stripe + Tailwind Sentry and much more 🛒
Stars: ✭ 524 (+319.2%)
Mutual labels:  prisma
fastify-env
Fastify plugin to check environment variables
Stars: ✭ 129 (+3.2%)
Mutual labels:  fastify

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

⚠️ Warning!

This repository is no longer maintained and some of the packages may be out of date.

Nonetheless, there are two patterns in here that I think are still really useful for anyone building a GraphQL API:

  • Code-first GraphQL schema construction. I still think this is the way to go if you like type safety and TypeScript. I would probably switch Nexus and nexus-prisma for Pothos. You can learn about this Pothos in this talk from the Pothos creator. The main benefit I see of Pothos over Nexus is simplicity and more active development.
  • Observability & Tracing: having visibility into the health of your GraphQL API is essential, as I demo in this talk.

Intro

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
  • nexus-prisma: Plugin that allows projecting types from your Prisma schema to the GraphQL schema
  • 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.
  • OpenTelemetry Tracing: An observability framework for cloud-native software. Configured to trace HTTP requests, GraphQL resolution and Prisma queries.
  • Altair GraphQL: GraphQL Web Client (similar to GraphQL Playground and Gr)

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

Tracing

The GraphQL server is instrumented with OpenTelemetry tracing.

Here's how it works:

  • @autorelic/fastify-opentelemetry is a plugin that creates a root span for every fastify HTTP request and allows creating child spans using request.openTelemetry()
  • @opentelemetry/instrumentation-graphql provides auto-instrumentation for GraphQL execution
  • Additional spans for Prisma Client queries are created in the GraphQL resolvers through context.request.openTelemetry().

Example trace

trace example

Viewing traces in local development with Jaeger

You can view traces in local development using Jaeger.

  1. Start jaeger by going into the tracing folder and running docker compose up -d
  2. In your .env file set JAEGER_EXPORTER="true"
  3. Open the Jaeger UI: http://localhost:16686/
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].