Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

pseudogarden/ariel

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ariel

💕 graphql backend project

Overview

This project focuses on the implementation of graphql on a backend express-mnode server. This project should act as a guide to help others fully implement graphql for server technology.

Project

The application will be a backend book shelf. The user of the shelf can get a book by:

  book {
    title
    author
    description
    publish_date
  }

🔧 Installation

Clone repo and navigate to project

git clone https://github.com/pseudogarden/ariel.git && cd ariel

Install latest version of node

nvm install

Install dependencies

npm i

Run development server

npm run start:dev

Tasks

The client side should be able to

  • User signup/login
  • Get books by user
  • Add book to user shelf
  • Edit book in user shelf
  • Remove a book from user shelf
  • Remove books by author from user shelf

Queries

@ localhost:3000/graphql

Signup

request

mutation {
  signup(username: "fin", email: "fin@test.com", password: "password") {
    id
    username
    email
  }
}

response

{
  "data": {
    "signup": {
      "id": 12,
      "username": "dan",
      "email": "dan@test.com"
    }
  }
}

Login

request

mutation {
    login(email: "dan@test.com", password: "password") {
        user {
            id
            email
            username
        }
    }
}

response

{
    "data": {
        "login": {
            "user": {
                "id": 12,
                "email": "dan@test.com",
                "username": "dan"
            }
        }
    }
}

Add Book

request

mutation {
    addBook(
        title: "For Whom The Bell Tolls",
        author: "Ernest Hemmingway",
        description: "A Novel about war in sapin",
        publishDate: "1940-10-21"
    ) {
        id
        title
        author
        description
        user {
            id
            username
        }
    }
}

response

{
    "data": {
        "addBook": {
            "id": 7,
            "title": "For Whom The Bell Tolls",
            "author": "Ernest Hemmingway",
            "description": "A Novel about war in sapin",
            "user": {
                "id": 12,
                "username": "dan"
            }
        }
    }
}

Current User

this simply feeds you the current logged in user

request

{
    currentUser {
        id
        username
        email
    }
}

response

{
    "data": {
        "currentUser": {
            "id": 12,
            "username": "dan",
            "email": "dan@test.com"
        }
    }
}

Get Books

books of logged in user

request

{
    getBooks {
        id
        title
        author
        description
        user {
            id
            username
        }
    }
}

response

{
    "data": {
        "getBooks": [
            {
                "id": 7,
                "title": "For Whom The Bell Tolls",
                "author": "Ernest Hemmingway",
                "description": "A Novel about war in sapin",
                "user": {
                    "id": 12,
                    "username": "dan"
                }
            }
        ]
    }
}

books of any user via username

request

{
    getBooks(username: "john") {
        id
        title
        author
        description
        user {
            id
            username
        }
    }
}

response

{
    "data": {
        "getBooks": [
            {
                "id": 1,
                "title": "On the Origin of Species",
                "author": "Charles Darwin",
                "description": "Textbook about evolution",
                "user": {
                    "id": 11,
                    "username": "john"
                }
            }
        ]
    }
}

About

💕 graphql backend project

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.