Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
/ paired-api Public archive

A GraphQL API built with Node, Express, Apollo Server, and MongoDB

Notifications You must be signed in to change notification settings

dForDeveloper/paired-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Paired API

The Paired API is a GraphQL API built with Node, Express, Apollo Server, and MongoDB. It serves as the back end for Paired, a React application created to improve pair programming between Turing students throughout their seven-month immersive program.

Front End

How to Contribute

  • Install MongoDB Community Server (instructions for macOS)
  • mongod to start MongoDB
  • Fork this repo
  • Open your terminal
  • cd to where you want the repo directory to be created
  • Clone your fork down to your machine either
    • with SSH: git clone git@github.com:yourusername/paired-api.git
    • or with HTTPS: git clone https://github.com/yourusername/paired-api.git
  • cd paired-api
  • npm install
  • npm run seed to seed the database
  • npm run test:dev to run the test suite
  • npm run server to start the server
  • Go to http://localhost:3001/graphql to use the GraphQL Playground
  • Push changes up to your fork
  • Make pull requests from your fork to the original repo

Schema

  • User

    Field Data Type
    id ID!
    name String!
    module String!
    program Int!
    skills [String]
    interests [String]
    pronouns String
    slack String
    email String
    image String
  • Pairing

    Field Data Type
    id ID!
    pairer User!
    pairee User
    date String!
    times String!
    notes String

Endpoint

  • https://paired-api.herokuapp.com/graphql

Queries:

  • getUser(id: ID!): User

    • example query

      {
        getUser(id: "5cad1dcfee07882ab05e904a") {
          name
          program
          module
        }
      }
      
    • example response

      {
        "data": {
          "getUser": {
            "name": "Jeo",
            "program": "FE",
            "module": 4
          }
        }
      }

    getUser query

  • getUsers: [User]

    • example query

      {
        getUsers {
          name
          program
          module
        }
      }
      
    • example response

      {
        "data": {
          "user": [
            {
              "name": "Jeo",
              "program": "FE",
              "module": 4
            },
            {
              "name": "Tiffany",
              "program": "FE",
              "module": 4
            },
            {
              "name": "Aaron",
              "program": "BE",
              "module": 4
            },
            {
              "name": "Hillary",
              "program": "FE",
              "module": 4
            }
          ]
        }
      }
  • getPairings: [Pairing]

    • example query

      {
        getPairings {
          id
          pairer {
            name
          }
          pairee {
            name
          }
          date
          time
        }
      }
      
    • example response

      {
        "data": {
          "getPairings": [
            {
              "id": "5ca56d0d4a515ca7339852b3",
              "pairer": {
                "name": "Jeo"
              },
              "pairee": null,
              "date": "Wed Apr 03 2019",
              "time": "lunch"
            },
            {
              "id": "5ca56d0d4a515ca7339852b5",
              "pairer": {
                "name": "Tiffany"
              },
              "pairee": {
                "name": "Jeo"
              },
              "date": "Wed Apr 03 2019",
              "time": "afternoon"
            },
            ...
          ]
        }
      }
  • getPairing(id: ID!): Pairing

    • example query
    {
      getPairing(id: "5ccba783eb113c2e2ef3692f") {
        pairer {
          name
          module
          program
          id
          pronouns
          skills
          slack
          image
        }
        date
        time
        id
      }
    }
    
    • example response
    {
      "data": {
        "getPairing": {
          "pairer": {
            "name": "Hill",
            "module": 4,
            "program": "FE",
            "id": "5ccba783eb113c2e2ef3692d",
            "pronouns": "she/her",
            "skills": [
              "react",
              "redux"
            ],
            "slack": "@hillstew",
            "image": "https://avatars3.githubusercontent.com/u/36748280?v=4"
          },
          "date": "Mon May 06 2019",
          "time": "lunch",
          "id": "5ccba783eb113c2e2ef3692f"
        }
      }
    }
  • getAvailablePairings(filter: PairingFilter): [Pairing]

    • example query
    {
      getAvailablePairings(
        filter: { program: "FE", module: 4, date: "Wed Apr 03 2019" }
      ) {
        pairer {
          name
          module
          program
        }
        date
        time
      }
    }
    
    • example response
    {
      "data": {
        "getAvailablePairings": [
          {
            "pairer": {
              "name": "Jeo",
              "module": 4,
              "program": "FE"
            },
            "date": "Wed Apr 03 2019",
            "time": "lunch"
          },
          {
            "pairer": {
              "name": "Hillary",
              "module": 4,
              "program": "FE"
            },
            "date": "Wed Apr 03 2019",
            "time": "morning"
          }
        ]
      }
    }
  • getUserPairings(id: ID): [Pairing]

    • example query
    {
      getUserPairings(id: "5ca929750dbd7d527336849e") {
        pairer {
          name
        }
        pairee {
          name
        }
        date
        time
      }
    }
    
    • example response
    {
      "data": {
        "getUserPairings": [
          {
            "pairer": {
              "name": "Tiffany"
            },
            "pairee": {
              "name": "Jeo"
            },
            "date": "Wed Apr 03 2019",
            "time": "afternoon"
          },
          {
            "pairer": {
              "name": "Hillary"
            },
            "pairee": {
              "name": "Tiffany"
            },
            "date": "Fri Apr 05 2019",
            "time": "morning"
          }
        ]
      }
    }

Mutations:

  • createUser(user: CreateUserInput): User!

    • example mutation
    mutation {
      createUser(user: { name: "John", module: 2, program: "FE" }) {
        id
        name
        module
        program
        email
      }
    }
    
    • example response
    {
      "data": {
        "createUser": {
          "id": "5ca56e87f1f10fa7acbe9544",
          "name": "John",
          "module": 2,
          "program": "FE",
          "email": null
        }
      }
    }
  • createPairing(pairing: CreatePairingInput): Pairing!

    • example mutation
    mutation {
      createPairing(
        pairing: {
          pairer: "5ca56e87f1f10fa7acbe9544"
          pairee: 5
          date: "Fri Apr 05 2019"
          time: "lunch"
        }
      ) {
        pairer {
          name
          module
        }
        pairee {
          name
          module
          program
        }
        date
        time
      }
    }
    
    • example response
    {
      "data": {
        "createPairing": {
          "pairer": {
            "name": "John",
            "module": 2
          },
          "pairee": {
            "name": "Alice",
            "module": 1,
            "program": "BE"
          },
          "date": "Fri Apr 05 2019",
          "time": "lunch"
        }
      }
    }
  • createPairings(pairings: [CreatePairingInput]): [UnpopulatedPairing]

    • example mutation
    mutation {
      createPairings(
        pairings: [
          {
            pairer: "5cad1dcfee07882ab05e904a"
            date: "Mon Apr 29 2019"
            time: "morning"
          }
          {
            pairer: "5cad1dcfee07882ab05e904a"
            date: "Mon Apr 29 2019"
            time: "lunch"
          }
        ]
      ) {
        pairer
        date
        time
      }
    }
    
    • example response
    {
      "data": {
        "createPairings": [
          {
            "pairer": "5cad1dcfee07882ab05e904a",
            "date": "Mon Apr 29 2019",
            "time": "morning",
            "notes": null
          },
          {
            "pairer": "5cad1dcfee07882ab05e904a",
            "date": "Mon Apr 29 2019",
            "time": "lunch",
            "notes": null
          }
        ]
      }
    }
  • updateUser(user: UpdateUserInput): User

    • example mutation
    mutation {
      updateUser(
        user: {
          id: "5ca92b7f6a7f1153030b872b"
          skills: ["react", "redux", "graphql"]
          interests: ["super market sweep", "graphql"]
        }
      ) {
        name
        skills
        interests
      }
    }
    
    • example response
    {
      "data": {
        "updateUser": {
          "name": "Hillary",
          "skills": [
            "react",
            "redux",
            "graphql"
          ],
          "interests": [
            "super market sweep",
            "graphql"
          ]
        }
      }
    }
  • updatePairing(pairing: UpdatePairingInput): Pairing

    • example mutation
    mutation {
      updatePairing(
        pairing: {
          id: "5ca92b7f6a7f1153030b872d"
          pairee: "5ca92b7f6a7f1153030b872b"
          notes: "Please help with GraphQL"
        }
      ) {
        pairer {
          name
        }
        pairee {
          name
        }
        notes
      }
    }
    
    • example response
    {
      "data": {
        "updatePairing": {
          "pairer": {
            "name": "Jeo"
          },
          "pairee": {
            "name": "Hillary"
          },
          "notes": "Please help with GraphQL"
        }
      }
    }
  • deleteUser(id: ID!): User

    • example mutation
    mutation {
      deleteUser(id: "5ca92b7f6a7f1153030b8728") {
        name
      }
    }
    
    • example response
    {
      "data": {
        "deleteUser": {
          "name": "Jeo"
        }
      }
    }
  • deletePairing(id: ID!): Pairing

    • example mutation
    mutation {
      deletePairing(id: "5ca92ec3c9624e53b4971959") {
        date
        time
      }
    }
    
    • example response
    {
      "data": {
        "deletePairing": {
          "date": "Wed Apr 03 2019",
          "time": "lunch"
        }
      }
    }
  • deletePairings(id: ID!): DeletedPairing

    • example mutation
    mutation {
      deletePairings(id: "5cc88756a3ac3b35ffd45d2d") {
        date
        time
      }
    }
    
    • example response
    {
      "data": {
        "deletePairings": {
          "date": null,
          "time": null
        }
      }
    }

Built With

Testing and Continuous Integration

  • Jest
  • Travis CI

Contributors

About

A GraphQL API built with Node, Express, Apollo Server, and MongoDB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published