jacruzca / backend-quiz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CarDash Backend Quiz

This is a basic quiz to to assess your familiarity with the technology stack we're using. If you are familiar with the tech stack, this should only take 30-45 minutes of your time. If not familiar, it could take longer.

To get started, clone this repository.

To get the app running, npm i and run npm run dev.

To test your work, run npm run test

The Tasks

  1. Create a new query to fetch an individual user by id
{
  user(id: 5) {
    firstName
  }
}

Bonus points for generalizing this to work across all of the models

  1. Create a new GraphQL property on User called displayName, which is defined as first name and last initial, e.g. Evan R.

  2. Create a new query profitableUsers which returns a sorted list of users according to the total value of their orders.

{
  profitableUsers(top: 5) {
    user {
      firstName
      lastName
    }
    spend
  }
}
  1. Create a new GraphQL mutation createVehicle that accepts parameters year, make, and model. This mutation throws an error if the (make, model) pair is not valid. You will want to fill out the function set in db.js, and you can find the list of valid pairs below.

  2. Create a new GraphQL mutation updateVehicle that accepts parameters id, year, make, and model. This mutation throws an error if the (make, model) pair is not valid. Otherwise it updates and saves the appropriate model. You will want to fill out the function set in db.js, and you can find the list of valid pairs below.

Valid pairs

const makes = {
  Acura: ['MDX', 'RDX', 'ILX'],
  Audi: ['A4', 'Q5', 'Q7'],
  BMW: ['325', '750'],
  Ford: ['Taurus', 'F150'],
  Honda: ['CR-V', 'Accord'],
  Jaguar: ['XJ', 'XF', 'XE'],
  Jeep: ['Grand Cherokee'],
  Toyota: ['RAV4', 'Corolla', 'Camry'],
}

About

License:MIT License


Languages

Language:JavaScript 100.0%