How to get wikiCount using graphql?
#50752
-
Select Topic AreaQuestion BodyThis query doesn't seem to work. {
search(query: "repo:owner/repo", type: REPOSITORY) {
wikiCount
}
}According to the docs (https://docs.github.com/en/graphql/reference/objects#searchresultitemconnection), this should return the number of wiki pages, but always returns 0 for me. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
You can't directly access the wikiCount field in the GitHub GraphQL API under the search query for a repository. It's more likely used in search operations involving multiple repositories or a broader search scope. When you need to fetch data for one specific repository, including wiki-related information, you could typically query the repository object directly. import subprocess
import os
def clone_and_count_wiki_pages(repo_url, temp_dir):
# Clone the wiki Git repository
wiki_repo_url = repo_url.rstrip('/') + '.wiki.git'
subprocess.run(['git', 'clone', wiki_repo_url, temp_dir], check=True)
# Count the number of Markdown files
wiki_page_count = len([f for f in os.listdir(temp_dir) if f.endswith('.md')])
return wiki_page_count
# Example usage
repo_url = 'https://github.com/[username]/[repository]' # Replace with actual repository URL
temp_dir = '/path/to/temp/dir' # Replace with the path to a temporary directory
wiki_count = clone_and_count_wiki_pages(repo_url, temp_dir)
print(f"Number of wiki pages: {wiki_count}") |
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
You can't directly access the wikiCount field in the GitHub GraphQL API under the search query for a repository. It's more likely used in search operations involving multiple repositories or a broader search scope. When you need to fetch data for one specific repository, including wiki-related information, you could typically query the repository object directly.