From 3406c60ab565a6b046eb1be5045a8a31f9994728 Mon Sep 17 00:00:00 2001 From: Carlos Saito Date: Thu, 7 Aug 2025 16:23:43 +0200 Subject: [PATCH 1/7] Define and use filters --- .../src/graph/createQuery.ts | 4 +- .../optimizely-cms-sdk/src/graph/filters.ts | 178 ++++++++++++++++++ .../optimizely-cms-sdk/src/graph/index.ts | 33 ++-- 3 files changed, 195 insertions(+), 20 deletions(-) create mode 100644 packages/optimizely-cms-sdk/src/graph/filters.ts diff --git a/packages/optimizely-cms-sdk/src/graph/createQuery.ts b/packages/optimizely-cms-sdk/src/graph/createQuery.ts index 0178d14..3e83c18 100644 --- a/packages/optimizely-cms-sdk/src/graph/createQuery.ts +++ b/packages/optimizely-cms-sdk/src/graph/createQuery.ts @@ -252,8 +252,8 @@ export function createQuery(contentType: string) { return ` ${fragment.join('\n')} -query FetchContent($filter: _ContentWhereInput) { - _Content(where: $filter) { +query FetchContent($where: _ContentWhereInput, $variation: VariationInput) { + _Content(where: $where, variation: $variation) { item { __typename ...${contentType} diff --git a/packages/optimizely-cms-sdk/src/graph/filters.ts b/packages/optimizely-cms-sdk/src/graph/filters.ts new file mode 100644 index 0000000..b4d904b --- /dev/null +++ b/packages/optimizely-cms-sdk/src/graph/filters.ts @@ -0,0 +1,178 @@ +/** + * This module contains the TypeScript definitions of a Graph Query + * and functions to build those filters based on path, + * preview parameters, etc. + */ + +/** + * Creates a {@linkcode ContentInput} object that filters results by a specific URL path. + * + * @param path - The URL path to filter by. + * @returns A `GraphQueryArguments` object with a `where` clause that matches the given path. + */ +export function pathFilter(path: string): ContentInput { + return { + where: { + _metadata: { + url: { + default: { + eq: path, + }, + }, + }, + }, + }; +} + +/** + * Creates a {@linkcode ContentInput} object for previewing content based on key, version, and locale. + * + * @param params - An object containing the following properties: + * @param params.key - The unique key identifying the content. + * @param params.ver - The version of the content to preview. + * @param params.loc - The locale of the content to preview. + * + * @returns A `GraphQueryArguments` object with a `where` clause filtering by key, version, and locale. + */ +export function previewFilter(params: { + key: string; + ver: string; + loc: string; +}): ContentInput { + return { + where: { + _metadata: { + key: { eq: params.key }, + version: { eq: params.ver }, + locale: { eq: params.loc }, + }, + }, + }; +} + +export function variationsFilter( + values?: string | (string | undefined | null)[], + includeOriginal?: boolean +): ContentInput { + if (!values) { + return { + variation: { + include: 'ALL', + }, + }; + } + + if (typeof values === 'string') { + return { + variation: { + include: 'SOME', + value: [values], + includeOriginal: includeOriginal ?? true, + }, + }; + } + + const notNulls = values.filter((v) => typeof v === 'string'); + + return { + variation: { + include: 'SOME', + value: notNulls, + includeOriginal: notNulls.length !== values.length, + }, + }; +} + +/** + * Arguments for querying content via the Graph API. + */ +export type ContentInput = { + variation?: VariationInput; + where?: ContentWhereInput; +}; + +type VariationInput = { + include?: VariationIncludeMode; + value?: string[]; + includeOriginal?: boolean; +}; + +type VariationIncludeMode = 'ALL' | 'SOME' | 'NONE'; + +type ContentWhereInput = { + _and?: ContentWhereInput[]; + _or?: ContentWhereInput[]; + _fulltext?: StringFilterInput; + _modified?: DateFilterInput; + _metadata?: IContentMetadataWhereInput; +}; + +type StringFilterInput = ScalarFilterInput & { + like?: string; + startsWith?: string; + endsWith?: string; + in?: string[]; + notIn?: string[]; + match?: string; + contains?: string; + synonyms?: ('ONE' | 'TWO')[]; + fuzzly?: boolean; +}; + +type DateFilterInput = ScalarFilterInput & { + gt?: string; + gte?: string; + lt?: string; + lte?: string; + decay?: { + origin?: string; + scale?: number; + rate?: number; + }; +}; + +type IContentMetadataWhereInput = { + key?: StringFilterInput; + locale?: StringFilterInput; + fallbackForLocale?: StringFilterInput; + version?: StringFilterInput; + displayName?: StringFilterInput; + url?: ContentUrlInput; + types?: StringFilterInput; + published?: DateFilterInput; + status?: StringFilterInput; + changeset?: StringFilterInput; + created?: DateFilterInput; + lastModified?: DateFilterInput; + sortOrder?: IntFilterInput; + variation?: StringFilterInput; +}; + +type IntFilterInput = ScalarFilterInput & { + gt?: number; + gte?: number; + lt?: number; + lte?: number; + in?: number[]; + notIn?: number[]; + factor?: { + value?: number; + modifier?: 'NONE' | 'SQUARE' | 'SQRT' | 'LOG' | 'RECIPROCAL'; + }; +}; + +type ContentUrlInput = { + type?: T; + default?: T; + hierarchical?: T; + internal?: T; + graph?: T; + base?: T; +}; + +type ScalarFilterInput = { + eq?: T; + notEq?: T; + exist?: boolean; + boost?: number; +}; diff --git a/packages/optimizely-cms-sdk/src/graph/index.ts b/packages/optimizely-cms-sdk/src/graph/index.ts index e7c9cce..21b4f33 100644 --- a/packages/optimizely-cms-sdk/src/graph/index.ts +++ b/packages/optimizely-cms-sdk/src/graph/index.ts @@ -4,6 +4,12 @@ import { GraphHttpResponseError, GraphResponseError, } from './error.js'; +import { + ContentInput, + pathFilter, + previewFilter, + variationsFilter, +} from './filters.js'; /** Options for Graph */ type GraphOptions = { @@ -31,8 +37,8 @@ export type GraphVariables = { }; const FETCH_CONTENT_TYPE_QUERY = ` -query FetchContentType($filter: _ContentWhereInput) { - _Content(where: $filter) { +query FetchContentType($where: _ContentWhereInput, $variation: VariationInput) { + _Content(where: $where, variation: $variation) { item { _metadata { types @@ -91,11 +97,7 @@ export class GraphClient { } /** Perform a GraphQL query with variables */ - async request( - query: string, - variables: GraphVariables, - previewToken?: string - ) { + async request(query: string, variables: ContentInput, previewToken?: string) { const url = new URL(this.graphUrl); if (!previewToken) { @@ -150,10 +152,10 @@ export class GraphClient { } /** Fetches the content type of a content. Returns `undefined` if the content doesn't exist */ - async fetchContentType(filter: GraphFilter, previewToken?: string) { + private async fetchContentType(input: ContentInput, previewToken?: string) { const data = await this.request( FETCH_CONTENT_TYPE_QUERY, - { filter }, + input, previewToken ); @@ -181,25 +183,20 @@ export class GraphClient { /** Fetches a content given the preview parameters (preview_token, ctx, ver, loc, key) */ async fetchPreviewContent(params: PreviewParams) { - const filter = getFilterFromPreviewParams(params); + const input = previewFilter(params); const contentTypeName = await this.fetchContentType( - filter, + input, params.preview_token ); if (!contentTypeName) { throw new GraphResponseError( `No content found for key [${params.key}]. Check that your CMS contains something there`, - { request: { variables: { filter }, query: FETCH_CONTENT_TYPE_QUERY } } + { request: { variables: input, query: FETCH_CONTENT_TYPE_QUERY } } ); } const query = createQuery(contentTypeName); - - const response = await this.request( - query, - { filter }, - params.preview_token - ); + const response = await this.request(query, input, params.preview_token); return decorateWithContext(response?._Content?.item, params); } From a822db4b0fd276020e44a94a3a6d8ec8694ac6a0 Mon Sep 17 00:00:00 2001 From: Carlos Saito Date: Thu, 7 Aug 2025 16:24:12 +0200 Subject: [PATCH 2/7] Extend fetchContent function --- .../optimizely-cms-sdk/src/graph/index.ts | 62 +++++++------------ 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/packages/optimizely-cms-sdk/src/graph/index.ts b/packages/optimizely-cms-sdk/src/graph/index.ts index 21b4f33..cc7bfe3 100644 --- a/packages/optimizely-cms-sdk/src/graph/index.ts +++ b/packages/optimizely-cms-sdk/src/graph/index.ts @@ -25,16 +25,13 @@ export type PreviewParams = { loc: string; }; -// TODO: this type definition is provisional -export type GraphFilter = { - _metadata: { - [key: string]: any; - }; -}; - -export type GraphVariables = { - filter: GraphFilter; -}; +/** Arguments for the method `fetchContent` */ +type PathOrOptions = + | string + | { + path: string; + variation: string; + }; const FETCH_CONTENT_TYPE_QUERY = ` query FetchContentType($where: _ContentWhereInput, $variation: VariationInput) { @@ -48,26 +45,6 @@ query FetchContentType($where: _ContentWhereInput, $variation: VariationInput) { } `; -export function getFilterFromPreviewParams(params: PreviewParams): GraphFilter { - return { - _metadata: { - key: { eq: params.key }, - version: { eq: params.ver }, - locale: { eq: params.loc }, - }, - }; -} - -export function getFilterFromPath(path: string): GraphFilter { - return { - _metadata: { - url: { - default: { eq: path }, - }, - }, - }; -} - /** Adds an extra `__context` property next to each `__typename` property */ function decorateWithContext(obj: any, params: PreviewParams): any { if (Array.isArray(obj)) { @@ -163,20 +140,29 @@ export class GraphClient { } /** Fetches a content given its path */ - async fetchContent(path: string) { - const filter = getFilterFromPath(path); - const contentTypeName = await this.fetchContentType(filter); + async fetchContent(options: PathOrOptions) { + let input: ContentInput; + + if (typeof options === 'string') { + input = pathFilter(options); + } else { + input = { + ...pathFilter(options.path), + ...variationsFilter(options.variation), + }; + } + + const contentTypeName = await this.fetchContentType(input); if (!contentTypeName) { - throw new GraphResponseError( - `No content found for path [${path}]. Check that your CMS contains something in the given path`, - { request: { variables: { filter }, query: FETCH_CONTENT_TYPE_QUERY } } - ); + throw new GraphResponseError(`No content found.`, { + request: { variables: input, query: FETCH_CONTENT_TYPE_QUERY }, + }); } const query = createQuery(contentTypeName); - const response = await this.request(query, { filter }); + const response = await this.request(query, input); return response?._Content?.item; } From 87374df1935bc8277bc61a6e825796fa1fa7d66d Mon Sep 17 00:00:00 2001 From: Carlos Saito Date: Thu, 7 Aug 2025 16:29:11 +0200 Subject: [PATCH 3/7] Rename and document --- .../optimizely-cms-sdk/src/graph/index.ts | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/packages/optimizely-cms-sdk/src/graph/index.ts b/packages/optimizely-cms-sdk/src/graph/index.ts index cc7bfe3..7a81259 100644 --- a/packages/optimizely-cms-sdk/src/graph/index.ts +++ b/packages/optimizely-cms-sdk/src/graph/index.ts @@ -26,12 +26,10 @@ export type PreviewParams = { }; /** Arguments for the method `fetchContent` */ -type PathOrOptions = - | string - | { - path: string; - variation: string; - }; +type FetchContentOptions = { + path: string; + variation: string; +}; const FETCH_CONTENT_TYPE_QUERY = ` query FetchContentType($where: _ContentWhereInput, $variation: VariationInput) { @@ -128,7 +126,13 @@ export class GraphClient { return json.data; } - /** Fetches the content type of a content. Returns `undefined` if the content doesn't exist */ + /** + * Fetches the content type metadata for a given content input. + * + * @param input - The content input used to query the content type. + * @param previewToken - Optional preview token for fetching preview content. + * @returns A promise that resolves to the first content type metadata object, or `undefined` if not found. + */ private async fetchContentType(input: ContentInput, previewToken?: string) { const data = await this.request( FETCH_CONTENT_TYPE_QUERY, @@ -139,8 +143,18 @@ export class GraphClient { return data._Content?.item?._metadata?.types?.[0]; } - /** Fetches a content given its path */ - async fetchContent(options: PathOrOptions) { + /** + * Fetches content from the CMS based on the provided path or options. + * + * If a string is provided, it is treated as a content path. If an object is provided, + * it may include both a path and a variation to filter the content. + * + * @param options - A string representing the content path, + * or an {@linkcode FetchContentOptions} containing path and variation filters. + * + * @returns A promise that resolves to the fetched content item. + */ + async fetchContent(options: string | FetchContentOptions) { let input: ContentInput; if (typeof options === 'string') { From 97d6a62bb6a1d2592e0ff388eff918e0d78ace98 Mon Sep 17 00:00:00 2001 From: Carlos Saito Date: Fri, 8 Aug 2025 10:33:10 +0200 Subject: [PATCH 4/7] Expose fetchContentType(path), remove other internal methods --- .../optimizely-cms-sdk/src/graph/error.ts | 4 +- .../optimizely-cms-sdk/src/graph/filters.ts | 2 + .../optimizely-cms-sdk/src/graph/index.ts | 69 +++++++++++++------ packages/optimizely-cms-sdk/src/index.ts | 2 +- .../src/app/json/[...slug]/page.tsx | 8 +-- 5 files changed, 56 insertions(+), 29 deletions(-) diff --git a/packages/optimizely-cms-sdk/src/graph/error.ts b/packages/optimizely-cms-sdk/src/graph/error.ts index 2d059a0..7fdda4e 100644 --- a/packages/optimizely-cms-sdk/src/graph/error.ts +++ b/packages/optimizely-cms-sdk/src/graph/error.ts @@ -1,4 +1,4 @@ -import type { GraphVariables } from './index.js'; +import type { ContentInput } from './filters.js'; /** Represents the request sent to graph */ type GraphRequest = { @@ -6,7 +6,7 @@ type GraphRequest = { query: string; /** Variables sent to Graph */ - variables: GraphVariables; + variables: ContentInput; }; /** Super-class for all errors related to Optimizely Graph */ diff --git a/packages/optimizely-cms-sdk/src/graph/filters.ts b/packages/optimizely-cms-sdk/src/graph/filters.ts index b4d904b..6c17be2 100644 --- a/packages/optimizely-cms-sdk/src/graph/filters.ts +++ b/packages/optimizely-cms-sdk/src/graph/filters.ts @@ -2,6 +2,8 @@ * This module contains the TypeScript definitions of a Graph Query * and functions to build those filters based on path, * preview parameters, etc. + * + * This is used internally in the SDK */ /** diff --git a/packages/optimizely-cms-sdk/src/graph/index.ts b/packages/optimizely-cms-sdk/src/graph/index.ts index 7a81259..051c078 100644 --- a/packages/optimizely-cms-sdk/src/graph/index.ts +++ b/packages/optimizely-cms-sdk/src/graph/index.ts @@ -5,7 +5,7 @@ import { GraphResponseError, } from './error.js'; import { - ContentInput, + ContentInput as GraphVariables, pathFilter, previewFilter, variationsFilter, @@ -25,12 +25,35 @@ export type PreviewParams = { loc: string; }; -/** Arguments for the method `fetchContent` */ +/** Arguments for the public methods `fetchContent`, `fetchContentType` */ type FetchContentOptions = { - path: string; - variation: string; + path?: string; + variation?: string; }; +/** + * Builds the variables object for a GraphQL query based on the provided options. + * + * If a string is provided, it is treated as a path and passed to `pathFilter`. + * If an object is provided, it may contain `path` and/or `variation` properties, + * which are processed by `pathFilter` and `variationsFilter` respectively. + * + * @param options - Either a string representing the content path, or an object containing fetch options. + * @returns A `GraphVariables` object containing the appropriate filters for the query. + */ +function buildGraphVariables( + options: string | FetchContentOptions +): GraphVariables { + if (typeof options === 'string') { + return pathFilter(options); + } + + return { + ...(options.path && pathFilter(options.path)), + ...(options.variation && variationsFilter(options.variation)), + }; +} + const FETCH_CONTENT_TYPE_QUERY = ` query FetchContentType($where: _ContentWhereInput, $variation: VariationInput) { _Content(where: $where, variation: $variation) { @@ -72,7 +95,11 @@ export class GraphClient { } /** Perform a GraphQL query with variables */ - async request(query: string, variables: ContentInput, previewToken?: string) { + async request( + query: string, + variables: GraphVariables, + previewToken?: string + ) { const url = new URL(this.graphUrl); if (!previewToken) { @@ -133,7 +160,7 @@ export class GraphClient { * @param previewToken - Optional preview token for fetching preview content. * @returns A promise that resolves to the first content type metadata object, or `undefined` if not found. */ - private async fetchContentType(input: ContentInput, previewToken?: string) { + private async getContentType(input: GraphVariables, previewToken?: string) { const data = await this.request( FETCH_CONTENT_TYPE_QUERY, input, @@ -143,6 +170,19 @@ export class GraphClient { return data._Content?.item?._metadata?.types?.[0]; } + /** + * Fetches a content type from the CMS using the provided options. + * + * @param options - A string representing the content path, + * or an {@linkcode FetchContentOptions} containing path and variation filters. + * @returns A promise that resolves to the requested content type. + */ + async fetchContentType(options: string | FetchContentOptions) { + let input: GraphVariables = buildGraphVariables(options); + + return this.getContentType(input); + } + /** * Fetches content from the CMS based on the provided path or options. * @@ -155,18 +195,8 @@ export class GraphClient { * @returns A promise that resolves to the fetched content item. */ async fetchContent(options: string | FetchContentOptions) { - let input: ContentInput; - - if (typeof options === 'string') { - input = pathFilter(options); - } else { - input = { - ...pathFilter(options.path), - ...variationsFilter(options.variation), - }; - } - - const contentTypeName = await this.fetchContentType(input); + const input: GraphVariables = buildGraphVariables(options); + const contentTypeName = await this.getContentType(input); if (!contentTypeName) { throw new GraphResponseError(`No content found.`, { @@ -175,7 +205,6 @@ export class GraphClient { } const query = createQuery(contentTypeName); - const response = await this.request(query, input); return response?._Content?.item; @@ -184,7 +213,7 @@ export class GraphClient { /** Fetches a content given the preview parameters (preview_token, ctx, ver, loc, key) */ async fetchPreviewContent(params: PreviewParams) { const input = previewFilter(params); - const contentTypeName = await this.fetchContentType( + const contentTypeName = await this.getContentType( input, params.preview_token ); diff --git a/packages/optimizely-cms-sdk/src/index.ts b/packages/optimizely-cms-sdk/src/index.ts index 226de4b..c806d5c 100644 --- a/packages/optimizely-cms-sdk/src/index.ts +++ b/packages/optimizely-cms-sdk/src/index.ts @@ -8,7 +8,7 @@ export { initContentTypeRegistry, initDisplayTemplateRegistry, } from './model/index.js'; -export { GraphClient, getFilterFromPath } from './graph/index.js'; +export { GraphClient } from './graph/index.js'; export { createQuery } from './graph/createQuery.js'; export type { PreviewParams } from './graph/index.js'; export { diff --git a/samples/nextjs-template/src/app/json/[...slug]/page.tsx b/samples/nextjs-template/src/app/json/[...slug]/page.tsx index 57caa28..5b8698d 100644 --- a/samples/nextjs-template/src/app/json/[...slug]/page.tsx +++ b/samples/nextjs-template/src/app/json/[...slug]/page.tsx @@ -1,8 +1,4 @@ -import { - getFilterFromPath, - GraphClient, - GraphErrors, -} from '@episerver/cms-sdk'; +import { GraphClient, GraphErrors } from '@episerver/cms-sdk'; import { createQuery } from '@episerver/cms-sdk'; type Props = { @@ -36,7 +32,7 @@ export default async function Page({ params }: Props) { // Note: this is shown for demo purposes. // `fetchContentType` and `createQuery` are not needed const contentType = await client - .fetchContentType(getFilterFromPath(path)) + .fetchContentType(path) .catch(handleGraphErrors); const query = createQuery(contentType); const response = await client.fetchContent(path).catch(handleGraphErrors); From 1dc24a39e9b27b68230910ad383d960fa49b6b6b Mon Sep 17 00:00:00 2001 From: Carlos Saito Date: Fri, 8 Aug 2025 10:43:31 +0200 Subject: [PATCH 5/7] Simplify variation --- .../optimizely-cms-sdk/src/graph/filters.ts | 28 ++----------------- .../optimizely-cms-sdk/src/graph/index.ts | 4 +-- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/packages/optimizely-cms-sdk/src/graph/filters.ts b/packages/optimizely-cms-sdk/src/graph/filters.ts index 6c17be2..cfc4b94 100644 --- a/packages/optimizely-cms-sdk/src/graph/filters.ts +++ b/packages/optimizely-cms-sdk/src/graph/filters.ts @@ -52,35 +52,11 @@ export function previewFilter(params: { }; } -export function variationsFilter( - values?: string | (string | undefined | null)[], - includeOriginal?: boolean -): ContentInput { - if (!values) { - return { - variation: { - include: 'ALL', - }, - }; - } - - if (typeof values === 'string') { - return { - variation: { - include: 'SOME', - value: [values], - includeOriginal: includeOriginal ?? true, - }, - }; - } - - const notNulls = values.filter((v) => typeof v === 'string'); - +export function variationFilter(value: string): ContentInput { return { variation: { include: 'SOME', - value: notNulls, - includeOriginal: notNulls.length !== values.length, + value: [value], }, }; } diff --git a/packages/optimizely-cms-sdk/src/graph/index.ts b/packages/optimizely-cms-sdk/src/graph/index.ts index 051c078..4e95741 100644 --- a/packages/optimizely-cms-sdk/src/graph/index.ts +++ b/packages/optimizely-cms-sdk/src/graph/index.ts @@ -8,7 +8,7 @@ import { ContentInput as GraphVariables, pathFilter, previewFilter, - variationsFilter, + variationFilter, } from './filters.js'; /** Options for Graph */ @@ -50,7 +50,7 @@ function buildGraphVariables( return { ...(options.path && pathFilter(options.path)), - ...(options.variation && variationsFilter(options.variation)), + ...(options.variation && variationFilter(options.variation)), }; } From 3b8763663a5f0a5906b9b81c42391c7b070c0923 Mon Sep 17 00:00:00 2001 From: Carlos Saito Date: Fri, 8 Aug 2025 11:01:22 +0200 Subject: [PATCH 6/7] Update test website --- .../test-website/src/app/[...slug]/page.tsx | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/__test__/test-website/src/app/[...slug]/page.tsx b/__test__/test-website/src/app/[...slug]/page.tsx index ddcccf2..02a60ae 100644 --- a/__test__/test-website/src/app/[...slug]/page.tsx +++ b/__test__/test-website/src/app/[...slug]/page.tsx @@ -1,4 +1,4 @@ -import { GraphClient } from '@episerver/cms-sdk'; +import { GraphClient, GraphErrors } from '@episerver/cms-sdk'; import { OptimizelyComponent } from '@episerver/cms-sdk/react/server'; import React from 'react'; @@ -6,15 +6,36 @@ type Props = { params: Promise<{ slug: string[]; }>; + // Assume that search params are correct: + searchParams: Promise<{ variation?: string }>; }; -export default async function Page({ params }: Props) { +function handleGraphErrors(err: unknown): never { + if (err instanceof GraphErrors.GraphResponseError) { + console.log('Error message:', err.message); + console.log('Query:', err.request.query); + console.log('Variables:', err.request.variables); + } + if (err instanceof GraphErrors.GraphContentResponseError) { + console.log('Detailed errors: ', err.errors); + } + + throw err; +} + +export default async function Page({ params, searchParams }: Props) { const { slug } = await params; + const { variation } = await searchParams; const client = new GraphClient(process.env.OPTIMIZELY_GRAPH_SINGLE_KEY!, { graphUrl: process.env.OPTIMIZELY_GRAPH_URL, }); - const c = await client.fetchContent(`/${slug.join('/')}/`); - return ; + const path = `/${slug.join('/')}/`; + + const content = variation + ? await client.fetchContent({ path, variation }).catch(handleGraphErrors) + : await client.fetchContent(path).catch(handleGraphErrors); + + return ; } From 38c9f24f07ba87c65b2346d12f6206dbb394c149 Mon Sep 17 00:00:00 2001 From: Carlos Saito Date: Fri, 8 Aug 2025 15:38:34 +0200 Subject: [PATCH 7/7] Update test site --- __test__/test-website/src/app/[...slug]/page.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/__test__/test-website/src/app/[...slug]/page.tsx b/__test__/test-website/src/app/[...slug]/page.tsx index 02a60ae..0a58928 100644 --- a/__test__/test-website/src/app/[...slug]/page.tsx +++ b/__test__/test-website/src/app/[...slug]/page.tsx @@ -31,11 +31,9 @@ export default async function Page({ params, searchParams }: Props) { graphUrl: process.env.OPTIMIZELY_GRAPH_URL, }); - const path = `/${slug.join('/')}/`; - - const content = variation - ? await client.fetchContent({ path, variation }).catch(handleGraphErrors) - : await client.fetchContent(path).catch(handleGraphErrors); + const content = await client + .fetchContent({ path: `/${slug.join('/')}/`, variation }) + .catch(handleGraphErrors); return ; }