From ce763a6cc7c691759c90202deeb9474b44122701 Mon Sep 17 00:00:00 2001 From: art-alexeyenko Date: Tue, 31 Oct 2023 13:22:52 -0400 Subject: [PATCH 1/3] [sitecore-jss-nextjs][templates/nextjs] Move graphql client imports to allow its usage in middleware --- .../nextjs/src/lib/graphql-client-factory/create.ts | 4 ++-- packages/sitecore-jss-nextjs/graphql-client.d.ts | 1 + packages/sitecore-jss-nextjs/graphql-client.js | 1 + .../sitecore-jss-nextjs/src/graphql-client/index.ts | 5 +++++ packages/sitecore-jss-nextjs/src/index.ts | 12 ++++++++---- packages/sitecore-jss-nextjs/src/utils/index.ts | 1 + packages/sitecore-jss-nextjs/tsconfig.json | 1 + 7 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 packages/sitecore-jss-nextjs/graphql-client.d.ts create mode 100644 packages/sitecore-jss-nextjs/graphql-client.js create mode 100644 packages/sitecore-jss-nextjs/src/graphql-client/index.ts diff --git a/packages/create-sitecore-jss/src/templates/nextjs/src/lib/graphql-client-factory/create.ts b/packages/create-sitecore-jss/src/templates/nextjs/src/lib/graphql-client-factory/create.ts index e2b2918626..eef1bc95a9 100644 --- a/packages/create-sitecore-jss/src/templates/nextjs/src/lib/graphql-client-factory/create.ts +++ b/packages/create-sitecore-jss/src/templates/nextjs/src/lib/graphql-client-factory/create.ts @@ -1,8 +1,8 @@ import { GraphQLRequestClientFactoryConfig, - getEdgeProxyContentUrl, GraphQLRequestClient, -} from '@sitecore-jss/sitecore-jss-nextjs'; +} from '@sitecore-jss/sitecore-jss-nextjs/graphql-client'; +import { getEdgeProxyContentUrl } from '@sitecore-jss/sitecore-jss-nextjs/utils'; import { JssConfig } from 'lib/config'; /** diff --git a/packages/sitecore-jss-nextjs/graphql-client.d.ts b/packages/sitecore-jss-nextjs/graphql-client.d.ts new file mode 100644 index 0000000000..e3826d475b --- /dev/null +++ b/packages/sitecore-jss-nextjs/graphql-client.d.ts @@ -0,0 +1 @@ +export * from './types/graphql-client/index'; diff --git a/packages/sitecore-jss-nextjs/graphql-client.js b/packages/sitecore-jss-nextjs/graphql-client.js new file mode 100644 index 0000000000..522605aeb0 --- /dev/null +++ b/packages/sitecore-jss-nextjs/graphql-client.js @@ -0,0 +1 @@ +module.exports = require('./dist/cjs/graphql-client/index'); diff --git a/packages/sitecore-jss-nextjs/src/graphql-client/index.ts b/packages/sitecore-jss-nextjs/src/graphql-client/index.ts new file mode 100644 index 0000000000..f7346f3b2a --- /dev/null +++ b/packages/sitecore-jss-nextjs/src/graphql-client/index.ts @@ -0,0 +1,5 @@ +export { + GraphQLRequestClient, + GraphQLRequestClientFactory, + GraphQLRequestClientFactoryConfig, +} from '@sitecore-jss/sitecore-jss'; diff --git a/packages/sitecore-jss-nextjs/src/index.ts b/packages/sitecore-jss-nextjs/src/index.ts index e753bbee5d..260e9cfe9e 100644 --- a/packages/sitecore-jss-nextjs/src/index.ts +++ b/packages/sitecore-jss-nextjs/src/index.ts @@ -8,9 +8,6 @@ export { AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, - GraphQLRequestClient, - GraphQLRequestClientFactory, - GraphQLRequestClientFactoryConfig, HTMLLink, enableDebug, debug, @@ -18,6 +15,7 @@ export { // we will remove the root exports for these later // we cannot mark exports as deprected directly, so we're using this hack instead +import { GraphQLRequestClient as GraphQLRequestClientDep } from './graphql-client'; import { isEditorActive as isEditorActiveDep, resetEditorChromes as resetEditorChromesDep, @@ -28,6 +26,7 @@ import { handleEditorFastRefresh as handleEditorFastRefreshDep, getPublicUrl as getPublicUrlDep, } from './utils'; + /** @deprecated use import from '@sitecore-jss/sitecore-jss-nextjs/utils' instead */ const { isEditorActiveDep: isEditorActive, @@ -44,6 +43,12 @@ const { handleEditorFastRefreshDep, getPublicUrlDep, }; +/** @deprecated use import from '@sitecore-jss/sitecore-jss-nextjs/graphql-client' instead */ +const { GraphQLRequestClientDep: GraphQLRequestClient } = { + GraphQLRequestClientDep, +}; + +export { GraphQLRequestClient }; export { handleEditorFastRefresh, getPublicUrl }; export { isEditorActive, resetEditorChromes, resolveUrl, tryParseEnvValue }; @@ -72,7 +77,6 @@ export { EDITING_COMPONENT_PLACEHOLDER, EDITING_COMPONENT_ID, } from '@sitecore-jss/sitecore-jss/layout'; -export { getEdgeProxyContentUrl } from '@sitecore-jss/sitecore-jss/graphql'; export { mediaApi } from '@sitecore-jss/sitecore-jss/media'; export { trackingApi, diff --git a/packages/sitecore-jss-nextjs/src/utils/index.ts b/packages/sitecore-jss-nextjs/src/utils/index.ts index bb06217af3..6151c9ef60 100644 --- a/packages/sitecore-jss-nextjs/src/utils/index.ts +++ b/packages/sitecore-jss-nextjs/src/utils/index.ts @@ -5,3 +5,4 @@ export { resetEditorChromes, resolveUrl, } from '@sitecore-jss/sitecore-jss/utils'; +export { getEdgeProxyContentUrl } from '@sitecore-jss/sitecore-jss/graphql'; diff --git a/packages/sitecore-jss-nextjs/tsconfig.json b/packages/sitecore-jss-nextjs/tsconfig.json index e103177d08..681a1f4488 100644 --- a/packages/sitecore-jss-nextjs/tsconfig.json +++ b/packages/sitecore-jss-nextjs/tsconfig.json @@ -18,6 +18,7 @@ "editing.d.ts", "monitoring.d.ts", "site.d.ts", + "graphql-client.d.ts", "utils.d.ts", "src/tests/*", "src/test-data/*", From 7efda97af09e7862d2baeb1e860edec944ff483b Mon Sep 17 00:00:00 2001 From: art-alexeyenko Date: Tue, 31 Oct 2023 13:37:04 -0400 Subject: [PATCH 2/3] changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5db0b805d5..a6b1daa508 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Our versioning strategy is as follows: * `[templates/nextjs]` Import SitecoreForm component into sample nextjs app ([#1628](https://github.com/Sitecore/jss/pull/1628)) * `[sitecore-jss-nextjs]` (Vercel/Sitecore) Deployment Protection Bypass support for editing integration. ([#1634](https://github.com/Sitecore/jss/pull/1634)) * `[sitecore-jss]` `[templates/nextjs]` Load environment-specific FEAAS theme stylesheets based on Sitecore Edge Platform URL ([#1645](https://github.com/Sitecore/jss/pull/1645)) +* `[sitecore-jss-nextjs]` The _GraphQLRequestClient_ import from _@sitecore-jss/sitecore-jss-nextjs_ is deprecated, use imnport from _@sitecore-jss/sitecore-jss-nextjs/graphql-client_ submodule instead ([#1648](https://github.com/Sitecore/jss/pull/1648)) ### 🐛 Bug Fixes From 4bca971821d55761dc43a0b224eaaabd6910eb04 Mon Sep 17 00:00:00 2001 From: art-alexeyenko Date: Tue, 31 Oct 2023 14:26:19 -0400 Subject: [PATCH 3/3] changelog typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6b1daa508..ce18d723aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ Our versioning strategy is as follows: * `[templates/nextjs]` Import SitecoreForm component into sample nextjs app ([#1628](https://github.com/Sitecore/jss/pull/1628)) * `[sitecore-jss-nextjs]` (Vercel/Sitecore) Deployment Protection Bypass support for editing integration. ([#1634](https://github.com/Sitecore/jss/pull/1634)) * `[sitecore-jss]` `[templates/nextjs]` Load environment-specific FEAAS theme stylesheets based on Sitecore Edge Platform URL ([#1645](https://github.com/Sitecore/jss/pull/1645)) -* `[sitecore-jss-nextjs]` The _GraphQLRequestClient_ import from _@sitecore-jss/sitecore-jss-nextjs_ is deprecated, use imnport from _@sitecore-jss/sitecore-jss-nextjs/graphql-client_ submodule instead ([#1648](https://github.com/Sitecore/jss/pull/1648)) +* `[sitecore-jss-nextjs]` The _GraphQLRequestClient_ import from _@sitecore-jss/sitecore-jss-nextjs_ is deprecated, use import from _@sitecore-jss/sitecore-jss-nextjs/graphql-client_ submodule instead ([#1648](https://github.com/Sitecore/jss/pull/1648)) ### 🐛 Bug Fixes