Skip to content

Commit 94fe928

Browse files
authored
Merge pull request #120 from episerver/bugfix/CMS-43246-variation-small-bugs
Small bugfixes (variations)
2 parents 5e95a33 + e5c3631 commit 94fe928

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

packages/optimizely-cms-sdk/src/graph/createQuery.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ query GetContent($where: _ContentWhereInput, $variation: VariationInput) {
289289
item {
290290
__typename
291291
...${contentType}
292+
_metadata {
293+
variation
294+
}
292295
}
293296
}
294297
}

packages/optimizely-cms-sdk/src/graph/filters.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export function previewFilter(params: {
5151
},
5252
variation: {
5353
include: 'ALL',
54-
includeOriginal: true,
5554
},
5655
};
5756
}
@@ -69,13 +68,13 @@ export function variationFilter(value: string): ContentInput {
6968
* Arguments for querying content via the Graph API.
7069
*/
7170
export type ContentInput = {
72-
variation?: VariationInput;
71+
variation?: GraphVariationInput;
7372
where?: ContentWhereInput;
7473
};
7574

76-
export type VariationInput =
75+
export type GraphVariationInput =
7776
| { include: 'NONE' }
78-
| { include: 'ALL'; includeOriginal?: boolean }
77+
| { include: 'ALL' }
7978
| {
8079
include: 'SOME';
8180
value: string[];

packages/optimizely-cms-sdk/src/graph/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
ContentInput as GraphVariables,
1313
pathFilter,
1414
previewFilter,
15-
VariationInput,
15+
GraphVariationInput,
1616
} from './filters.js';
1717

1818
/** Options for Graph */
@@ -29,10 +29,12 @@ export type PreviewParams = {
2929
loc: string;
3030
};
3131

32-
type FetchContentOptions = {
33-
variation?: VariationInput;
32+
export type GraphGetContentOptions = {
33+
variation?: GraphVariationInput;
3434
};
3535

36+
export { GraphVariationInput };
37+
3638
const GET_CONTENT_METADATA_QUERY = `
3739
query GetContentMetadata($where: _ContentWhereInput, $variation: VariationInput) {
3840
_Content(where: $where, variation: $variation) {
@@ -187,7 +189,10 @@ export class GraphClient {
187189
*
188190
* @returns An iterator that traverses all found items
189191
*/
190-
async getContentByPath<T = any>(path: string, options?: FetchContentOptions) {
192+
async getContentByPath<T = any>(
193+
path: string,
194+
options?: GraphGetContentOptions
195+
) {
191196
const input: GraphVariables = {
192197
...pathFilter(path),
193198
variation: options?.variation,

packages/optimizely-cms-sdk/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ export {
88
initContentTypeRegistry,
99
initDisplayTemplateRegistry,
1010
} from './model/index.js';
11-
export { GraphClient } from './graph/index.js';
12-
export { createSingleContentQuery } from './graph/createQuery.js';
11+
export {
12+
GraphClient,
13+
GraphGetContentOptions,
14+
GraphVariationInput,
15+
} from './graph/index.js';
1316
export type { PreviewParams } from './graph/index.js';
1417
export {
1518
BlankSectionContentType,

0 commit comments

Comments
 (0)