Fix widget and front component queries hitting wrong GraphQL endpoint#17889
Fix widget and front component queries hitting wrong GraphQL endpoint#17889charlesBochet merged 1 commit intomainfrom
Conversation
|
Hey @ehconitin! After you've done the QA of your Pull Request, you can mark it as done here. Thank you! |
| loading, | ||
| error, | ||
| } = useQuery(BAR_CHART_DATA, { | ||
| client: apolloCoreClient, | ||
| variables: { | ||
| input: { | ||
| objectMetadataId: objectMetadataItemId, |
There was a problem hiding this comment.
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.
LogDetails |
Greptile OverviewGreptile SummaryThis PR fixes a critical routing issue where widget and front component GraphQL queries were hitting the wrong endpoint. BackgroundAfter PR #17845 separated GraphQL schemas into two endpoints ( Changes Made
ImpactThese hooks now correctly use the default Apollo client (configured to hit Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
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
|
|
🚀 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. |
No description provided.