GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Pasi-D/serverless-graphql-api: Serverless GraphQL API with Apollo, Prisma & Pothos

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
prisma
prisma
 
 
src
src
 
 
.env.dist
.env.dist
 
 
.eslintignore
.eslintignore
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
.nvmrc
.nvmrc
 
 
.prettierignore
.prettierignore
 
 
.prettierrc
.prettierrc
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
serverless.ts
serverless.ts
 
 
tsconfig.json
tsconfig.json
 
 
tsconfig.paths.json
tsconfig.paths.json
 
 
webpack.config.js
webpack.config.js
 
 

Repository files navigation

Serverless GraphQL API with Prisma + Apollo

This project is a derivative of aws-nodejs-typescript template from the Serverless framework. Instead of using esbuild it uses webpack.

For detailed instructions, please refer to the documentation.

Installation/deployment instructions

Depending on your preferred package manager, follow the instructions below to deploy your project.

Requirements: NodeJS lts/fermium (v.14.15.0). If you're using nvm, run nvm use to ensure you're using the same Node version in local and in your lambda's runtime.

Create a copy of .env.dist

cp .env.dist .env

Update the .env with appropriate values

Using NPM

  • Run npm i to install the project dependencies
  • Run npm run deploy to deploy this stack to AWS
  • Run npm run remove to destroy the Lambda deployed

Using Yarn

  • Run yarn to install the project dependencies
  • Run yarn deploy to deploy this stack to AWS
  • Run yarn remove to destroy the Lambda deployed

Test your service

This repository contains a GraphQL API that can be run locally. It can be explored via Apollo Studio.

⚠️ As is, this template, once deployed, opens a public endpoint within your AWS account resources. Anybody with the URL can actively execute the API Gateway endpoint and the corresponding lambda. You should protect this endpoint with the authentication method of your choice.

Locally

In order to test the hello function locally, run the following command:

  • npm run dev if you're using NPM
  • yarn dev if you're using Yarn

Project structure

The project code base is mainly located within the src folder. This folder is divided in:

  • functions - containing code base and configuration for your lambda functions
  • libs - containing shared code base between your lambdas
.
├── src
│   ├── functions                  # Lambda configuration and source code folder
│   │   ├── api
│   │   │   ├── handler.ts         # lambda source code
│   │   │   ├── index.ts           # lambda Serverless configuration
│   │   │   └── context.ts         # GraphQL context
│   │   │   └── db.ts              # Common database layer access (Prisma instance)
│   │   │   └── schema
│   │   │         └── builder.ts   # Schema builder
│   │   │         └── index.ts     # GraphQL schema
│   │   │   
│   │   └── index.ts               # Import/export of all lambda configurations
│   │
│   └── libs                       # Lambda shared code
│       └── apiGateway.ts          # API Gateway specific helpers
│       └── handlerResolver.ts     # Sharable library for resolving lambda handlers
│       └── lambda.ts              # Lambda middleware
│
├── package.json
├── serverless.ts               # Serverless service file
├── tsconfig.json               # Typescript compiler configuration
└──tsconfig.paths.json         # Typescript paths

Size Comparison between esbuild version and webpack

Webpack Esbuild
Bundle Size ~16.0KB ~44.0KB

3rd party libraries

  • @serverless/typescript - provides up-to-date TypeScript definitions for your serverless.ts service file
  • fork-ts-checker-webpack-plugin - Type checking without a burden on build performance.
  • serverless-webpack-prisma - Deletes unnecessary prisma from bundling to Lambda.

Advanced usage

Any tsconfig.json can be used, but if you do, set the environment variable TS_NODE_CONFIG for building the application, eg TS_NODE_CONFIG=./tsconfig.app.json npx serverless webpack

About

Serverless GraphQL API with Apollo, Prisma & Pothos

Resources

Readme
MIT license
Activity

Stars

5 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.