Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sitecore-jss-nextjs][templates/nextjs] Move graphql client imports to allow usage in middleware #1648

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 import from _@sitecore-jss/sitecore-jss-nextjs/graphql-client_ submodule instead ([#1648](https://github.com/Sitecore/jss/pull/1648))

### 🐛 Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down
1 change: 1 addition & 0 deletions packages/sitecore-jss-nextjs/graphql-client.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './types/graphql-client/index';
1 change: 1 addition & 0 deletions packages/sitecore-jss-nextjs/graphql-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/cjs/graphql-client/index');
5 changes: 5 additions & 0 deletions packages/sitecore-jss-nextjs/src/graphql-client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export {
GraphQLRequestClient,
GraphQLRequestClientFactory,
GraphQLRequestClientFactoryConfig,
} from '@sitecore-jss/sitecore-jss';
12 changes: 8 additions & 4 deletions packages/sitecore-jss-nextjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ export {
AxiosDataFetcherConfig,
NativeDataFetcher,
NativeDataFetcherConfig,
GraphQLRequestClient,
GraphQLRequestClientFactory,
GraphQLRequestClientFactoryConfig,
HTMLLink,
enableDebug,
debug,
} from '@sitecore-jss/sitecore-jss';

// 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,
Expand All @@ -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,
Expand All @@ -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 };

Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/sitecore-jss-nextjs/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export {
resetEditorChromes,
resolveUrl,
} from '@sitecore-jss/sitecore-jss/utils';
export { getEdgeProxyContentUrl } from '@sitecore-jss/sitecore-jss/graphql';
1 change: 1 addition & 0 deletions packages/sitecore-jss-nextjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*",
Expand Down