Skip to content

Latest commit

 

History

History
234 lines (138 loc) · 5.04 KB

README.md

File metadata and controls

234 lines (138 loc) · 5.04 KB

This was created during my time as a student at Code Chrysalis

NBA Players API

An API that will return NBA players with their current team.

To run the app locally

  1. npm install
  2. npm run start or npm run dev for the dev environment
  3. Access localhost:4000/graphql for the graphql playground

.env Parameters

DATABASE_URL
PORT

Schema

Player

A NBA / basketball Player

Field Type Description
id Int Auto-incremented id
firstName! String Player's first name
lastName! String Player's last name
height Int Player's height in centimeters
weight Int Player's weight in kilograms
currentTeam Team Player's current team
dateOfBirth DateTime Player's date of birth

Team

A NBA / basketball team

Field Type Description
id Int Auto-incremented id
name! String Team name
abbreviation String Team abbreviation (eg: LAL)
homeArena String Name of home arena
players [Player] List of current NBA / basketball players

Queries

players

Get all NBA / basketball players

Return Type: [Player]

Input: none


player

Get one NBA / basketball player by id

Return Type: Player

Input: (id: Int!)


playersOnTeamByTeamId

Get NBA / basketball players by team id

Return Type: Player

Input: (teamId: Int!)


playersByName

Get NBA / basketball players by name (firstName, lastName)

Return Type: Player

Input: (firstName: String!, lastName: String!)


playersByPartialName

Get NBA / basketball players by partial name (name in first or last name)

Return Type: Player

Input: (partialName: String!)


teams

Get all NBA / basketball team

Return Type: [Team]

Input: none


team

Get one NBA / basketball team by id

Return Type: Team

Input: (id: Int!)


teamByName

Get one NBA / basketball team by name

Return Type: Team

Input: (name: String!)


Mutations

createPlayer

Create a NBA / basketball player

Return Type: Player

Input: (data: PlayerCreateInput!)


updatePlayer

Update a NBA / basketball player by id

Return Type: Player

Input: (id: Int!, data: PlayerUpdateInput!)


deletePlayer

Delete a NBA / basketball player by id

Return Type: Player

Input: (id: Int!)


createTeam

Create a NBA / basketball team

Return Type: Team

Input: (data: TeamCreateInput!)


updateTeam

Update a NBA / basketball team by id

Return Type: Team

Input: (id: Int!, data: TeamUpdateInput!)


deleteTeam

Delete a NBA / basketball Team

Return Type: Team

Input: (id: Int!)


Inputs

PlayerCreateInput

Field Type Description
firstName! String Player's first name
lastName! String Player's last name
height Int Player's height in centimeters
weight Int Player's weight in kilograms
currentTeamId Int Player's current team's id

PlayerUpdateInput

Field Type Description
firstName! String Player's first name
lastName! String Player's last name
height Int Player's height in centimeters
weight Int Player's weight in kilograms
currentTeamId Int Player's current team's id

TeamCreateInput

Field Type Description
name! String Team name
abbreviation String Team abbreviation (eg: LAL)
homeArena String Name of home arena

TeamUpdateInput

Field Type Description
name! String Team name
abbreviation String Team abbreviation (eg: LAL)
homeArena String Name of home arena