Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { REST_API_BASE_URL } from '@/apollo/constant/rest-api-base-url';
import { getTokenPair } from '@/apollo/utils/getTokenPair';
import { useFrontComponentExecutionContext } from '@/front-components/hooks/useFrontComponentExecutionContext';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { useTheme } from '@emotion/react';
import { t } from '@lingui/core/macro';
import { useState } from 'react';
import { FrontComponentRenderer as SharedFrontComponentRenderer } from 'twenty-sdk/front-component';
import { isDefined } from 'twenty-shared/utils';

import { useFrontComponentExecutionContext } from '@/front-components/hooks/useFrontComponentExecutionContext';

type FrontComponentRendererProps = {
frontComponentId: string;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById';
import { type FieldMetadataItemOption } from '@/object-metadata/types/FieldMetadataItem';
import { BAR_CHART_DATA } from '@/page-layout/widgets/graph/graphql/queries/barChartData';
Expand Down Expand Up @@ -57,8 +56,6 @@ export const useGraphBarChartWidgetData = ({
objectId: objectMetadataItemId,
});

const apolloCoreClient = useApolloCoreClient();

const dataConfiguration = useMemo(
() => extractBarChartDataConfiguration(configuration),
[configuration],
Expand All @@ -70,7 +67,6 @@ export const useGraphBarChartWidgetData = ({
loading,
error,
} = useQuery(BAR_CHART_DATA, {
client: apolloCoreClient,
variables: {
input: {
objectMetadataId: objectMetadataItemId,
Comment on lines 67 to 72
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.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById';
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { LINE_CHART_DATA } from '@/page-layout/widgets/graph/graphql/queries/lineChartData';
Expand Down Expand Up @@ -46,16 +45,13 @@ export const useGraphLineChartWidgetData = ({
objectId: objectMetadataItemId,
});

const apolloCoreClient = useApolloCoreClient();

const dataConfiguration = extractLineChartDataConfiguration(configuration);

const {
data: queryData,
loading,
error,
} = useQuery(LINE_CHART_DATA, {
client: apolloCoreClient,
variables: {
input: {
objectMetadataId: objectMetadataItemId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById';
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { PIE_CHART_DATA } from '@/page-layout/widgets/graph/graphql/queries/pieChartData';
Expand Down Expand Up @@ -42,8 +41,6 @@ export const useGraphPieChartWidgetData = ({
objectId: objectMetadataItemId,
});

const apolloCoreClient = useApolloCoreClient();

const dataConfiguration = useMemo(
() => extractPieChartDataConfiguration(configuration),
[configuration],
Expand All @@ -54,7 +51,6 @@ export const useGraphPieChartWidgetData = ({
loading,
error,
} = useQuery(PIE_CHART_DATA, {
client: apolloCoreClient,
variables: {
input: {
objectMetadataId: objectMetadataItemId,
Expand Down
Loading