0

I want to fetch all the repos, that I'm owner/contributor with specific topic.

I tried below this request. This returned, all my repos that I'm owner/contributor with all the topics.

{
  viewer {
    repositories(first: 100) {
      pageInfo {
        hasPreviousPage
        hasNextPage
        startCursor
        endCursor
      }
      nodes {
        name
        repositoryTopics(first: 10) {
          nodes {
            topic {
              name
            }
          }
          totalCount
        }
      }
    }
  }
}

I also tried the below request. But it returned all the repos in my org (not only mine) with that specific topic.

{
  search(first: 100, type: REPOSITORY, query: "topic:mytopic org:myorg") {
    pageInfo {
      hasNextPage
      endCursor
      }
    repos: edges {
      repo: node {
        ... on Repository {
          name
          url
          id
        }
      }
    }
  }
}

I need only repos that I'm owner/contributor with that specific topic

mnvbrtn
  • 558
  • 1
  • 8
  • 27

1 Answers1

0

In your first query it simply seems like you have fetched the first 100 topics irrespective of their actual topic. In order to select according to a topic you have to use variables.Thereafter, use the useQuery hook and pass your variable.(You can make an input field and associate its value with the variable with which you filter). See more here in the apollo docs : https://www.apollographql.com/docs/react/data/queries/#caching-query-results

Peter Malik
  • 403
  • 4
  • 14