Skip to content

dhyeythumar/how-to-GraphQL-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How To GraphQL using JavaScript

GraphQL Authentication GraphQL Subscriptions Prisma (ORM) Apollo Server Express Filtering, Pagination & Sorting

What’s In This Document

Introduction

This repo contains the code for the concepts I learned from "How to GraphQL - Node.js Tutorial".

Setup Instructions

  1. Clone the repository

    git clone https://github.com/dhyeythumar/how-to-GraphQL-js.git
    cd how-to-GraphQL-js
  2. Install the dependencies

    npm install
  3. 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)

  4. 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
  5. 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

Getting Started

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.

License

Licensed under the MIT License.