GraphQL Authentication • GraphQL Subscriptions • Prisma (ORM) • Apollo Server Express • Filtering, Pagination & Sorting
This repo contains the code for the concepts I learned from "How to GraphQL - Node.js Tutorial".
-
Clone the repository
git clone https://github.com/dhyeythumar/how-to-GraphQL-js.git cd how-to-GraphQL-js
-
Install the dependencies
npm install
-
Adding Database using Prisma (if you choose not to use the existing prisma files from this repo then follow this step else jump to step 3)
(Prisma is an open source database toolkit for JS & TS that makes it easy for developers to reason about their data and how they access it.)
-
Using Prisma CLI to initialize Prisma
npx prisma init
-
Now specifies your database connection & add your schema into
prisma/schema.prisma
(for example check this schema.prisma file)
-
-
Migration changes from schema (existing prisma's schema file have the complete implementation)
-
Run the migration (this will also create prisma client)
npx prisma migrate dev --name "<add-message-here>"
-
To generate prisma client (as I mentioned that client is created with the migrations but if you still want to create then you use the following)
npx prisma generate
-
-
Exploring the data using Prisma Studio (open another terminal so studio can run parallelly)
(Prisma Studio is a powerful database GUI where you can interact with your data)
npx prisma studio
Testing your GraphQL server
npm run dev
As indicated by the terminal output, the server is now running on http://localhost:4000/graphql. To test the API of your server, open a browser and navigate to this URL.
Licensed under the MIT License.