Skip to content

Fix widget and front component queries hitting wrong GraphQL endpoint#17889

Merged
charlesBochet merged 1 commit intomainfrom
fix-api-client-for-widgets
Feb 12, 2026
Merged

Fix widget and front component queries hitting wrong GraphQL endpoint#17889
charlesBochet merged 1 commit intomainfrom
fix-api-client-for-widgets

Conversation

@ehconitin
Copy link
Copy Markdown
Contributor

No description provided.

@charlesBochet charlesBochet merged commit c48ccbc into main Feb 12, 2026
50 checks passed
@charlesBochet charlesBochet deleted the fix-api-client-for-widgets branch February 12, 2026 11:38
Copy link
Copy Markdown
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 4 files

@twenty-eng-sync
Copy link
Copy Markdown

Hey @ehconitin! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

Comment on lines 67 to 72
loading,
error,
} = useQuery(BAR_CHART_DATA, {
client: apolloCoreClient,
variables: {
input: {
objectMetadataId: objectMetadataItemId,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Removing the apolloCoreClient causes chart data queries to target the default /graphql endpoint instead of the required /metadata endpoint, where the resolvers are located.
Severity: CRITICAL

Suggested Fix

Revert the change. The chart data queries must explicitly use the apolloCoreClient to ensure they are sent to the correct /metadata GraphQL endpoint, as was the case before this change. Restore the client: apolloCoreClient parameter in the useQuery hooks for chart data.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location:
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetBarChart/hooks/useGraphBarChartWidgetData.ts#L67-L72

Potential issue: The PR removes the explicit `client: apolloCoreClient` from chart data
queries. However, the corresponding server-side resolvers (`BarChartDataResolver`,
`LineChartDataResolver`, `PieChartDataResolver`) are decorated with
`@MetadataResolver()`, which scopes them to the `/metadata` GraphQL endpoint. By
removing the specific client, these queries will now default to using the `/graphql`
endpoint, which does not contain these resolvers. This will result in GraphQL "unknown
query" errors at runtime, causing all chart widgets to fail to load their data.

Did we get this right? 👍 / 👎 to inform future reviews.

@github-actions
Copy link
Copy Markdown
Contributor

Fails
🚫

node failed.

Log

Details
�[31mError: �[39m SyntaxError: Unexpected token 'C', "Contributo"... is not valid JSON
    at JSON.parse (<anonymous>)
�[90m    at parseJSONFromBytes (node:internal/deps/undici/undici:4259:19)�[39m
�[90m    at successSteps (node:internal/deps/undici/undici:6882:27)�[39m
�[90m    at readAllBytes (node:internal/deps/undici/undici:5807:13)�[39m
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)�[39m
danger-results://tmp/danger-results-18acc1f1.json

Generated by 🚫 dangerJS against 71e6e86

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 12, 2026

Greptile Overview

Greptile Summary

This PR fixes a critical routing issue where widget and front component GraphQL queries were hitting the wrong endpoint.

Background

After PR #17845 separated GraphQL schemas into two endpoints (/metadata and /graphql), chart data resolvers (barChartData, lineChartData, pieChartData) were moved to the /metadata endpoint using @MetadataResolver() decorators. However, the frontend widget hooks were still explicitly using apolloCoreClient (which points to /graphql), causing queries to hit the wrong endpoint.

Changes Made

  • Removed explicit client: apolloCoreClient overrides from all three chart widget hooks (useGraphBarChartWidgetData, useGraphLineChartWidgetData, useGraphPieChartWidgetData)
  • Removed unused useApolloCoreClient imports
  • Fixed import ordering in FrontComponentRenderer.tsx to follow code style guidelines (external imports before internal)

Impact

These hooks now correctly use the default Apollo client (configured to hit /metadata endpoint), allowing chart queries to properly reach their resolvers.

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The changes are straightforward removals of incorrect Apollo client overrides. The fix aligns with the architectural change from PR Prevent leak between /metadata and /graphql GQL schemas #17845 that separated GraphQL schemas. All chart data resolvers are decorated with @MetadataResolver() on the backend, so these queries must use the default metadata client.
  • No files require special attention

Important Files Changed

Filename Overview
packages/twenty-front/src/modules/front-components/components/FrontComponentRenderer.tsx Import order fix - moved internal import to follow external imports per code style guidelines
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetBarChart/hooks/useGraphBarChartWidgetData.ts Removed explicit apolloCoreClient override, now correctly uses default metadata endpoint
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetLineChart/hooks/useGraphLineChartWidgetData.ts Removed explicit apolloCoreClient override, now correctly uses default metadata endpoint
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetPieChart/hooks/useGraphPieChartWidgetData.ts Removed explicit apolloCoreClient override, now correctly uses default metadata endpoint

Sequence Diagram

sequenceDiagram
    participant Widget as Chart Widget Hook
    participant Apollo as Apollo Client
    participant Metadata as /metadata Endpoint
    participant Core as /graphql Endpoint
    participant Resolver as Chart Data Resolver

    Note over Widget,Resolver: BEFORE (Incorrect)
    Widget->>Apollo: useQuery with apolloCoreClient override
    Apollo->>Core: Query barChartData/lineChartData/pieChartData
    Core-->>Apollo: Error (resolver not found on /graphql)
    Apollo-->>Widget: Query fails

    Note over Widget,Resolver: AFTER (Fixed)
    Widget->>Apollo: useQuery (default client)
    Apollo->>Metadata: Query barChartData/lineChartData/pieChartData
    Metadata->>Resolver: Route to @MetadataResolver
    Resolver-->>Metadata: Return chart data
    Metadata-->>Apollo: Response
    Apollo-->>Widget: Chart data rendered successfully
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:8202

This environment will automatically shut down when the PR is closed or after 5 hours.

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.

2 participants