[GraphQL API] How to find repositories by search phrase and sort the results by the first commit date in found repos #109517
Replies: 5 comments 1 reply
-
I haven't found required info in GraphQL API docs |
Beta Was this translation helpful? Give feedback.
-
Is there a way to gather required info? |
Beta Was this translation helpful? Give feedback.
-
Can anyone help me? |
Beta Was this translation helpful? Give feedback.
-
Maybe I haven't specified category for this question correctly? |
Beta Was this translation helpful? Give feedback.
-
The
The
This is the challenging part. One approach is to use Additionally, it seems rather inefficient to query and discard a large amount of data just to obtain the last commit. I recommend the following: query ($searchPhrase: String = "LLM on CPU") {
search(query: $searchPhrase, type: REPOSITORY, first: 100) {
repositoryCount
nodes {
... on Repository {
url
nameWithOwner
createdAt
defaultBranchRef {
target {
... on Commit {
history(first: 1) {
totalCount
}
}
}
}
}
}
}
}
# Exemplary 'REST API' calls to get the 'first commit' using 'curl' and 'jq'
# [curl] https://curl.se/
# [jq] https://jqlang.github.io/jq/
curl -s 'https://api.github.com/repos/${nameWithOwner}/commits?per_page=1&page=${totalCount}' |
jq '.[].commit.author.date'
Footnotes |
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Question
Body
Hello there,
Could you please help me to create Github GraphQL API query?
I need implement this flow:
Every element (repo) in search results must have the following fields (names of fields gathered from API reference docs):
I wrote this code, but it does not do everything I need:
Please help me to write right query
P.S.
Is there a method in REST API to get the date of first commit in particular repo by specifying the ID of the repo in form of {owner}/{repository} as it is specified in repo URL?
Beta Was this translation helpful? Give feedback.
All reactions