Skip to content

Fetch only needed fields from GitHub contributors API — id (numeric user ID) collected but only login and html_url are displayed #225

Description

@ooloth

Why

The contributors GraphQL query fetches the GitHub numeric user id and uses it as a React list key, but login alone would serve as a stable unique key — unnecessarily collecting a persistent cross-site identifier.

Current state

src/queries/useContributorsData.ts lines 17–18 fetch id in the GraphQL query. src/components/Contributors.tsx line 47 uses contributor.id as the React key. The rendered UI displays only the avatar image and a link — neither of which requires the numeric id. The login string is a stable, human-readable unique identifier that could serve as the list key.

Ideal state

  • The query does not fetch the numeric id field.
  • login (or html_url) is used as the React list key.
  • The numeric GitHub user ID is not fetched, stored in the Gatsby data layer, or used anywhere in the component tree.

Out of scope

  • Removing id from the upstream GitHub API response (it is returned by default; the fix is to not fetch it in the query).

Starting points

  • src/queries/useContributorsData.ts — the GraphQL query: remove the id field selection.
  • src/components/Contributors.tsx — line 47: replace key={contributor.id} with key={contributor.login}.

QA plan

  1. Remove id from the GraphQL query and update the React key to use login.
  2. Run gatsby build — expect no TypeScript errors.
  3. Open the built site and confirm the Contributors section renders all contributors correctly.
  4. Inspect the Gatsby data layer — confirm no id field exists on contributor nodes.

Done when

The contributors query does not fetch the numeric GitHub id, and login is used as the React list key.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions