Skip to content

Commit d69741a

Browse files
committed
Add empty headers to all graphql queries and mutations to fix the arg issue
1 parent 349bc9b commit d69741a

File tree

20 files changed

+402
-134
lines changed

20 files changed

+402
-134
lines changed

app/[locale]/(user)/categories/[categorySlug]/page.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
'use client';
22

3+
import { useEffect, useReducer, useState } from 'react';
4+
import Image from 'next/image';
5+
import { useRouter } from 'next/navigation';
36
import GraphqlPagination from '@/app/[locale]/dashboard/components/GraphqlPagination/graphqlPagination';
47
import { fetchDatasets } from '@/fetch';
58
import { graphql } from '@/gql';
69
import { useQuery } from '@tanstack/react-query';
7-
import Image from 'next/image';
8-
import { useRouter } from 'next/navigation';
910
import { Pill, SearchInput, Select, Text } from 'opub-ui';
10-
import { useEffect, useReducer, useState } from 'react';
1111

12+
import { GraphQL } from '@/lib/api';
1213
import BreadCrumbs from '@/components/BreadCrumbs';
1314
import { ErrorPage } from '@/components/error';
1415
import { Loading } from '@/components/loading';
15-
import { GraphQL } from '@/lib/api';
1616
import Card from '../../datasets/components/Card';
1717
import Filter from '../../datasets/components/FIlter/Filter';
1818

@@ -171,7 +171,13 @@ const CategoryDetailsPage = ({ params }: { params: { categorySlug: any } }) => {
171171
isLoading: boolean;
172172
isError: boolean;
173173
} = useQuery([`get_category_details_${params.categorySlug}`], () =>
174-
GraphQL(categoryQueryDoc, { filters: { slug: params.categorySlug } })
174+
GraphQL(
175+
categoryQueryDoc,
176+
{
177+
// Entity Headers if present
178+
},
179+
{ filters: { slug: params.categorySlug } }
180+
)
175181
);
176182

177183
const [facets, setFacets] = useState<{

app/[locale]/(user)/categories/page.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use client';
22

3-
import { graphql } from '@/gql';
4-
import { useQuery } from '@tanstack/react-query';
53
import Image from 'next/image';
64
import Link from 'next/link';
5+
import { graphql } from '@/gql';
6+
import { useQuery } from '@tanstack/react-query';
77
import { Text } from 'opub-ui';
88

9+
import { GraphQL } from '@/lib/api';
910
import BreadCrumbs from '@/components/BreadCrumbs';
1011
import { ErrorPage } from '@/components/error';
1112
import { Loading } from '@/components/loading';
12-
import { GraphQL } from '@/lib/api';
1313

1414
const categoriesListQueryDoc: any = graphql(`
1515
query CategoriesList {
@@ -30,7 +30,13 @@ const CategoriesListingPage = () => {
3030
error: any;
3131
isError: boolean;
3232
} = useQuery([`categories_list_page`], () =>
33-
GraphQL(categoriesListQueryDoc, [])
33+
GraphQL(
34+
categoriesListQueryDoc,
35+
{
36+
// Entity Headers if present
37+
},
38+
[]
39+
)
3440
);
3541

3642
return (

app/[locale]/(user)/datasets/[datasetIdentifier]/components/AccessModels/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,15 @@ const AccessModels = () => {
124124
const { data, error, isLoading } = useQuery(
125125
[`accessmodel_${params.datasetIdentifier}`],
126126
() =>
127-
GraphQL(accessModelResourcesQuery, {
128-
datasetId: params.datasetIdentifier,
129-
})
127+
GraphQL(
128+
accessModelResourcesQuery,
129+
{
130+
// Entity Headers if present
131+
},
132+
{
133+
datasetId: params.datasetIdentifier,
134+
}
135+
)
130136
);
131137

132138
return (

app/[locale]/(user)/datasets/[datasetIdentifier]/components/Details/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ const Details = () => {
4545
}: { data: any; isLoading: boolean; refetch: any } = useQuery(
4646
[`chartdata_${params.datasetIdentifier}`],
4747
() =>
48-
GraphQL(charts, {
49-
datasetId: params.datasetIdentifier,
50-
})
48+
GraphQL(
49+
charts,
50+
{
51+
// Entity Headers if present
52+
},
53+
{
54+
datasetId: params.datasetIdentifier,
55+
}
56+
)
5157
);
5258

5359
return (

app/[locale]/(user)/datasets/[datasetIdentifier]/components/Resources/index.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { useState, useEffect, useRef } from 'react';
3+
import { useEffect, useRef, useState } from 'react';
44
import Link from 'next/link';
55
import { useParams } from 'next/navigation';
66
import { graphql } from '@/gql';
@@ -49,12 +49,21 @@ const Resources = () => {
4949

5050
const { data, isLoading } = useQuery(
5151
[`resources_${params.datasetIdentifier}`],
52-
() => GraphQL(datasetResourceQuery, { datasetId: params.datasetIdentifier })
52+
() =>
53+
GraphQL(
54+
datasetResourceQuery,
55+
{
56+
// Entity Headers if present
57+
},
58+
{ datasetId: params.datasetIdentifier }
59+
)
5360
);
5461

5562
// Use an object to manage the expanded state for each resource individually
5663
const [showMore, setShowMore] = useState<{ [key: number]: boolean }>({});
57-
const [isDescriptionLong, setIsDescriptionLong] = useState<{ [key: number]: boolean }>({});
64+
const [isDescriptionLong, setIsDescriptionLong] = useState<{
65+
[key: number]: boolean;
66+
}>({});
5867

5968
const descriptionRefs = useRef<(HTMLDivElement | null)[]>([]);
6069

@@ -70,7 +79,8 @@ const Resources = () => {
7079
useEffect(() => {
7180
descriptionRefs.current.forEach((descriptionElement, index) => {
7281
if (descriptionElement) {
73-
const isLong = descriptionElement.scrollHeight > descriptionElement.clientHeight;
82+
const isLong =
83+
descriptionElement.scrollHeight > descriptionElement.clientHeight;
7484
setIsDescriptionLong((prevState) => ({
7585
...prevState,
7686
[index]: isLong,
@@ -90,11 +100,11 @@ const Resources = () => {
90100
<Text variant="bodyLg" className="mx-6 lg:mx-0">
91101
Downloadable Resources
92102
</Text>
93-
<div className="mx-6 lg:mx-0 mt-5 flex flex-col gap-8 bg-surfaceDefault p-6">
103+
<div className="mx-6 mt-5 flex flex-col gap-8 bg-surfaceDefault p-6 lg:mx-0">
94104
{data?.datasetResources.map((item: any, index: number) => (
95105
<div key={index} className="flex flex-wrap justify-between gap-4">
96106
<div className="gap flex flex-col lg:w-4/5">
97-
<div className="item flex gap-2 items-center">
107+
<div className="item flex items-center gap-2">
98108
<Text variant="headingMd">{item.name}</Text>
99109
<Tag>{item.fileDetails.format}</Tag>
100110
</div>

app/[locale]/(user)/datasets/[datasetIdentifier]/page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ const DatasetDetailsPage = () => {
5555
const params = useParams();
5656

5757
const { data, isLoading } = useQuery([`${params.datasetIdentifier}`], () =>
58-
GraphQL(datasetQuery, { filters: { id: params.datasetIdentifier } })
58+
GraphQL(
59+
datasetQuery,
60+
{
61+
// Entity Headers if present
62+
},
63+
{ filters: { id: params.datasetIdentifier } }
64+
)
5965
);
6066

6167
return (

app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/charts/components/ChartsList.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,15 @@ const ChartsList: React.FC<ChartsListProps> = ({
5353
}: { data: any; isLoading: boolean; refetch: any } = useQuery(
5454
[`chartDetails_${params.id}`],
5555
() =>
56-
GraphQL(chartDetailsQuery, {
57-
datasetId: params.id,
58-
})
56+
GraphQL(
57+
chartDetailsQuery,
58+
{
59+
// Entity Headers if present
60+
},
61+
{
62+
datasetId: params.id,
63+
}
64+
)
5965
);
6066

6167
const [filteredRows, setFilteredRows] = useState<any[]>([]);
@@ -68,7 +74,14 @@ const ChartsList: React.FC<ChartsListProps> = ({
6874
}, [data, type]);
6975

7076
const { mutate, isLoading: deleteLoading } = useMutation(
71-
(data: { chartId: UUID }) => GraphQL(deleteResourceChart, data),
77+
(data: { chartId: UUID }) =>
78+
GraphQL(
79+
deleteResourceChart,
80+
{
81+
// Entity Headers if present
82+
},
83+
data
84+
),
7285
{
7386
onSuccess: () => {
7487
toast('Chart Deleted Successfully');

app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/charts/components/ChartsVisualize.tsx

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,25 @@ const ChartsVisualize: React.FC<VisualizationProps> = ({
129129
}) => {
130130
const params = useParams();
131131
const { data }: { data: any } = useQuery([`charts_${params.id}`], () =>
132-
GraphQL(datasetResource, { datasetId: params.id })
132+
GraphQL(
133+
datasetResource,
134+
{
135+
// Entity Headers if present
136+
},
137+
{ datasetId: params.id }
138+
)
133139
);
134140

135141
const { data: chartDetails, refetch }: { data: any; refetch: any } = useQuery(
136142
[`chartsdata_${params.id}`],
137-
() => GraphQL(getResourceChartDetails, { chartDetailsId: chartId }),
143+
() =>
144+
GraphQL(
145+
getResourceChartDetails,
146+
{
147+
// Entity Headers if present
148+
},
149+
{ chartDetailsId: chartId }
150+
),
138151
{
139152
enabled: !!chartId, // Fetch only if chartId is available
140153
}
@@ -146,9 +159,15 @@ const ChartsVisualize: React.FC<VisualizationProps> = ({
146159
}: { data: any; isLoading: boolean; refetch: any } = useQuery(
147160
[`chartsList_${params.id}`],
148161
() =>
149-
GraphQL(chartDetailsQuery, {
150-
datasetId: params.id,
151-
})
162+
GraphQL(
163+
chartDetailsQuery,
164+
{
165+
// Entity Headers if present
166+
},
167+
{
168+
datasetId: params.id,
169+
}
170+
)
152171
);
153172

154173
const [isSheetOpen, setIsSheetOpen] = useState(false);
@@ -223,7 +242,13 @@ const ChartsVisualize: React.FC<VisualizationProps> = ({
223242

224243
const { mutate, isLoading: editMutationLoading } = useMutation(
225244
(chartInput: { chartInput: ResourceChartInput }) =>
226-
GraphQL(createChart, chartInput),
245+
GraphQL(
246+
createChart,
247+
{
248+
// Entity Headers if present
249+
},
250+
chartInput
251+
),
227252
{
228253
onSuccess: (res: any) => {
229254
toast('Resource chart saved');

app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/components/AccessModelForm.tsx

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,14 @@ const AccessModelForm: React.FC<AccessModelProps> = ({
105105
const params = useParams();
106106
const { data, isLoading }: { data: any; isLoading: boolean } = useQuery(
107107
[`resourcesList_${params.id}`],
108-
() => GraphQL(datasetResourcesQuery, { datasetId: params.id })
108+
() =>
109+
GraphQL(
110+
datasetResourcesQuery,
111+
{
112+
// Entity Headers if present
113+
},
114+
{ datasetId: params.id }
115+
)
109116
);
110117

111118
const {
@@ -114,15 +121,29 @@ const AccessModelForm: React.FC<AccessModelProps> = ({
114121
refetch: accessModelListRefetch,
115122
}: { data: any; isLoading: boolean; refetch: any } = useQuery(
116123
[`accessModelList_${params.id}`],
117-
() => GraphQL(accessModelListQuery, { datasetId: params.id })
124+
() =>
125+
GraphQL(
126+
accessModelListQuery,
127+
{
128+
// Entity Headers if present
129+
},
130+
{ datasetId: params.id }
131+
)
118132
);
119133
const {
120134
data: accessModelDetails,
121135
refetch: accessModelDetailsRefetch,
122136
isLoading: accessModelDetailsLoading,
123137
}: { data: any; isLoading: boolean; refetch: any } = useQuery(
124138
[`accessModelDetails${params.id}`],
125-
() => GraphQL(getAccessModelDetails, { accessModelId: accessModelId })
139+
() =>
140+
GraphQL(
141+
getAccessModelDetails,
142+
{
143+
// Entity Headers if present
144+
},
145+
{ accessModelId: accessModelId }
146+
)
126147
);
127148

128149
const [accessModelData, setAccessModelData] = useState({
@@ -288,7 +309,13 @@ const AccessModelForm: React.FC<AccessModelProps> = ({
288309

289310
const { mutate, isLoading: editMutationLoading } = useMutation(
290311
(data: { accessModelInput: EditAccessModelInput }) =>
291-
GraphQL(editaccessModel, data),
312+
GraphQL(
313+
editaccessModel,
314+
{
315+
// Entity Headers if present
316+
},
317+
data
318+
),
292319
{
293320
onSuccess: (res: any) => {
294321
// toast('Access Model Saved');

app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/components/AccessModelList.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,15 @@ const AccessModelList: React.FC<AccessModelListProps> = ({
5757
}: { data: any; isLoading: boolean; refetch: any } = useQuery(
5858
[`accessModelList_${params.id}`],
5959
() =>
60-
GraphQL(accessModelQuery, {
61-
datasetId: params.id,
62-
})
60+
GraphQL(
61+
accessModelQuery,
62+
{
63+
// Entity Headers if present
64+
},
65+
{
66+
datasetId: params.id,
67+
}
68+
)
6369
);
6470

6571
const [filteredRows, setFilteredRows] = useState<any[]>([]);
@@ -72,7 +78,14 @@ const AccessModelList: React.FC<AccessModelListProps> = ({
7278
}, [data, list]);
7379

7480
const { mutate, isLoading: deleteLoading } = useMutation(
75-
(data: { accessModelId: UUID }) => GraphQL(deleteAccessModel, data),
81+
(data: { accessModelId: UUID }) =>
82+
GraphQL(
83+
deleteAccessModel,
84+
{
85+
// Entity Headers if present
86+
},
87+
data
88+
),
7689
{
7790
onSuccess: () => {
7891
toast('Access Model Deleted Successfully');

0 commit comments

Comments
 (0)