Skip to content

Mscebba/graphql_recipes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Typescript Graphql CRUD

This is a recipes CRUD backend.

Demo

View live demo here

Used Libraries

  • NodeJs
  • GraphQl
  • Typescript
  • Express
  • Apollo
  • TypeOrm
  • Bcrypt
  • JsonWebToken
  • PostgreSQL

Pre-requisites

Installation

  1. Clone the repository or download the zip file
$ git clone [email protected]:Mscebba/graphql_puzzle.git
  1. Install dependencies with npm
$ npm install

or using yarn

$ yarn

Rename .env.example to .env

PORT= '...your port (without quotes)'
JWT_SECRET_KEY= '....your jwt secret key (without quotes)'
DB_TYPE=
DB_USERNAME =
DB_PASSWORD=
HOST=
DB_NAME=
  1. Start PostresQl server and create the database with the name in "database".
  2. From the folder you cloned the repository run the application.

Using npm

$ npm start

or using yarn

$ yarn start

Usage example

  1. Open a browser and go to the Apollo GraphQL Playground
http://localhost:4001/graphql
  1. Create your user first with the signUp mutation
mutation signUp {
  signUp(input: { name: "name", email: "email", password: "password" }) {
    id
    email
    name
    createdAt
  }
}
  1. Then login to get the token and run the other queries
mutation login {
  login(email: "email", password: "password") {
    token
  }
}

{
  "data": {
    "login": {
      "token": "eyJhbGciOiJIUzI1NiI....."
             }
           }
 }
  1. Copy the token and paste it below in the header after Bearer
{
  "authorization": "Bearer eyJhbGciOiJIUzI1NiI....."
}
  1. You'll find the other queries in the Playground right tabs DOCS and SCHEMA
  2. For more documentation about "Apollo GraphQL Playground" go here

Project Demo

https://puzzlegraphql.herokuapp.com/graphql

Author

Martin Scebba | October 2020

License

MIT