huming0618 / codetower

read and share for reading the code
0 stars 0 forks source link

[NOTE] Github API v4 - GraphQL #10

Open huming0618 opened 4 years ago

huming0618 commented 4 years ago

links

mutation AddReactionToIssue { addReaction(input:{subjectId:"MDU6SXNzdWUyMzEzOTE1NTE=",content:HOORAY}) { reaction { content } subject { id } } }

huming0618 commented 4 years ago

get all branches

{
  repository(owner: "huming0618", name: "learn-rust") {
        refs(first: 100, refPrefix: "refs/heads/") {
          nodes {
            name
            target {
              ... on Commit {
                oid
                committedDate
              }
            }
          }
        }
  }
}

get the commits

{
  repository(name: "learn-rust", owner: "huming0618") {
    object(expression: "master:01-trait") {
      ... on Tree {
        commitUrl
        id
        commitResourcePath
        entries {
          name
          type
        }
      }
    }
  }
}

get entries on branch

  repository(name: "<repo>", owner: "<owner>") {
    object(expression: "master:") {
      ... on Tree {
        entries {
          name
        }
      }
    }
  }
query { 
  repository(name: "<repo>", owner: "<owner>") {
    object(expression: "master:<path>") {
      ... on Blob {
        oid
        byteSize
        text
      }
    }
  }
}
query ListFiles($repoName: String!) {
  repository(name: $repoName) {
    commit(rev: "develop") {
      tree(path: "/", recursive: true) {
        entries {
          path
          isDirectory
          url
        }
      }
    }
  }
}