Search for code in GitHub using GraphQL (v4 API)

前端 未结 2 718
孤城傲影
孤城傲影 2021-01-01 11:02

I am using the GitHub\'s GraphQL API to search for files/code containing a particular word. A simple (contrived) example of a search which in this case is to find the term

相关标签:
2条回答
  • 2021-01-01 11:50

    Type: CODE is not supported yet. There is no way you can search the code using graphql right now.

    Your understanding is right. Just that you are missing one piece. The search you are doing is happening against the type: REPOSITORY. if you replace your search with

    search(query: "beef", type: REPOSITORY, first: 10) {

    you will get all the repos having beef in their name.

    0 讨论(0)
  • 2021-01-01 12:01

    You can add qualifiers, if you want to search "beef" just in names than change the query like

    search(query: "beef in:name", type: REPOSITORY, first: 10) {

    for further detail you can look at https://help.github.com/en/articles/searching-for-repositories#search-based-on-the-contents-of-a-repository

    0 讨论(0)
提交回复
热议问题