How do I make an API call to GitHub for a user's pinned repositories?

后端 未结 3 2034
长发绾君心
长发绾君心 2020-12-29 14:31

On GitHub, a user can have pinned repositories.

There\'s also the Repositories section of the API describing how to make requests that involve repos. You can also ge

3条回答
  •  甜味超标
    2020-12-29 15:36

    An update to the original answer:

    The changelog for GitHub GraphQL schema (2019-03-30) mentions that the pinnedRepositories will be deprecated or removed by 2019-07-01. GraphQL API users are requested to use ProfileOwner.pinnedItems instead.

    Examples to retrieve pinned repositories using ProfileOwner.pinnedItems:

    Example 1:

    query {
        user(login:"kranthilakum") {
        pinnedItems(first: 5, types: [REPOSITORY, GIST]) {
          totalCount
          edges {
            node {
              ... on Repository {
                name
              }
            }
          }
        }
      }
    }
    

    Try Example 1 in the GraphQL API Explorer

    Example 2:

    query {
      repositoryOwner(login: "kranthilakum") {
        ... on ProfileOwner {
          pinnedItemsRemaining
          itemShowcase {
            items(first: 5) {
              totalCount
              edges {
                node {
                  ... on Repository {
                    name
                  }
                }
              }
            }
            hasPinnedItems
          }
        }
      }
    }
    

    Try Example 2 in GraphQL API Explorer

提交回复
热议问题