Skip to content

Latest commit

 

History

History
176 lines (152 loc) · 2.73 KB

operations.md

File metadata and controls

176 lines (152 loc) · 2.73 KB

This document contains the operations that can be performed on the GraphQL API.

Query

Query operations are used to fetch data from the server.

Get a contributor

  • By directly passing the Argument (userId)
query getAContributor {
  getAContributor(userId: "1") {
    userId
    githubUsername
    name
    email
    contributions {
      contributionId
      projectName
      type
      date
    }
  }
}
  • By passing the Argument (userId) as a variable. = "1" is the default value.
query getContributor($userId: String! = "1") {
  getContributor(userId: $userId) {
    userId
    githubUsername
    name
    email
    contributions {
      contributionId
      projectName
      type
      date
    }
  }
}
{
  "userId": "1"
}

Get all contributors

query getAllContributors {
  getAllContributors {
    userId
    githubUsername
    name
    email
    contributions {
      contributionId
      projectName
      type
      date
    }
  }
}

Mutation

Mutation operations are used to modify data on the server.

Add a contributor - without contributions

mutation addAContributor {
  addAContributor(
    input: {
      githubUsername: "Pradumnasaraf"
      name: "Pradumna Saraf"
      email: "[email protected]"
    }
  ) {
    userId
    githubUsername
    name
    email
  }
}

Add a contributor - with contributions

mutation addContributor_contributions {
  addAContributor(
    input: {
      githubUsername: "Pradumnasaraf"
      name: "Pradumna Saraf"
      email: "[email protected]"
      contributions: {
        projectName: "Pradumnasaraf/DevOps"
        type: "code"
        date: "2023"
      }
    }
  ) {
    userId
    githubUsername
    name
    email
    contributions {
      contributionId
      projectName
      type
      date
    }
  }
}

Update a contributor

mutation updateAConbributor {
  updateAContributor(
    userId: "UPradumnasaraf"
    input: {
      name: "Pradumna Saraf"
      email: "[email protected]"
      githubUsername: "Pradumnasaraf"
    }
  ) {
    userId
    githubUsername
    name
    email
  }
}

Delete a contributor

mutation DeleteAContributor {
  deleteAContributor(userId: "UPradumnasaraf") {
    userId
  }
}

Add a contribution by userId

mutation addAcontributions {
  addAContribution(
    userId: "UPradumnasaraf"
    input: { projectName: "UPradumnasaraf/DevOps", type: "code", date: "2023" }
  ) {
    contributionId
  }
}

Delete a contribution by ContributionId

mutation deleteContribution {
  deleteAContribution(userId: "UPradumnasaraf", contributionId: "CPradumnasaraf/DevOps") {
    contributionId
  }
}