Skip to content

Latest commit

 

History

History
172 lines (150 loc) · 2.65 KB

operation.md

File metadata and controls

172 lines (150 loc) · 2.65 KB

Purpose of this file is to provide the information about the operations that can be performed with the GraphQL API.

Query

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

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
  }
}