From db9229a5c97a6f956952273935dea526f1fcb722 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Mon, 3 Jul 2023 15:58:49 +0200 Subject: [PATCH 1/5] fix(graphiql-plugin-explorer): Use preferDefault helper --- packages/graphiql-plugin-explorer/src/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/graphiql-plugin-explorer/src/index.tsx b/packages/graphiql-plugin-explorer/src/index.tsx index 35be73d05e8..dd30bea59b3 100644 --- a/packages/graphiql-plugin-explorer/src/index.tsx +++ b/packages/graphiql-plugin-explorer/src/index.tsx @@ -4,12 +4,15 @@ import { useExecutionContext, useSchemaContext, } from '@graphiql/react'; -import GraphiQLExplorer, { GraphiQLExplorerProps } from 'graphiql-explorer'; +import type { GraphiQLExplorerProps } from 'graphiql-explorer'; +import GraphiQLExplorerImport from 'graphiql-explorer'; import React, { useCallback, useRef } from 'react'; import './graphiql-explorer.d.ts'; import './index.css'; +const preferDefault = (m: any): any => m?.default || m; + const colors = { keyword: 'hsl(var(--color-primary))', def: 'hsl(var(--color-tertiary))', @@ -71,6 +74,7 @@ const checkboxUnchecked = ( ); + const checkboxChecked = ( Date: Mon, 3 Jul 2023 16:04:16 +0200 Subject: [PATCH 2/5] Create shaggy-eyes-melt.md --- .changeset/shaggy-eyes-melt.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/shaggy-eyes-melt.md diff --git a/.changeset/shaggy-eyes-melt.md b/.changeset/shaggy-eyes-melt.md new file mode 100644 index 00000000000..8823393f45d --- /dev/null +++ b/.changeset/shaggy-eyes-melt.md @@ -0,0 +1,5 @@ +--- +"@graphiql/plugin-explorer": patch +--- + +fix(graphiql-plugin-explorer): Use `preferDefault` helper to correctly import `graphiql-explorer` From 28a2b061dc35bd63deedb0b3f4463705b53ec43f Mon Sep 17 00:00:00 2001 From: Lennart Date: Tue, 4 Jul 2023 07:56:46 +0200 Subject: [PATCH 3/5] Update packages/graphiql-plugin-explorer/src/index.tsx Co-authored-by: Dimitri POSTOLOV --- packages/graphiql-plugin-explorer/src/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/graphiql-plugin-explorer/src/index.tsx b/packages/graphiql-plugin-explorer/src/index.tsx index dd30bea59b3..79db7bd5c53 100644 --- a/packages/graphiql-plugin-explorer/src/index.tsx +++ b/packages/graphiql-plugin-explorer/src/index.tsx @@ -4,8 +4,7 @@ import { useExecutionContext, useSchemaContext, } from '@graphiql/react'; -import type { GraphiQLExplorerProps } from 'graphiql-explorer'; -import GraphiQLExplorerImport from 'graphiql-explorer'; +import { Explorer as GraphiQLExplorer, GraphiQLExplorerProps } from 'graphiql-explorer'; import React, { useCallback, useRef } from 'react'; import './graphiql-explorer.d.ts'; From fe7713b09a6c3b65e9c5329b828596707cbcc4f9 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Tue, 4 Jul 2023 08:02:36 +0200 Subject: [PATCH 4/5] remaining fix to use explorer import --- .../graphiql-plugin-explorer/src/graphiql-explorer.d.ts | 2 ++ packages/graphiql-plugin-explorer/src/index.tsx | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/graphiql-plugin-explorer/src/graphiql-explorer.d.ts b/packages/graphiql-plugin-explorer/src/graphiql-explorer.d.ts index d9560f7521f..66fffce659a 100644 --- a/packages/graphiql-plugin-explorer/src/graphiql-explorer.d.ts +++ b/packages/graphiql-plugin-explorer/src/graphiql-explorer.d.ts @@ -61,5 +61,7 @@ declare module 'graphiql-explorer' { defaultValue: (arg: GraphQLLeafType) => ValueNode; }; + export { GraphiQLExplorer as Explorer }; + export default GraphiQLExplorer; } diff --git a/packages/graphiql-plugin-explorer/src/index.tsx b/packages/graphiql-plugin-explorer/src/index.tsx index 79db7bd5c53..228f05f052a 100644 --- a/packages/graphiql-plugin-explorer/src/index.tsx +++ b/packages/graphiql-plugin-explorer/src/index.tsx @@ -4,14 +4,15 @@ import { useExecutionContext, useSchemaContext, } from '@graphiql/react'; -import { Explorer as GraphiQLExplorer, GraphiQLExplorerProps } from 'graphiql-explorer'; +import { + Explorer as GraphiQLExplorer, + GraphiQLExplorerProps, +} from 'graphiql-explorer'; import React, { useCallback, useRef } from 'react'; import './graphiql-explorer.d.ts'; import './index.css'; -const preferDefault = (m: any): any => m?.default || m; - const colors = { keyword: 'hsl(var(--color-primary))', def: 'hsl(var(--color-tertiary))', @@ -114,8 +115,6 @@ const styles = { }, }; -const GraphiQLExplorer = preferDefault(GraphiQLExplorerImport); - function ExplorerPlugin(props: GraphiQLExplorerProps) { const { setOperationName } = useEditorContext({ nonNull: true }); const { schema } = useSchemaContext({ nonNull: true }); From 2ccd847059d60ab6a8635495e94b8dced8bb6a9b Mon Sep 17 00:00:00 2001 From: LekoArts Date: Tue, 4 Jul 2023 08:05:42 +0200 Subject: [PATCH 5/5] adjust changelog --- .changeset/shaggy-eyes-melt.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/shaggy-eyes-melt.md b/.changeset/shaggy-eyes-melt.md index 8823393f45d..9233e74a67c 100644 --- a/.changeset/shaggy-eyes-melt.md +++ b/.changeset/shaggy-eyes-melt.md @@ -2,4 +2,4 @@ "@graphiql/plugin-explorer": patch --- -fix(graphiql-plugin-explorer): Use `preferDefault` helper to correctly import `graphiql-explorer` +Use named `Explorer` import from `graphiql-explorer` to fix an issue where the bundler didn't correctly choose either the `default` or `Explorer` import. This change should ensure that `@graphiql/plugin-explorer` works correctly without `graphiql-explorer` being bundled.