Skip to content

Commit 48614a7

Browse files
committed
feat: remove modifyResponseExchange and restore graphqlClient to previous spec
1 parent ddf30ef commit 48614a7

File tree

5 files changed

+6
-98
lines changed

5 files changed

+6
-98
lines changed

apps/marketing/app/[locale]/[[...slug]]/page.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { TopicBusinessInfoFieldsFragment } from '#/components/topic-business-inf
1616
import { TopicProductFragment } from '#/components/topic-product/topic-product';
1717
import { addContentSourceMaps } from '#/lib/content-source-maps';
1818
import { graphqlClient } from '#/lib/graphql-client';
19-
import { getTaxonomyConcepts } from '#/lib/get-taxonomy-concepts';
2019
import { getLocaleFromPath } from '#/locales/get-locale-from-path';
2120
import { getStaticParams } from '#/locales/server';
2221

@@ -30,12 +29,6 @@ interface Params {
3029
}
3130

3231
const getPage = async (slug: string, locale: string, preview = false) => {
33-
const taxonomyConcepts = await getTaxonomyConcepts(process.env.CONTENTFUL_ORGANIZATION ?? '<missing organization>');
34-
const clientData = {
35-
locale,
36-
taxonomyConcepts,
37-
};
38-
3932
const pageQuery = graphql(
4033
`
4134
query PageQuery($slug: String, $locale: String, $preview: Boolean) @contentSourceMaps {
@@ -77,7 +70,7 @@ const getPage = async (slug: string, locale: string, preview = false) => {
7770
]
7871
);
7972

80-
const response = await graphqlClient({ preview, data: clientData }).query(pageQuery, {
73+
const response = await graphqlClient(preview).query(pageQuery, {
8174
locale,
8275
preview,
8376
slug,
@@ -100,7 +93,7 @@ const getPageSlugs = async (locale: string) => {
10093
}
10194
`);
10295

103-
const pages = await graphqlClient({ preview: false }).query(pageQuery, {
96+
const pages = await graphqlClient(false).query(pageQuery, {
10497
locale,
10598
});
10699

@@ -131,7 +124,7 @@ const getPageMetadata = async (slug: string, locale: string, preview = false): P
131124
[ComponentSEOFieldsFragment]
132125
);
133126

134-
const response = await graphqlClient({ preview }).query(pageQuery, {
127+
const response = await graphqlClient(preview).query(pageQuery, {
135128
locale,
136129
preview,
137130
slug,

apps/marketing/app/[locale]/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default async function RootLayout(props: { children: React.ReactNode; par
3939
[NavigationFieldsFragment]
4040
);
4141

42-
const layoutData = await graphqlClient({ preview: isDraftMode }).query(
42+
const layoutData = await graphqlClient(isDraftMode).query(
4343
layoutQuery,
4444
{
4545
locale: getLocaleFromPath(locale),

apps/marketing/lib/get-page-slug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const getPageSlug = async (slug: string, locale: string, preview = false) => {
1414
`);
1515

1616
return (
17-
await graphqlClient({ preview }).query(pageSlugQuery, {
17+
await graphqlClient(preview).query(pageSlugQuery, {
1818
locale,
1919
preview,
2020
slug,

apps/marketing/lib/graphql-client.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,10 @@ import { createClient, fetchExchange } from '@urql/core';
99
import { persistedExchange } from '@urql/exchange-persisted';
1010
import memoize from 'lodash/memoize';
1111
import { mapExchange } from 'urql';
12-
import type { ConceptProps } from 'contentful-management';
13-
14-
import { modifyResponseExchange } from './modify-response-exchange';
1512

1613
const graphqlEndpoint = `https://graphql.contentful.com/content/v1/spaces/${process.env.CONTENTFUL_SPACE ?? '<missing space>'}/environments/${process.env.CONTENTFUL_ENVIRONMENT ?? '<missing environment>'}`;
1714

18-
interface MakeClientProps {
19-
preview?: boolean;
20-
data?: {
21-
locale?: string;
22-
taxonomyConcepts?: ConceptProps[];
23-
};
24-
}
25-
26-
const makeClient = ({ preview, data = {} }: MakeClientProps) => {
27-
const { locale, taxonomyConcepts } = data;
15+
const makeClient = (preview: boolean) => {
2816
return createClient({
2917
url: `${graphqlEndpoint}?access_token=${(preview ? process.env.CONTENTFUL_PREVIEW_API : process.env.CONTENTFUL_DELIVERY_API) ?? '<missing token>'}`,
3018
exchanges: [
@@ -38,10 +26,6 @@ const makeClient = ({ preview, data = {} }: MakeClientProps) => {
3826
persistedExchange({
3927
preferGetForPersistedQueries: true,
4028
}),
41-
modifyResponseExchange({
42-
locale,
43-
taxonomyConcepts,
44-
}),
4529
/**
4630
* It map seem counter-intuitive, but exchanges are bi-directional, so mapExchange can both pass things to fetch,
4731
* as well as receive errors back from fetch on it's way back.

apps/marketing/lib/modify-response-exchange.ts

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)