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

fix(graphiql-plugin-explorer): Use named Explorer import from graphiql-explorer #3319

Merged
merged 5 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .changeset/shaggy-eyes-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphiql/plugin-explorer": patch
---

fix(graphiql-plugin-explorer): Use `preferDefault` helper to correctly import `graphiql-explorer`
8 changes: 7 additions & 1 deletion packages/graphiql-plugin-explorer/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
LekoArts marked this conversation as resolved.
Show resolved Hide resolved
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))',
Expand Down Expand Up @@ -71,6 +74,7 @@ const checkboxUnchecked = (
<circle cx="7.5" cy="7.5" r="6" stroke="currentColor" fill="none" />
</svg>
);

const checkboxChecked = (
<svg
viewBox="0 0 15 15"
Expand Down Expand Up @@ -111,6 +115,8 @@ const styles = {
},
};

const GraphiQLExplorer = preferDefault(GraphiQLExplorerImport);

function ExplorerPlugin(props: GraphiQLExplorerProps) {
const { setOperationName } = useEditorContext({ nonNull: true });
const { schema } = useSchemaContext({ nonNull: true });
Expand Down