Skip to content

[github-data] fix: switch contributions queries from user(login) to viewer form#24

Merged
bit-incarnas merged 1 commit into
mainfrom
fix/activity-viewer-form
Apr 25, 2026
Merged

[github-data] fix: switch contributions queries from user(login) to viewer form#24
bit-incarnas merged 1 commit into
mainfrom
fix/activity-viewer-form

Conversation

@bit-incarnas
Copy link
Copy Markdown
Owner

@bit-incarnas bit-incarnas commented Apr 25, 2026

Summary

GitHub treats `user(login: $login).contributionsCollection` as a third-party query and only returns what's visible on the user's public profile graph -- private contributions get omitted from per-repo / per-day breakdowns even when the authenticated user IS that login and "Include private contributions on profile" is enabled.

Result: every private commit silently dropped out of the activity feed regardless of PAT scope or profile settings.

Fix

Switch all four contributions queries (main, paginate PRs, paginate issues, paginate reviews) to the `viewer` form, which returns the authenticated viewer's complete contributions including granular private-repo data.

  • Drops the now-unused `$login` variable from each query
  • Drops the `login` parameter from `fetchContributionsCollection`
  • The viewer login is still captured via `fetchViewerLogin` for the `SyncActivityResult` diagnostic

Repro before / after

Before (v0.0.4):

  • Push 4 commits to a private repo -> activity sync runs, returns `ok: true`, writes 0 day files for that activity. Heatmap stays empty for those days.

After (v0.0.5):

  • Same scenario -> activity sync writes the full per-day rollup including the private-repo per-repo breakdown. Heatmap colors in.

Tests

489 / 489 passing. Updated mock fixtures in `graphql.test.ts` and `activity-writer.test.ts` to use the `viewer` response shape; updated test names + assertions to reflect the new `viewer`-not-found error message.

Tag

v0.0.5 tag already pushed (points at the patched commit on this branch). BRAT will see it on next refresh after merge.

Test plan

  • Existing v0.0.4 users with private repo activity verify private commits surface after upgrading
  • Public-only users see no behavior change
  • PAT scope requirements unchanged (`viewer { contributionsCollection }` works with the same scopes that already worked for `user(login)` form)

🤖 Generated with Claude Code

…iewer form

GitHub treats `user(login: $login).contributionsCollection` as a third-party
query and only returns what's visible on the user's public profile graph --
private contributions get omitted from per-repo / per-day breakdowns even when
the authenticated user IS that login and the "Include private contributions on
profile" toggle is enabled. Result: every private commit silently dropped out
of the activity feed regardless of PAT scope or profile settings.

Switch all four contributions queries (main, paginate PRs, paginate issues,
paginate reviews) to the `viewer` form which returns the authenticated
viewer's complete contributions including granular private-repo data.

Drops the now-unused $login variable from each query and the `login`
parameter from `fetchContributionsCollection`. The viewer login is still
captured via `fetchViewerLogin` for the SyncActivityResult diagnostic.

Tests updated to use the `viewer` mock shape; 489/489 pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

📝 Walkthrough

Walkthrough

Version bump from 0.0.4 to 0.0.5. Primary functional change: refactored fetchContributionsCollection to query authenticated viewer contributions instead of explicit user login. GraphQL queries, response structures, and related function signatures updated consistently across the codebase to reflect this shift.

Changes

Cohort / File(s) Summary
Version Updates
manifest.json, package.json, versions.json
Version incremented from 0.0.4 to 0.0.5. New mapping added in versions.json for 0.0.5 → 1.0.0.
GitHub GraphQL Refactoring
src/github/graphql.ts, src/github/graphql.test.ts
Switched from user(login: ...) to viewer queries. fetchContributionsCollection signature now excludes login parameter. Response parsing, pagination, and error messages updated to reference viewer instead of user. Tests restructured to mock viewer-based responses and validate new query structure.
Activity Sync Updates
src/sync/activity-writer.ts, src/sync/activity-writer.test.ts
Updated call to fetchContributionsCollection to omit login argument. Test response structure adjusted to place contributionsCollection under viewer.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A hop from login to viewer so sleek,
No more explicit names we seek!
Authenticated requests now flow,
Through GraphQL's authenticated glow,
Version bumped—let's celebrate! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: switching GitHub contributions queries from user(login) form to viewer form.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description is directly related to the changeset, clearly explaining the problem (private contributions omitted), the fix (switching to viewer form), code adjustments, test updates, and verification steps.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/activity-viewer-form

Comment @coderabbitai help to get the list of available commands and usage tips.

@bit-incarnas bit-incarnas merged commit 47b3cc0 into main Apr 25, 2026
3 of 4 checks passed
@bit-incarnas bit-incarnas self-assigned this May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant