The complete app can be found here.
- Create a directory
mkdir hackernews-node
cd hackernews-node
- Initialise a project
yarn init -y
mkdir src
- Make the server file
touch src/index.js
- Add graphql-yoga
yarn add graphql-yoga
- Make changes into
index.js
- Run the server using
node src/index.js
- Create the schema file
touch src/schema.graphql
- Remove the typeDefs from
index.js
& modify the resolver functions
- Create the Prisma directory
mkdir prisma
- Create the Prisma files
touch prisma/prisma.yml
&touch prisma/datamodel.prisma
- Add the datamodel in
datamodel.prisma
- Install the Prisma CLI globally
yarn global add prisma
- Deploy the model from root folder
prisma deploy
- Select the appropriate options to setup Prisma
- Inside the prisma folder run
prisma generate
- In root directory run
yarn add prisma-client-lib
- After the changes in
datamodel.prisma
redeploy the model usingprisma deploy
from root folder - Make the changes in schema
- Create the resolver function
- Run
yarn add jsonwebtoken bcryptjs
- Create
src/utils.js
- Make the necessary changes in
index.js
- Add the subscriptions in the schema
- Update the resolvers
- Update
index.js
- Listen to subscriptions on
http://localhost:4000
and make mutations through anotherhttps://localhost:4000
- Change the schema and the appropriate resolvers