From 4c8bf466c80b8c3a8f4595e3b71c9e1fc79015ab Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Fri, 15 Nov 2024 16:05:09 +0100 Subject: [PATCH] Remove preview-version header from open source --- .../plugins/magentoStoreGraphqlConfig.ts | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 packages/magento-store/plugins/magentoStoreGraphqlConfig.ts diff --git a/packages/magento-store/plugins/magentoStoreGraphqlConfig.ts b/packages/magento-store/plugins/magentoStoreGraphqlConfig.ts deleted file mode 100644 index e681ae483e..0000000000 --- a/packages/magento-store/plugins/magentoStoreGraphqlConfig.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { setContext, type graphqlConfig as graphqlConfigType } from '@graphcommerce/graphql' -import type { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config' - -export const config: PluginConfig = { - type: 'function', - module: '@graphcommerce/graphql', -} - -declare module '@graphcommerce/graphql/config' { - interface PreviewData { - magentoPreviewVersion?: string - } -} - -export const graphqlConfig: FunctionPlugin = (prev, conf) => { - const results = prev(conf) - - const previewVersion = conf.previewData?.magentoPreviewVersion - - return { - ...results, - links: [ - ...results.links, - setContext((_, context) => { - if (!context.headers) context.headers = {} - context.headers.store = conf.storefront.magentoStoreCode - if (conf.preview) { - // To disable caching from the backend, we provide a bogus cache ID. - context.headers['x-magento-cache-id'] = - `random-cache-id${Math.random().toString(36).slice(2)}` - if (previewVersion) { - context.headers['preview-version'] = previewVersion - } - } - return context - }), - ], - } -}