@remkoj/optimizely-graph-functions 6.0.0-pre10 → 6.0.0-pre12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Optimizely GraphQL Codegen Plugin
1
+ # Optimizely GraphQL Codegen Plugin <!-- omit in toc -->
2
2
  GraphQL Codegen plugin and preset which generate both the GraphQL type definitions and a few convenienece methods for useage with [Optimizely Graph Client](../optimizely-graph-client/README.md).
3
3
 
4
4
  [Release notes](https://github.com/remkoj/optimizely-dxp-clients/releases)
@@ -6,7 +6,22 @@ GraphQL Codegen plugin and preset which generate both the GraphQL type definitio
6
6
  > [!WARNING]
7
7
  > The GraphQL Codegen preset requires a patch to enable it to work with recursive queries. Make sure to run this command after every update to ensure you're using the latest patches: `yarn opti-graph patches:apply`. Adjust when used in a mono-repo to patch the correct package.json, for example: `yarn workspace frontend opti-graph patches:apply -p ../../`
8
8
 
9
- ## Install package
9
+ ## Contents <!-- omit in toc -->
10
+ - [1. Install package](#1-install-package)
11
+ - [2. Configure package](#2-configure-package)
12
+ - [3. GraphQL Document Processing](#3-graphql-document-processing)
13
+ - [3.1. Allow overwriting of built-in fragments \& queries](#31-allow-overwriting-of-built-in-fragments--queries)
14
+ - [3.2. Injection of fragments \& queries for ContentTypes](#32-injection-of-fragments--queries-for-contenttypes)
15
+ - [3.3. Auto inject fragments](#33-auto-inject-fragments)
16
+ - [3.4. Remove fragments and spreads that target non-existing types](#34-remove-fragments-and-spreads-that-target-non-existing-types)
17
+ - [3.5. Dedicated Queries \& Fragments](#35-dedicated-queries--fragments)
18
+ - [Compiler field directive `@depend`](#compiler-field-directive-depend)
19
+ - [4. Usage](#4-usage)
20
+ - [4.1. Option 1: Direct methods](#41-option-1-direct-methods)
21
+ - [4.2. Option 2: Enhanced Client](#42-option-2-enhanced-client)
22
+
23
+
24
+ ## 1. Install package
10
25
  To install using Yarn, use the following command:
11
26
 
12
27
  ```bash
@@ -19,7 +34,7 @@ yarn add --dev @remkoj/optimizely-graph-cli
19
34
  yarn opti-graph patches:apply
20
35
  ```
21
36
 
22
- ## Configure package
37
+ ## 2. Configure package
23
38
  Create a codegen.ts within your application root folder (e.g. apps/frontend/codegen.ts within the example site). Within the codegen.ts create the following configuration:
24
39
 
25
40
  ```typescript
@@ -104,11 +119,46 @@ The presetConfig of the `OptimizelyGraphPreset` is an extension of the configura
104
119
  | functions | The list of GraphQL Functions that should be made available in the `functions.ts` file. When specified, this overrides the default list.<br/>*Default value: `['getContentType','getContentByPath','getContentById']`*
105
120
  | verbose | Set to `true` to enable debugging output of the preset, loader, plugin and transform |
106
121
 
122
+ ## 3. GraphQL Document Processing
123
+ ### 3.1. Allow overwriting of built-in fragments & queries
124
+ All fragment and query names injected / generated by this package start with an underscore (for example: `_getContentById`). During the document pre-processing, all these fragments and queries will be processed with this logic:
125
+ - If there's no query or fragment with the name without the leading underscore, it will be renamed. (i.e. `_getContentById` becomes `getContentById`)
126
+ - If a query or fragment with the name without leading underscore does exist, the built-in version with underscore will be removed from the document set.
107
127
 
108
- ## Usage
128
+ This allows a project to overwrite built-in fragments and queries, while still ensuring type-safety.
129
+
130
+ ### 3.2. Injection of fragments & queries for ContentTypes
131
+ For each content type the appropriate fragments and queries will be auto generated an injected into the document set.
132
+
133
+ ### 3.3. Auto inject fragments
134
+ Dynamically build queries & fragments based upon the `injections` configuration, and the default injections from the auto-generated fragments & queries.
135
+
136
+ This allows you to tell wich group of fragments you want at a given location and then during GraphQL compilation generate the full queries based upon the current content schema in Optimizely CMS and your project configuration.
137
+
138
+ ### 3.4. Remove fragments and spreads that target non-existing types
139
+ Depending on the features you have enabled in your CMS, not all types might actually be present in Optimizely Graph. This logic removes these fragments and spreads from the documents.
140
+
141
+ This approach assumes you're using TypeScript, as missing, but required types or fields should cause an error in the TypeScript compilation step of you application. Hence it moves the error from GraphQL Codegen to TypeScript, allowing some of the changes to be handled in the code.
142
+
143
+ ### 3.5. Dedicated Queries & Fragments
144
+ The preset automatically injects a number of fragments and documents into the generated code. These can be found in their respective document:
145
+
146
+ - [`opti-cms:/queries/13`](./src/documents/queries.cms13.ts)
147
+ - [`opti-cms:/queries/12`](./src/documents/queries.cms12.ts)
148
+ - [`opti-cms:/fragments/13`](./src/documents/fragments.cms13.ts)
149
+ - [`opti-cms:/fragments/12`](./src/documents/fragments.cms12.ts)
150
+
151
+ ### Compiler field directive `@depend`
152
+ A compile time directive `@depend` is processed, allowing you to make selections depend on a field to present in the schema.
153
+
154
+ For example: `componentData: item @depend(on: "ContentReference.item") {}` will remove the field selection `componentData` from the document if there's no type with the name `ContentReference` that has a field named `item`.
155
+
156
+ This allows to write generic queries that can cope with differen configurations within the CMS.
157
+
158
+ ## 4. Usage
109
159
  After running the code generation, you can use the following API's (assuming the folder where the generated files are stored is available at `@/gql`):
110
160
 
111
- ### Option 1: Direct methods
161
+ ### 4.1. Option 1: Direct methods
112
162
  Only the methods specified by the `functions` preset configuration are available using this method.
113
163
 
114
164
  ```typescript
@@ -123,7 +173,7 @@ const contentFromId = await getContentById(client, { guidValue: '00000000-0000-0
123
173
  const contentFromPath = await getContentByPath(client, { path: '/en' })
124
174
  ```
125
175
 
126
- ### Option 2: Enhanced Client
176
+ ### 4.2. Option 2: Enhanced Client
127
177
  All GraphQL operations (e.g. Queries, Mutations, ...) defined within the documents are available using this method.
128
178
 
129
179
  ```typescript
@@ -138,11 +188,3 @@ const locale = Schema.Locales.En
138
188
 
139
189
  const contentItem = await client.getContentById({ guidValue: contentId, locale })
140
190
  ```
141
-
142
- ## Query Fragments
143
- The preset automatically injects a number of fragments and documents into the generated code. These can be found in their respective document:
144
-
145
- - [`opti-cms:/queries/13`](./src/documents/queries.cms13.ts)
146
- - [`opti-cms:/queries/12`](./src/documents/queries.cms12.ts)
147
- - [`opti-cms:/fragments/13`](./src/documents/fragments.cms13.ts)
148
- - [`opti-cms:/fragments/12`](./src/documents/fragments.cms12.ts)
@@ -0,0 +1,11 @@
1
+ import type { Types } from '@graphql-codegen/plugin-helpers';
2
+ import type { PresetOptions } from '../types';
3
+ /**
4
+ * Remove the "item" field in queries and fragments from the "ContentReference" type if it's not in the schema
5
+ *
6
+ * @param files
7
+ * @param options
8
+ * @returns
9
+ */
10
+ export declare function handleDependDirective(files: Types.DocumentFile[], options: Types.PresetFnArgs<PresetOptions>): Promise<Types.DocumentFile[]>;
11
+ export default handleDependDirective;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleDependDirective = handleDependDirective;
4
+ const graphql_1 = require("graphql");
5
+ /**
6
+ * Remove the "item" field in queries and fragments from the "ContentReference" type if it's not in the schema
7
+ *
8
+ * @param files
9
+ * @param options
10
+ * @returns
11
+ */
12
+ async function handleDependDirective(files, options) {
13
+ // Debug output
14
+ if (options.presetConfig.verbose)
15
+ console.log(`✨ [Optimizely] Checking ContentReference to determine if it has an "item" field`);
16
+ // Ouch, this is an old SaaS CMS instance, so we're going to clean this field
17
+ if (options.presetConfig.verbose)
18
+ console.log(`✨ [Optimizely] Nope it hasn't removing any reference to it`);
19
+ const filteredFiles = files.map((file) => {
20
+ let isModified = false;
21
+ const newDocument = file.document ? (0, graphql_1.visit)(file.document, {
22
+ Field: {
23
+ enter(node) {
24
+ // Check if the field has the `depend` directive
25
+ const dependDirective = node.directives?.find(x => x.name.value === 'depend');
26
+ if (dependDirective) {
27
+ // If so read the arguments and validate if the required "on" argument is there
28
+ const args = parseArgs(dependDirective.arguments);
29
+ const dependency = args.get('on');
30
+ if (typeof dependency !== 'string' || dependency.length === 0)
31
+ throw new Error(`The "@depend" directive requires the parameter "on" to be a non-empty string ${buildLocString(dependDirective)}`);
32
+ // Parse & validate the argument
33
+ const [typeName, fieldName, ...remaining] = dependency.split('.');
34
+ if (remaining.length > 0)
35
+ throw new Error(`The "on" parameter of the "@depend" directive must have the form "typeName.fieldName" ${buildLocString(dependDirective)}`);
36
+ // Retrieve the type fields
37
+ const fields = getObjectFieldNames(options.schema, typeName);
38
+ if (!(fields?.includes(fieldName) ?? false)) {
39
+ isModified = true;
40
+ return null; // Remove the item
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }) : undefined;
46
+ return isModified
47
+ ? {
48
+ ...file,
49
+ rawSDL: newDocument ? (0, graphql_1.print)(newDocument) : undefined,
50
+ document: newDocument,
51
+ }
52
+ : file;
53
+ });
54
+ return filteredFiles;
55
+ }
56
+ exports.default = handleDependDirective;
57
+ function buildLocString(node) {
58
+ if (!node.loc)
59
+ return "";
60
+ const sourceName = node.loc.source.name;
61
+ const startLine = node.loc.startToken.line;
62
+ const startChar = node.loc.startToken.column;
63
+ return `in ${sourceName} at line ${startLine}, position ${startChar}`;
64
+ }
65
+ function parseArgs(args) {
66
+ return args?.reduce((out, arg) => {
67
+ const argName = arg.name.value;
68
+ switch (arg.value.kind) {
69
+ case graphql_1.Kind.INT:
70
+ out.set(argName, parseInt(arg.value.value));
71
+ break;
72
+ case graphql_1.Kind.BOOLEAN:
73
+ out.set(argName, new Boolean(arg.value.value));
74
+ break;
75
+ case graphql_1.Kind.STRING:
76
+ out.set(argName, arg.value.value);
77
+ break;
78
+ default:
79
+ throw new Error(`Error parsing directive arguments, encountered unsupported argument kind ${arg.value.kind} for ${argName} ${buildLocString(arg)}`);
80
+ }
81
+ return out;
82
+ }, new Map()) ?? new Map();
83
+ }
84
+ function getObjectFieldNames(schema, objectName) {
85
+ let currentObjectName;
86
+ let objectFields = [];
87
+ let hasType = false;
88
+ (0, graphql_1.visit)(schema, {
89
+ ObjectTypeDefinition: {
90
+ enter(node) {
91
+ if (node.name.value === objectName)
92
+ hasType = true;
93
+ currentObjectName = node.name.value;
94
+ },
95
+ leave(node) {
96
+ if (currentObjectName === node.name.value)
97
+ currentObjectName = undefined;
98
+ },
99
+ },
100
+ FieldDefinition: {
101
+ enter(node) {
102
+ if (currentObjectName === objectName)
103
+ objectFields.push(node.name.value);
104
+ },
105
+ },
106
+ });
107
+ return objectFields;
108
+ }
109
+ function isASTNode(node) {
110
+ return !Array.isArray(node);
111
+ }
112
+ function isNotNullOrUndefined(toTest) {
113
+ return toTest !== null && toTest !== undefined;
114
+ }
115
+ function isFragmentOrOperation(x) {
116
+ if (Array.isArray(x) || x == undefined || x == null)
117
+ return false;
118
+ return (x.kind == graphql_1.Kind.FRAGMENT_DEFINITION ||
119
+ x.kind == graphql_1.Kind.OPERATION_DEFINITION);
120
+ }
121
+ //# sourceMappingURL=handleDependDirective.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleDependDirective.js","sourceRoot":"","sources":["../../src/_transform/handleDependDirective.ts"],"names":[],"mappings":";;AA2BA,sDAqDC;AA/ED,qCAcgB;AAKhB;;;;;;GAMG;AACI,KAAK,UAAU,qBAAqB,CACzC,KAA2B,EAC3B,OAA0C;IAE1C,eAAe;IACf,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;QAC9B,OAAO,CAAC,GAAG,CACT,iFAAiF,CAClF,CAAA;IAEH,6EAA6E;IAC7E,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;QAC9B,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAA;IAE3E,MAAM,aAAa,GAAyB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7D,IAAI,UAAU,GAAG,KAAK,CAAA;QACtB,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,eAAK,EAAC,IAAI,CAAC,QAAQ,EAAE;YACvD,KAAK,EAAE;gBACL,KAAK,CAAC,IAAI;oBACR,gDAAgD;oBAChD,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAA;oBAC7E,IAAI,eAAe,EAAE,CAAC;wBAEpB,+EAA+E;wBAC/E,MAAM,IAAI,GAAG,SAAS,CAAC,eAA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types } from '@graphql-codegen/plugin-helpers';
2
+ import type { PresetOptions } from '../types';
3
+ /**
4
+ * Remove the "item" field in queries and fragments from the "ContentReference" type if it's not in the schema
5
+ *
6
+ * @param files
7
+ * @param options
8
+ * @returns
9
+ */
10
+ export declare function removeReferenceItem(files: Types.DocumentFile[], options: Types.PresetFnArgs<PresetOptions>): Promise<Types.DocumentFile[]>;
11
+ export default removeReferenceItem;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeReferenceItem = removeReferenceItem;
4
+ const graphql_1 = require("graphql");
5
+ /**
6
+ * Remove the "item" field in queries and fragments from the "ContentReference" type if it's not in the schema
7
+ *
8
+ * @param files
9
+ * @param options
10
+ * @returns
11
+ */
12
+ async function removeReferenceItem(files, options) {
13
+ // Debug output
14
+ if (options.presetConfig.verbose)
15
+ console.log(`✨ [Optimizely] Checking ContentReference to determine if it has an "item" field`);
16
+ const GraphSchemaObject = 'ContentReference';
17
+ const GraphFieldName = 'item';
18
+ // Get the fields of ContentReference, return if it contains "item" - we're all good to go
19
+ const contentReferenceFields = getObjectFieldNames(options.schema, GraphSchemaObject);
20
+ if (contentReferenceFields.includes(GraphFieldName))
21
+ return files;
22
+ // Ouch, this is an old SaaS CMS instance, so we're going to clean this field
23
+ if (options.presetConfig.verbose)
24
+ console.log(`✨ [Optimizely] Nope it hasn't removing any reference to it`);
25
+ const filteredFiles = files.map((file) => {
26
+ let isModified = false;
27
+ const newDocument = file.document ? (0, graphql_1.visit)(file.document, {
28
+ Field: {
29
+ enter(node) {
30
+ const dependDirective = node.directives?.find(x => x.name.value === 'depend');
31
+ if (dependDirective) {
32
+ const args = parseArgs(dependDirective.arguments);
33
+ const dependency = args.get('on');
34
+ if (typeof dependency !== 'string' || dependency.length === 0)
35
+ throw new Error(`The depend directive requires the parameter "on" to be a non-empty string ${buildLocString(dependDirective)}`);
36
+ console.log(`Field ${node.name.value} depends on ${args.get('on')}`);
37
+ }
38
+ }
39
+ }
40
+ }) : undefined;
41
+ return isModified
42
+ ? {
43
+ ...file,
44
+ rawSDL: newDocument ? (0, graphql_1.print)(newDocument) : undefined,
45
+ document: newDocument,
46
+ }
47
+ : file;
48
+ });
49
+ return filteredFiles;
50
+ }
51
+ function buildLocString(node) {
52
+ if (!node.loc)
53
+ return "";
54
+ const sourceName = node.loc.source.name;
55
+ const startLine = node.loc.startToken.line;
56
+ const startChar = node.loc.startToken.column;
57
+ return `in ${sourceName} at line ${startLine}, position ${startChar}`;
58
+ }
59
+ function parseArgs(args) {
60
+ return args?.reduce((out, arg) => {
61
+ const argName = arg.name.value;
62
+ switch (arg.value.kind) {
63
+ case graphql_1.Kind.INT:
64
+ out.set(argName, parseInt(arg.value.value));
65
+ break;
66
+ case graphql_1.Kind.BOOLEAN:
67
+ out.set(argName, new Boolean(arg.value.value));
68
+ break;
69
+ case graphql_1.Kind.STRING:
70
+ out.set(argName, arg.value.value);
71
+ break;
72
+ default:
73
+ throw new Error(`Error parsing directive arguments, encountered unsupported argument kind ${arg.value.kind} for ${argName} ${buildLocString(arg)}`);
74
+ }
75
+ return out;
76
+ }, new Map()) ?? new Map();
77
+ }
78
+ exports.default = removeReferenceItem;
79
+ function getObjectFieldNames(schema, objectName) {
80
+ let currentObjectName;
81
+ let objectFields = [];
82
+ (0, graphql_1.visit)(schema, {
83
+ ObjectTypeDefinition: {
84
+ enter(node) {
85
+ currentObjectName = node.name.value;
86
+ },
87
+ leave(node) {
88
+ if (currentObjectName === node.name.value)
89
+ currentObjectName = undefined;
90
+ },
91
+ },
92
+ FieldDefinition: {
93
+ enter(node) {
94
+ if (currentObjectName === objectName)
95
+ objectFields.push(node.name.value);
96
+ },
97
+ },
98
+ });
99
+ return objectFields;
100
+ }
101
+ function isASTNode(node) {
102
+ return !Array.isArray(node);
103
+ }
104
+ function isNotNullOrUndefined(toTest) {
105
+ return toTest !== null && toTest !== undefined;
106
+ }
107
+ function isFragmentOrOperation(x) {
108
+ if (Array.isArray(x) || x == undefined || x == null)
109
+ return false;
110
+ return (x.kind == graphql_1.Kind.FRAGMENT_DEFINITION ||
111
+ x.kind == graphql_1.Kind.OPERATION_DEFINITION);
112
+ }
113
+ //# sourceMappingURL=removeReferenceItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeReferenceItem.js","sourceRoot":"","sources":["../../src/_transform/removeReferenceItem.ts"],"names":[],"mappings":";;AA2BA,kDAiDC;AA3ED,qCAcgB;AAKhB;;;;;;GAMG;AACI,KAAK,UAAU,mBAAmB,CACvC,KAA2B,EAC3B,OAA0C;IAE1C,eAAe;IACf,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;QAC9B,OAAO,CAAC,GAAG,CACT,iFAAiF,CAClF,CAAA;IAEH,MAAM,iBAAiB,GAAG,kBAAkB,CAAA;IAC5C,MAAM,cAAc,GAAG,MAAM,CAAA;IAE7B,0FAA0F;IAC1F,MAAM,sBAAsB,GAAG,mBAAmB,CAChD,OAAO,CAAC,MAAM,EACd,iBAAiB,CAClB,CAAA;IACD,IAAI,sBAAsB,CAAC,QAAQ,CAAC,cAAc,CAAC;QAAE,OAAO,KAAK,CAAA;IAEjE,6EAA6E;IAC7E,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO;QAC9B,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAA;IAE3E,MAAM,aAAa,GAAyB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7D,IAAI,UAAU,GAAG,KAAK,CAAA;QACtB,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,eAAK,EAAC,IAAI,CAAC,QAAQ,EAAE;YACvD,KAAK,EAAE;gBACL,KAAK,CAAC,IAAI;oBACR,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAA;oBAC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AS,CAAA;YAC1E,CAAC;SACF;QACD,eAAe,EAAE;YACf,KAAK,CAAC,IAAI;gBACR,IAAI,iBAAiB,KAAK,UAAU;oBAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAC1E,CAAC;SACF;KACF,CAAC,CAAA;IACF,OAAO,YAAY,CAAA;AACrB,CAAC;AAED,SAAS,SAAS,CAAC,IAAkC;IAEnD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAC;AAED,SAAS,oBAAoB,CAAI,MAAiB;IAChD,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,CAAA;AAChD,CAAC;AACD,SAAS,qBAAqB,CAC5B,CAAmD;IAEnD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,SAAS,IAAI,CAAC,IAAI,IAAI;QAAE,OAAO,KAAK,CAAA;IACjE,OAAO,CACJ,CAAa,CAAC,IAAI,IAAI,cAAI,CAAC,mBAAmB;QAC9C,CAAa,CAAC,IAAI,IAAI,cAAI,CAAC,oBAAoB,CACjD,CAAA;AACH,CAAC"}
@@ -317,7 +317,7 @@ function buildProperty(propertyName, propertyConfig, propertyTracker = new Map()
317
317
  base
318
318
  default
319
319
  }
320
- item {
320
+ item @depend(on: "ContentReference.item") {
321
321
  __typename
322
322
  ...CmpImageAssetInfo
323
323
  ...CmpVideoAssetInfo
package/dist/preset.js CHANGED
@@ -51,16 +51,18 @@ exports.preset = {
51
51
  */
52
52
  prepareDocuments: async (outputFilePath, outputSpecificDocuments) => {
53
53
  // Get the configured documents
54
- const optiDocs = outputSpecificDocuments.filter((x => typeof (x) == 'string' && x.startsWith('opti-cms:')));
55
- const normalDocs = outputSpecificDocuments.filter(x => !(typeof (x) == 'string' && x.startsWith('opti-cms:')));
54
+ const optiDocs = outputSpecificDocuments.filter(((x) => typeof x == 'string' && x.startsWith('opti-cms:')));
55
+ const normalDocs = outputSpecificDocuments.filter((x) => !(typeof x == 'string' && x.startsWith('opti-cms:')));
56
56
  // Get the base documents
57
- const documents = client_preset_1.preset.prepareDocuments ?
58
- await client_preset_1.preset.prepareDocuments(outputFilePath, normalDocs) :
59
- [...normalDocs, `!${outputFilePath}`];
57
+ const documents = client_preset_1.preset.prepareDocuments
58
+ ? await client_preset_1.preset.prepareDocuments(outputFilePath, normalDocs)
59
+ : [...normalDocs, `!${outputFilePath}`];
60
60
  // Transform / inject the Opti-CMS documents
61
- const CmsDocLoaders = (optiDocs.length == 0 ? ['opti-cms:/fragments/13', 'opti-cms:/queries/13'] : optiDocs).map(optiDoc => {
61
+ const CmsDocLoaders = (optiDocs.length == 0
62
+ ? ['opti-cms:/fragments/13', 'opti-cms:/queries/13']
63
+ : optiDocs).map((optiDoc) => {
62
64
  const loader = {};
63
- loader[optiDoc] = { loader: "@remkoj/optimizely-graph-functions/loader" };
65
+ loader[optiDoc] = { loader: '@remkoj/optimizely-graph-functions/loader' };
64
66
  return loader;
65
67
  });
66
68
  // Create a new, extended, array
@@ -75,9 +77,9 @@ exports.preset = {
75
77
  // Provided options
76
78
  ...options.config,
77
79
  // Enforced settings
78
- namingConvention: "keep", // Keep casing "as-is" from Optimizely Graph
80
+ namingConvention: 'keep', // Keep casing "as-is" from Optimizely Graph
79
81
  };
80
- // Change the default for fragment masking from 'useFragment' to
82
+ // Change the default for fragment masking from 'useFragment' to
81
83
  // 'getFragmentData', in order to prevent issues with code checks for
82
84
  // React hooks
83
85
  if (options.presetConfig.fragmentMasking !== false) {
@@ -85,11 +87,39 @@ exports.preset = {
85
87
  ...options.presetConfig,
86
88
  fragmentMasking: {
87
89
  unmaskFunctionName: 'getFragmentData',
88
- ...(typeof (options.presetConfig?.fragmentMasking) == 'object' ? options.presetConfig?.fragmentMasking : {})
89
- }
90
+ ...(typeof options.presetConfig?.fragmentMasking == 'object'
91
+ ? options.presetConfig?.fragmentMasking
92
+ : {}),
93
+ },
90
94
  };
91
95
  }
96
+ function injectOptimizelyTransforms(currentTransforms) {
97
+ const dt = currentTransforms ?? [];
98
+ dt.unshift({
99
+ name: 'Optimizely.CMS',
100
+ transformObject: {
101
+ transform: (tOpts) => (0, transform_1.executeDocumentTransforms)(tOpts.documents, [
102
+ transform_1.cleanFragments, // Remove fragments that target non-existing types
103
+ transform_1.normalizeFragmentNames, // Allow overriding of built-in fragments
104
+ transform_1.normalizeQueryNames, // Allow overriding of built-in queries
105
+ transform_1.injectComponentDocuments, // Inject fragments to fetch component data
106
+ transform_1.injectPageQueries, // Inject queries to fetch page/experience data
107
+ transform_1.injectSectionQueries, // Inject queries to fetch section data
108
+ transform_1.performInjections, // Run injections of component fragments adjacent to placeholder fragments
109
+ transform_1.cleanFragmentSpreads, // Remove all fragment spreads that target a fragment that does not exist in the documents
110
+ transform_1.handleDependDirective, // Remove the "item" field in queries and fragments from the "ContentReference" type if it's not in the schema
111
+ ], options),
112
+ },
113
+ });
114
+ return dt;
115
+ }
116
+ function hasOptimizelyTransform(currentTransforms) {
117
+ if (!Array.isArray(currentTransforms))
118
+ return false;
119
+ return currentTransforms.some(x => x.name === 'Optimizely.CMS');
120
+ }
92
121
  // Apply all changes to the document set, prior to validating it. They're executed in the order of the array
122
+ options.documentTransforms = injectOptimizelyTransforms(options.documentTransforms);
93
123
  options.documents = await (0, transform_1.executeDocumentTransforms)(options.documents, [
94
124
  transform_1.cleanFragments, // Remove fragments that target non-existing types
95
125
  transform_1.normalizeFragmentNames, // Allow overriding of built-in fragments
@@ -98,30 +128,31 @@ exports.preset = {
98
128
  transform_1.injectPageQueries, // Inject queries to fetch page/experience data
99
129
  transform_1.injectSectionQueries, // Inject queries to fetch section data
100
130
  transform_1.performInjections, // Run injections of component fragments adjacent to placeholder fragments
101
- transform_1.cleanFragmentSpreads // Remove all fragment spreads that target a fragment that does not exist in the documents
131
+ transform_1.cleanFragmentSpreads, // Remove all fragment spreads that target a fragment that does not exist in the documents
132
+ transform_1.handleDependDirective // Remove the "item" field in queries and fragments from the "ContentReference" type if it's not in the schema
102
133
  ], options);
103
134
  // Build the preset files
104
135
  const section = await client_preset_1.preset.buildGeneratesSection(options);
105
- // Add GraphQL Request Client.
136
+ // Add GraphQL Request Client.
106
137
  section.push({
107
138
  filename: `${options.baseOutputDir}client.ts`,
108
139
  pluginMap: {
109
- "add": AddPlugin,
110
- "typescript-graphql-request": GraphQLRequestPlugin
140
+ add: AddPlugin,
141
+ 'typescript-graphql-request': GraphQLRequestPlugin,
111
142
  },
112
143
  plugins: [
113
144
  {
114
145
  add: {
115
- content: ["import type * as Schema from \"./graphql\";"]
146
+ content: ['import type * as Schema from "./graphql";'],
116
147
  },
117
148
  },
118
149
  {
119
150
  'typescript-graphql-request': {
120
151
  ...options.config,
121
152
  useTypeImports: true,
122
- importOperationTypesFrom: "Schema",
123
- }
124
- }
153
+ importOperationTypesFrom: 'Schema',
154
+ },
155
+ },
125
156
  ],
126
157
  schema: options.schema,
127
158
  schemaAst: options.schemaAst,
@@ -130,19 +161,19 @@ exports.preset = {
130
161
  },
131
162
  profiler: options.profiler,
132
163
  documents: options.documents,
133
- documentTransforms: options.documentTransforms
164
+ documentTransforms: options.documentTransforms,
134
165
  });
135
- // Add the functions file, which will materialize the defined
136
- // functions.
166
+ // Add the functions file, which will materialize the defined
167
+ // functions.
137
168
  section.push({
138
169
  filename: `${options.baseOutputDir}functions.ts`,
139
170
  pluginMap: {
140
- ['optly-functions']: index_1.default
171
+ ['optly-functions']: index_1.default,
141
172
  },
142
173
  plugins: [
143
174
  {
144
- ['optly-functions']: {}
145
- }
175
+ ['optly-functions']: {},
176
+ },
146
177
  ],
147
178
  schema: options.schema,
148
179
  schemaAst: options.schemaAst,
@@ -152,36 +183,45 @@ exports.preset = {
152
183
  ...(0, index_1.pickPluginOptions)(options.presetConfig),
153
184
  },
154
185
  documents: options.documents,
155
- documentTransforms: options.documentTransforms
186
+ documentTransforms: options.documentTransforms,
156
187
  });
157
188
  // Update file generation configs
158
189
  section.forEach((fileConfig, idx) => {
159
190
  // Modify index.ts with additional exports
160
- if (fileConfig.filename.endsWith("index.ts")) {
191
+ if (fileConfig.filename.endsWith('index.ts')) {
161
192
  section[idx].plugins.unshift({
162
193
  add: {
163
194
  content: [
164
195
  'export * as Schema from "./graphql";',
165
196
  'export * from "./functions";',
166
197
  'export { getSdk, type Sdk } from "./client";',
167
- ]
168
- }
198
+ ],
199
+ },
169
200
  });
170
201
  section[idx].plugins.push({
171
202
  add: {
172
- content: ['', `export const WITH_RECURSIVE_SUPPORT = ${options.presetConfig.recursion === true ? 'true' : 'false'};`]
173
- }
203
+ content: [
204
+ '',
205
+ `export const WITH_RECURSIVE_SUPPORT = ${options.presetConfig.recursion === true ? 'true' : 'false'};`,
206
+ ],
207
+ },
174
208
  });
175
209
  }
210
+ if (!hasOptimizelyTransform(fileConfig.documentTransforms))
211
+ fileConfig.documentTransforms = injectOptimizelyTransforms(fileConfig.documentTransforms);
176
212
  // Optimizely Graph supports recursive queries to allow fetching
177
213
  // data as created in the CMS. This can cause issues when using
178
214
  // multiple GraphQL sources, hence the ability to enable/disalbe
179
215
  // the support for recursive queries.
180
- if (fileConfig.skipDocumentsValidation != true && options.presetConfig.recursion === true) {
216
+ if (fileConfig.skipDocumentsValidation != true &&
217
+ options.presetConfig.recursion === true) {
181
218
  const currentOptions = fileConfig.skipDocumentsValidation || {};
182
219
  section[idx].skipDocumentsValidation = {
183
220
  ...currentOptions,
184
- ignoreRules: [...(currentOptions.ignoreRules ?? []), 'NoFragmentCyclesRule']
221
+ ignoreRules: [
222
+ ...(currentOptions.ignoreRules ?? []),
223
+ 'NoFragmentCyclesRule',
224
+ ],
185
225
  };
186
226
  }
187
227
  });
@@ -1 +1 @@
1
- {"version":3,"file":"preset.js","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qBAAqB;AACrB,kEAAuH;AACvH,kGAAmF;AACnF,gEAAiD;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,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG;yBACvG;qBACF;iBACF,CAAC,CAAA;YACJ,CAAC;YAED,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,kBAAkB,CAAC;gBACxD,UAAU,CAAC,kBAAkB,GAAG,0BAA0B,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAA;YAE3F,gEAAgE;YAChE,+DAA+D;YAC/D,gEAAgE;YAChE,qCAAqC;YACrC,IACE,UAAU,CAAC,uBAAuB,IAAI,IAAI;gBAC1C,OAAO,CAAC,YAAY,CAAC,SAAS,KAAK,IAAI,EACvC,CAAC;gBACD,MAAM,cAAc,GAAG,UAAU,CAAC,uBAAuB,IAAI,EAAE,CAAA;gBAC/D,OAAO,CAAC,GAAG,CAAC,CAAC,uBAAuB,GAAG;oBACrC,GAAG,cAAc;oBACjB,WAAW,EAAE;wBACX,GAAG,CAAC,cAAc,CAAC,WAAW,IAAI,EAAE,CAAC;wBACrC,sBAAsB;qBACvB;iBACF,CAAA;YACH,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,OAAO,CAAA;IAChB,CAAC;CACF,CAAA;AAED,kBAAe,cAAM,CAAA"}
@@ -9,6 +9,7 @@ export { injectPageQueries } from "./_transform/injectPageQueries";
9
9
  export { injectSectionQueries } from "./_transform/injectSectionQueries";
10
10
  export { performInjections } from "./_transform/performInjections";
11
11
  export { cleanFragmentSpreads } from "./_transform/cleanSpreads";
12
+ export { handleDependDirective } from "./_transform/handleDependDirective";
12
13
  export type TransformFn<T = any> = (files: Types.DocumentFile[], options: Types.PresetFnArgs<T>) => Promise<Types.DocumentFile[]> | Types.DocumentFile[];
13
14
  export declare function executeDocumentTransforms<T = any>(files: Types.DocumentFile[], transforms: Array<TransformFn<T>>, options: Types.PresetFnArgs<T>): Promise<Types.DocumentFile[]>;
14
15
  export declare const transform: Types.DocumentTransformFunction<TransformOptions>;
package/dist/transform.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transform = exports.cleanFragmentSpreads = exports.performInjections = exports.injectSectionQueries = exports.injectPageQueries = exports.pickTransformOptions = exports.normalizeQueryNames = exports.normalizeFragmentNames = exports.injectComponentDocuments = exports.cleanFragments = void 0;
3
+ exports.transform = exports.handleDependDirective = exports.cleanFragmentSpreads = exports.performInjections = exports.injectSectionQueries = exports.injectPageQueries = exports.pickTransformOptions = exports.normalizeQueryNames = exports.normalizeFragmentNames = exports.injectComponentDocuments = exports.cleanFragments = void 0;
4
4
  exports.executeDocumentTransforms = executeDocumentTransforms;
5
5
  const graphql_1 = require("graphql");
6
6
  var cleanFragments_1 = require("./_transform/cleanFragments");
@@ -21,6 +21,8 @@ var performInjections_1 = require("./_transform/performInjections");
21
21
  Object.defineProperty(exports, "performInjections", { enumerable: true, get: function () { return performInjections_1.performInjections; } });
22
22
  var cleanSpreads_1 = require("./_transform/cleanSpreads");
23
23
  Object.defineProperty(exports, "cleanFragmentSpreads", { enumerable: true, get: function () { return cleanSpreads_1.cleanFragmentSpreads; } });
24
+ var handleDependDirective_1 = require("./_transform/handleDependDirective");
25
+ Object.defineProperty(exports, "handleDependDirective", { enumerable: true, get: function () { return handleDependDirective_1.handleDependDirective; } });
24
26
  async function executeDocumentTransforms(files, transforms, options) {
25
27
  let transformedFiles = files;
26
28
  for (const transform of transforms)
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":";;;AAgBA,8DAKC;AAlBD,qCAAqC;AAErC,8DAA4D;AAAnD,gHAAA,cAAc,OAAA;AACvB,kFAAgF;AAAvE,oIAAA,wBAAwB,OAAA;AACjC,8EAA4E;AAAnE,gIAAA,sBAAsB,OAAA;AAC/B,wEAAsE;AAA7D,0HAAA,mBAAmB,OAAA;AAC5B,gDAA2D;AAAlD,+GAAA,oBAAoB,OAAA;AAC7B,oEAAkE;AAAzD,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;IAEF,IAAI,MAAM,CAAC,OAAO;QAChB,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAA;IACnE,OAAO,gBAAgB,CAAA;AACzB,CAAC,CAAA;AA1FY,QAAA,SAAS,aA0FrB;AAED,kBAAe,EAAE,SAAS,EAAT,iBAAS,EAAE,CAAA;AAE5B,SAAS,oBAAoB,CAAI,MAAiB;IAChD,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,CAAA;AAChD,CAAC;AACD,SAAS,qBAAqB,CAAC,CAAmD;IAChF,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,SAAS,IAAI,CAAC,IAAI,IAAI;QACjD,OAAO,KAAK,CAAA;IACd,OAAQ,CAAa,CAAC,IAAI,IAAI,cAAI,CAAC,mBAAmB,IAAK,CAAa,CAAC,IAAI,IAAI,cAAI,CAAC,oBAAoB,CAAA;AAC5G,CAAC"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "repository": "https://github.com/remkoj/optimizely-dxp-clients.git",
4
4
  "author": "Remko Jantzen <693172+remkoj@users.noreply.github.com>",
5
5
  "homepage": "https://github.com/remkoj/optimizely-dxp-clients",
6
- "version": "6.0.0-pre10",
6
+ "version": "6.0.0-pre12",
7
7
  "license": "Apache-2.0",
8
8
  "type": "commonjs",
9
9
  "description": "GraphQL Codegen preset for Optimizely Graph",
@@ -47,9 +47,9 @@
47
47
  },
48
48
  "devDependencies": {
49
49
  "@graphql-typed-document-node/core": "^3.2.0",
50
- "@remkoj/optimizely-cms-api": "6.0.0-pre10",
51
- "@remkoj/optimizely-graph-client": "6.0.0-pre10",
52
- "@types/node": "^22.18.12",
50
+ "@remkoj/optimizely-cms-api": "6.0.0-pre12",
51
+ "@remkoj/optimizely-graph-client": "6.0.0-pre12",
52
+ "@types/node": "^22.18.13",
53
53
  "typescript": "^5.9.3"
54
54
  },
55
55
  "dependencies": {
@@ -59,8 +59,8 @@
59
59
  "@graphql-codegen/typescript": "^5.0.2",
60
60
  "@graphql-codegen/typescript-graphql-request": "^6.3.0",
61
61
  "@graphql-codegen/typescript-operations": "^5.0.2",
62
- "@remkoj/optimizely-cms-api": "^6.0.0-pre10",
63
- "@remkoj/optimizely-graph-client": "^6.0.0-pre10",
62
+ "@remkoj/optimizely-cms-api": "6.0.0-pre12",
63
+ "@remkoj/optimizely-graph-client": "6.0.0-pre12",
64
64
  "graphql": "^16.11.0",
65
65
  "graphql-request": "^7.3.1",
66
66
  "graphql-sock": "^1.0.1",