Nothing Special   »   [go: up one dir, main page]

Skip to content

Node Express based Apollo GraphQL api with custom directive, authentication and authorization with jwt

Notifications You must be signed in to change notification settings

mabc224/node-apollo-graphql-jwt-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setup:

npm install
npm start
http://localhost:8000/graphql

Running in dev mode
npm run dev

This code base is for understanding of HTTP, GraphQL, Node.js and general API practices.

Instructions:

  1. Implement a Node.js-based server with raw http, Koa or Express.
  2. Add a /graphql endpoint serving the apollo-server or any other GraphQL implementation.
  3. Schema must be able to return proper response for the following public query:
{
  movies {
    title
    year
    rating
    actors {
      name
      birthday
      country
      directors {
        name
        birthday
        country
      }
    }
  }
}
  1. Add support for the following mutation:
mutation createUser($username: String, $password: String) {
  createUser(username: $username, password: $password) {
    token
    user {
      id
      name
    }
  }
}

Input Fields
{
  "username": "",
  "password": ""
}
  1. To expand on the number four, add a mutation-based authentication that accepts:
mutation login($username: String, $password: String) {
  login(username: $username, password: $password) {
    token
    user {
      id
      name
    }
  }
}

Input Fields
{
  "username": "",
  "password": ""
}


HTTP Headers
{
    "Authorization": "Bearer ...Token..."
}
  1. Authenticated users may request additional fields for the query used earlier. New scoutbase_rating field must return the a random string between 5.0-9.0:
{
  movies {
    scoutbase_rating

    title
    year
    rating
    actors {
      name
      birthday
      country
      directors {
        name
        birthday
        country
      }
    }
  }
}

HTTP Headers
{
    "Authorization": "Bearer ...Token..."
}
  1. /graphql must be accessible for external clients.

  2. End.

About

Node Express based Apollo GraphQL api with custom directive, authentication and authorization with jwt

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published