@dotcms/client 0.0.1-beta.41 → 0.0.1-beta.42
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 +11 -2
- package/next.cjs.js +5 -4
- package/next.esm.js +6 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -264,8 +264,17 @@ The `page.get()` method accepts an optional second argument of type [`DotCMSPage
|
|
|
264
264
|
| `languageId` | string \| number | Language version of the page |
|
|
265
265
|
| `mode` | string | Rendering mode: `LIVE`, `PREVIEW_MODE`, etc. |
|
|
266
266
|
| `personaId` | string | Personalize content based on persona ID |
|
|
267
|
-
| `graphql` |
|
|
268
|
-
| `fireRules` | boolean
|
|
267
|
+
| `graphql` | DotCMSGraphQLParams | GraphQL options for extending the response |
|
|
268
|
+
| `fireRules` | boolean | Whether to trigger page rules |
|
|
269
|
+
|
|
270
|
+
The `graphql` option allows you to customize the page and content data returned. It accepts:
|
|
271
|
+
|
|
272
|
+
| Property | Type | Description |
|
|
273
|
+
| ----------- | -------- | ----------------------------------------------------- |
|
|
274
|
+
| `page` | string | GraphQL partial query that will be automatically wrapped with the page context. (you don't need to include the `page(url:"/")` wrapper in your query) |
|
|
275
|
+
| `content` | object | Named queries to fetch additional content |
|
|
276
|
+
| `fragments` | string[] | GraphQL fragments that can be reused across queries |
|
|
277
|
+
| `variables` | object | Variables to pass into the GraphQL queries |
|
|
269
278
|
|
|
270
279
|
> 💡 See [`DotCMSPageRequestParams`](https://github.com/dotCMS/core/blob/6e003eb697554ea9636a1fec59bc0fa020b84390/core-web/libs/sdk/types/src/lib/client/public.ts#L5-L54) for a full list of supported options.
|
|
271
280
|
|
package/next.cjs.js
CHANGED
|
@@ -228,8 +228,8 @@ const buildPageQuery = ({ page, fragments, additionalQueries }) => {
|
|
|
228
228
|
|
|
229
229
|
${fragments ? fragments.join('\n\n') : ''}
|
|
230
230
|
|
|
231
|
-
query PageContent($url: String!, $languageId: String, $mode: String, $personaId: String, $fireRules: Boolean, $publishDate: String, $siteId: String) {
|
|
232
|
-
page: page(url: $url, languageId: $languageId, pageMode: $mode, persona: $personaId, fireRules: $fireRules, publishDate: $publishDate, site: $siteId) {
|
|
231
|
+
query PageContent($url: String!, $languageId: String, $mode: String, $personaId: String, $fireRules: Boolean, $publishDate: String, $siteId: String, $variantName: String) {
|
|
232
|
+
page: page(url: $url, languageId: $languageId, pageMode: $mode, persona: $personaId, fireRules: $fireRules, publishDate: $publishDate, site: $siteId, variantName: $variantName) {
|
|
233
233
|
...DotCMSPage
|
|
234
234
|
${page ? '...ClientPage' : ''}
|
|
235
235
|
}
|
|
@@ -375,7 +375,7 @@ class PageClient {
|
|
|
375
375
|
* ```
|
|
376
376
|
*/
|
|
377
377
|
async get(url, options) {
|
|
378
|
-
const { languageId = '1', mode = 'LIVE', siteId = this.siteId, fireRules = false, personaId, publishDate, graphql = {} } = options || {};
|
|
378
|
+
const { languageId = '1', mode = 'LIVE', siteId = this.siteId, fireRules = false, personaId, publishDate, variantName, graphql = {} } = options || {};
|
|
379
379
|
const { page, content = {}, variables, fragments } = graphql;
|
|
380
380
|
const contentQuery = buildQuery(content);
|
|
381
381
|
const completeQuery = buildPageQuery({
|
|
@@ -392,6 +392,7 @@ class PageClient {
|
|
|
392
392
|
fireRules,
|
|
393
393
|
publishDate,
|
|
394
394
|
siteId,
|
|
395
|
+
variantName,
|
|
395
396
|
...variables
|
|
396
397
|
};
|
|
397
398
|
const requestHeaders = this.requestOptions.headers;
|
|
@@ -404,7 +405,7 @@ class PageClient {
|
|
|
404
405
|
});
|
|
405
406
|
if (errors) {
|
|
406
407
|
errors.forEach((error) => {
|
|
407
|
-
|
|
408
|
+
consola.error('[DotCMS GraphQL Error]: ', error.message);
|
|
408
409
|
});
|
|
409
410
|
}
|
|
410
411
|
const pageResponse = transforms.graphqlToPageEntity(data);
|
package/next.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { consola } from 'consola';
|
|
1
|
+
import consola$1, { consola } from 'consola';
|
|
2
2
|
import { E as ErrorMessages, g as graphqlToPageEntity, C as Content } from './transforms.esm.js';
|
|
3
3
|
|
|
4
4
|
class NavigationClient {
|
|
@@ -226,8 +226,8 @@ const buildPageQuery = ({ page, fragments, additionalQueries }) => {
|
|
|
226
226
|
|
|
227
227
|
${fragments ? fragments.join('\n\n') : ''}
|
|
228
228
|
|
|
229
|
-
query PageContent($url: String!, $languageId: String, $mode: String, $personaId: String, $fireRules: Boolean, $publishDate: String, $siteId: String) {
|
|
230
|
-
page: page(url: $url, languageId: $languageId, pageMode: $mode, persona: $personaId, fireRules: $fireRules, publishDate: $publishDate, site: $siteId) {
|
|
229
|
+
query PageContent($url: String!, $languageId: String, $mode: String, $personaId: String, $fireRules: Boolean, $publishDate: String, $siteId: String, $variantName: String) {
|
|
230
|
+
page: page(url: $url, languageId: $languageId, pageMode: $mode, persona: $personaId, fireRules: $fireRules, publishDate: $publishDate, site: $siteId, variantName: $variantName) {
|
|
231
231
|
...DotCMSPage
|
|
232
232
|
${page ? '...ClientPage' : ''}
|
|
233
233
|
}
|
|
@@ -373,7 +373,7 @@ class PageClient {
|
|
|
373
373
|
* ```
|
|
374
374
|
*/
|
|
375
375
|
async get(url, options) {
|
|
376
|
-
const { languageId = '1', mode = 'LIVE', siteId = this.siteId, fireRules = false, personaId, publishDate, graphql = {} } = options || {};
|
|
376
|
+
const { languageId = '1', mode = 'LIVE', siteId = this.siteId, fireRules = false, personaId, publishDate, variantName, graphql = {} } = options || {};
|
|
377
377
|
const { page, content = {}, variables, fragments } = graphql;
|
|
378
378
|
const contentQuery = buildQuery(content);
|
|
379
379
|
const completeQuery = buildPageQuery({
|
|
@@ -390,6 +390,7 @@ class PageClient {
|
|
|
390
390
|
fireRules,
|
|
391
391
|
publishDate,
|
|
392
392
|
siteId,
|
|
393
|
+
variantName,
|
|
393
394
|
...variables
|
|
394
395
|
};
|
|
395
396
|
const requestHeaders = this.requestOptions.headers;
|
|
@@ -402,7 +403,7 @@ class PageClient {
|
|
|
402
403
|
});
|
|
403
404
|
if (errors) {
|
|
404
405
|
errors.forEach((error) => {
|
|
405
|
-
|
|
406
|
+
consola$1.error('[DotCMS GraphQL Error]: ', error.message);
|
|
406
407
|
});
|
|
407
408
|
}
|
|
408
409
|
const pageResponse = graphqlToPageEntity(data);
|