MCPcopy
hub / github.com/vinta/awesome-python / build_graphql_query

Function build_graphql_query

website/fetch_github_stars.py:48–58  ·  view source on GitHub ↗

Build a GraphQL query with aliases for up to 100 repos.

(repos: Sequence[str])

Source from the content-addressed store, hash-verified

46
47
48def build_graphql_query(repos: Sequence[str]) -> str:
49 """Build a GraphQL query with aliases for up to 100 repos."""
50 parts = []
51 for i, repo in enumerate(repos):
52 owner, name = repo.split("/", 1)
53 if not GITHUB_OWNER_RE.match(owner) or not GITHUB_NAME_RE.match(name):
54 continue
55 parts.append(f'repo_{i}: repository(owner: "{owner}", name: "{name}") {{ stargazerCount owner {{ login }} defaultBranchRef {{ target {{ ... on Commit {{ committedDate }} }} }} }}')
56 if not parts:
57 return ""
58 return "query { " + " ".join(parts) + " }"
59
60
61def parse_graphql_response(

Calls

no outgoing calls