Skip to content

colleowino/graphql-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL basics

This is based on the 1st project(ecomm-app-graphql) in the book - Practical GraphQL

How to run the app

This is a backend API project. It requires nodemon to be installed globally. npm i -g nodemon

  1. Install npm modules with npm install .
  2. Run the app with npm run dev.
  3. Open the browser on http://localhost:4000.

Overview

There are 3 models/objects Courses, Genres and Reviews.

  • The database is hardcoded, but the CRUD commands will work as expected in Apollo Studio.
  • The main parts of the App are queries and resolvers. Most of the heavy lifting is done in the resolvers.
  • Mutators are for Modifying and deleting items.
  • It uses exclamations to prevent null values.

What I liked

  • The code is well organized and leads the user in creating the app progressively.

What I didn't like

  • The code for the api calls were displayed as pixelated images, making it hard to read it clearly.
  • The rest of the code could have been better presented with syntax highlighting.
  • Some of the code snippets were not shown exactly where they would go in the code and were left to the user to decide.

APIs for testing

  • Feel free to add fields if they belong to the entity.

Courses, Genres, Reviews

query{
  courses {
    id
    name
  }
}
query{
  genres {
    id
    name
  }
}
query{
  reviews {
    id
    title
    courseId
  }
}

Adding review

mutation($addReviewInput2: AddReviewInput!){
  addReview(input: $addReviewInput2) {
    id
    rating
    date
  }
}

Variables

{
  "addReviewInput2": {
    "date": "2025-09-05",
    "title": "The best book",
    "comment": "Must read for everyone",
    "rating": 5,
    "courseId": "book-06"
  }

About

Learning graphQl by building an API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published