Skip to content

feat(about): combine separate GraphQL queries into single request#3604

Merged
arkid15r merged 5 commits intoOWASP:mainfrom
HarshitVerma109:feature/optimize-about-queries
Feb 3, 2026
Merged

feat(about): combine separate GraphQL queries into single request#3604
arkid15r merged 5 commits intoOWASP:mainfrom
HarshitVerma109:feature/optimize-about-queries

Conversation

@HarshitVerma109
Copy link
Contributor

Proposed change

Resolves #3592

This PR optimizes the About page performance by combining 5 separate API requests into a single GraphQL query.

Changes:

  • Created GetAboutPageData query to fetch project, contributors, and leaders data in one go.
  • Updated About page component to use this single query.
  • Updated unit and E2E tests to support the new query structure.

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: I ran make check-test locally: all warnings addressed, tests passed
  • I used AI for code, documentation, tests, or communication related to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Summary by CodeRabbit

  • Refactor

    • About page now loads project, top contributors, and three featured leaders via a single consolidated data request, simplifying loading and error handling and improving consistent rendering.
  • Tests

    • Updated unit and end-to-end tests and mocks to reflect the consolidated data shape and to validate mission, leaders, contributors, roadmap, and error/toast behaviors.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Consolidates multiple About-page GraphQL queries into a single GetAboutPageDataDocument/GET_ABOUT_PAGE_DATA, refactors the About page to consume the unified response, adds the new query module, and updates unit and e2e tests to mock and assert the consolidated data shape.

Changes

Cohort / File(s) Summary
GraphQL Query Definition
frontend/src/server/queries/aboutQueries.ts
New file adding GET_ABOUT_PAGE_DATA which requests project metadata, topContributors, and three leader fields (leader1, leader2, leader3) with variables for projectKey, excludedUsernames, limit, and leader logins.
About Page Implementation
frontend/src/app/about/page.tsx
Replaces multiple queries with GetAboutPageDataDocument; derives projectMetadata, topContributors, and leadersData from the single response; streamlines loading/error handling and removes previous multi-query logic/hooks.
Unit Tests
frontend/__tests__/unit/pages/About.test.tsx
Reworks mocks to respond to GetAboutPageDataDocument with unified payload (project, topContributors, leader1/2/3); updates tests for rendering, error, loading, and null-data scenarios to match new shape.
E2E Tests
frontend/__tests__/e2e/pages/About.spec.ts
Updates GraphQL route handler to inspect operationName === 'GetAboutPageData', build leader1–leader3 from mock users and return consolidated response; removes prior per-query branching.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • arkid15r
  • kasya
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: combining separate GraphQL queries into a single request for the About page.
Description check ✅ Passed The description is related to the changeset and clearly explains the optimization of combining 5 API requests into a single GraphQL query.
Linked Issues check ✅ Passed The PR successfully addresses issue #3592 by combining 5 separate GraphQL queries into a single GetAboutPageData query and updating the frontend accordingly.
Out of Scope Changes check ✅ Passed All changes are directly related to combining GraphQL queries for the About page; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/__tests__/e2e/pages/About.spec.ts (1)

7-29: Ensure non‑matching GraphQL requests are continued.

Playwright route handlers must explicitly handle all intercepted requests by calling continue(), fulfill(), abort(), or fallback(). Currently, any GraphQL operation other than GetAboutPageData is left unhandled and will hang indefinitely, causing test timeouts if any additional query fires (e.g., from future layout or header changes).

✅ Fix
      if (postData.operationName === 'GetAboutPageData') {
         const leaders = ['arkid15r', 'kasya', 'mamicidal']
         const leaderData = leaders.reduce(
           (acc, leader, index) => ({
             ...acc,
             [`leader${index + 1}`]: mockAboutData.users[leader],
           }),
           {}
         )
-        await route.fulfill({
+        return route.fulfill({
           status: 200,
           json: {
             data: {
               project: mockAboutData.project,
               topContributors: mockAboutData.topContributors,
               ...leaderData,
             },
           },
         })
       }
+      return route.continue()
🧹 Nitpick comments (2)
frontend/src/server/queries/aboutQueries.ts (1)

3-82: Consider extracting a shared fragment for leader fields.

This selection set is repeated three times; a fragment keeps future changes in sync.

♻️ Possible refactor
 export const GET_ABOUT_PAGE_DATA = gql`
+  fragment LeaderUserFields on User {
+    id
+    avatarUrl
+    login
+    name
+    badgeCount
+    badges {
+      cssClass
+      description
+      id
+      name
+      weight
+    }
+  }
   query GetAboutPageData(
     $projectKey: String!
@@
-    leader1: user(login: $leader1) {
-      id
-      avatarUrl
-      login
-      name
-      badgeCount
-      badges {
-        cssClass
-        description
-        id
-        name
-        weight
-      }
-    }
-    leader2: user(login: $leader2) {
-      id
-      avatarUrl
-      login
-      name
-      badgeCount
-      badges {
-        cssClass
-        description
-        id
-        name
-        weight
-      }
-    }
-    leader3: user(login: $leader3) {
-      id
-      avatarUrl
-      login
-      name
-      badgeCount
-      badges {
-        cssClass
-        description
-        id
-        name
-        weight
-      }
-    }
+    leader1: user(login: $leader1) {
+      ...LeaderUserFields
+    }
+    leader2: user(login: $leader2) {
+      ...LeaderUserFields
+    }
+    leader3: user(login: $leader3) {
+      ...LeaderUserFields
+    }
   }
 `
frontend/src/app/about/page.tsx (1)

14-84: Guard leader descriptions and names against missing mappings.

If a leader login isn’t in the leaders map or the name is missing, the UI can receive undefined. Add nullish fallbacks.

🛠️ Suggested tweak
-  const leadersData = [data?.leader1, data?.leader2, data?.leader3].filter(Boolean).map((user) => ({
-    description: user?.login ? leaders[user.login as keyof typeof leaders] : '',
-    memberName: user?.name || user?.login,
-    member: user,
-  }))
+  const leadersData = [data?.leader1, data?.leader2, data?.leader3].filter(Boolean).map((user) => ({
+    description: user?.login ? leaders[user.login as keyof typeof leaders] ?? '' : '',
+    memberName: user?.name ?? user?.login ?? '',
+    member: user,
+  }))

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 27, 2026
@HarshitVerma109
Copy link
Contributor Author

@arkid15r , please review it and let me know if any changes are required.

@HarshitVerma109
Copy link
Contributor Author

@arkid15r , please review it and let me know if any changes are required.

@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.69%. Comparing base (d3c09fb) to head (15432b9).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
frontend/src/app/about/page.tsx 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3604      +/-   ##
==========================================
- Coverage   87.70%   87.69%   -0.01%     
==========================================
  Files         462      462              
  Lines       14287    14271      -16     
  Branches     1905     1900       -5     
==========================================
- Hits        12530    12515      -15     
  Misses       1344     1344              
+ Partials      413      412       -1     
Flag Coverage Δ
backend 87.45% <ø> (ø)
frontend 88.36% <90.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
frontend/src/app/about/page.tsx 87.64% <90.00%> (-0.94%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3c09fb...15432b9. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arkid15r
Copy link
Collaborator

arkid15r commented Feb 3, 2026

@cubic-dev-ai review this pull request

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Feb 3, 2026

@cubic-dev-ai review this pull request

@arkid15r I have started the AI code review. It will take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arkid15r arkid15r added this pull request to the merge queue Feb 3, 2026
Merged via the queue into OWASP:main with commit f602ccf Feb 3, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize the About page queries

2 participants