Skip to content

App used to demonstrate GraphQL migrations from REST to GraphQL in presentations and workshops

Notifications You must be signed in to change notification settings

thisdot/rest-to-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL Migration Demo

Prerequisites

  • Node v16+
  • npm v7+

Getting Started

There are 2 project folders in this repo under 'apps':

  • server: Express.js API
  • client: Next.js website

Before continuing, run npm install in both directories:

npm install

Initialize the Database

The following command will initialize the database, create the new tables, and seed the data. When asked for a name call it anything you'd like for instance, "init seed"

npm run prisma:reset

Copy /apps/client/.env.sample -> /apps/client/.env

cp apps/client/.env.sample apps/client/.env

Run the server

npm run dev:server

Run the client

npm run dev:client

Run both for easy development

npm run dev

Migration Steps

  1. Setup your GraphQL Server
  2. Define your schema
  3. Create your resolvers using your preferred methodology
  4. Setup your choice for GraphQL client
  5. Update existing API calls with GraphQL calls
  6. 🚢

Testing

The focus is on testing the CRUD actions on the server side of the application.

npm test

This will

  1. Execute Prisma Test then Server Test
  2. Prisma Test is going to do a couple things
    1. dotenv -e .env.test -- npx prisma migrate reset --force
    2. setup a clean test.sqlite and seed it with data
    3. run all migrations on it
  3. Then after Prisma Test is complete jest test from the server directory is executed

Working with Repo during workshop

The repo is broken down by tags

  1. git checkout tags/v1.0 -b v1.0-branch Is the inital project with tested REST api. ...
  2. git checkout tags/v2.0 -b v2.0-branch Is the final, finished project with GRAPHQL implemented along side the REST API

TODO: Repo needs to be progressivly enhanced from v1.0 -> v2.0 for each moudle adding in the code and tests along with objectives to cover from the instructor docs. Starting with Commit cc783d701147d63a996c0f03eda48d9e2931797d is where gql deps are added and then work up the commits, and generate a tag v1.1 before moving onto the next modlue. (at least that was the general plan)

About

App used to demonstrate GraphQL migrations from REST to GraphQL in presentations and workshops

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published