Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphiql

Package Overview
Dependencies
Maintainers
12
Versions
559
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphiql - npm Package Compare versions

Comparing version 4.0.0-alpha.0 to 4.0.0-alpha.1

53

dist/index.d.ts

@@ -1,4 +0,4 @@

import { default as default_2 } from 'react';
import { GraphiQLProvider } from '@graphiql/react';
import { GraphiQLProviderProps } from '@graphiql/react';
import { JSX as JSX_2 } from 'react';
import { PropsWithChildren } from 'react';

@@ -16,3 +16,3 @@ import { ReactNode } from 'react';

export declare function GraphiQL({ dangerouslyAssumeSchemaIsValid, defaultQuery, defaultTabs, externalFragments, fetcher, getDefaultFieldNames, headers, inputValueDeprecation, introspectionQueryName, maxHistoryLength, onEditOperationName, onSchemaChange, onTabChange, onTogglePluginVisibility, operationName, plugins, query, response, schema, schemaDescription, shouldPersistHeaders, storage, validationRules, variables, visiblePlugin, defaultHeaders, ...props }: GraphiQLProps): default_2.JSX.Element;
export declare function GraphiQL({ dangerouslyAssumeSchemaIsValid, defaultQuery, defaultTabs, externalFragments, fetcher, getDefaultFieldNames, headers, inputValueDeprecation, introspectionQueryName, maxHistoryLength, onEditOperationName, onSchemaChange, onTabChange, onTogglePluginVisibility, operationName, plugins, query, response, schema, schemaDescription, shouldPersistHeaders, storage, validationRules, variables, visiblePlugin, defaultHeaders, ...props }: GraphiQLProps): JSX_2.Element;

@@ -25,10 +25,6 @@ export declare namespace GraphiQL {

declare function GraphiQLFooter<TProps>(props: PropsWithChildren<TProps>): default_2.JSX.Element;
declare function GraphiQLFooter<TProps>(props: PropsWithChildren<TProps>): JSX_2.Element;
declare namespace GraphiQLFooter {
var displayName: string;
}
export declare function GraphiQLInterface(props: GraphiQLInterfaceProps): JSX_2.Element;
export declare function GraphiQLInterface(props: GraphiQLInterfaceProps): default_2.JSX.Element;
export declare type GraphiQLInterfaceProps = WriteableEditorProps & AddSuffix<Pick<UseQueryEditorArgs, 'onEdit'>, 'Query'> & Pick<UseQueryEditorArgs, 'onCopyQuery'> & AddSuffix<Pick<UseVariableEditorArgs, 'onEdit'>, 'Variables'> & AddSuffix<Pick<UseHeaderEditorArgs, 'onEdit'>, 'Headers'> & Pick<UseResponseEditorArgs, 'responseTooltip'> & {

@@ -38,3 +34,2 @@ children?: ReactNode;

isHeadersEditorEnabled?: boolean;
toolbar?: GraphiQLToolbarConfig;
showPersistHeadersSettings?: boolean;

@@ -45,8 +40,4 @@ forcedTheme?: (typeof THEMES)[number];

declare function GraphiQLLogo<TProps>(props: PropsWithChildren<TProps>): default_2.JSX.Element;
declare function GraphiQLLogo<TProps>({ children, }: PropsWithChildren<TProps>): JSX_2.Element;
declare namespace GraphiQLLogo {
var displayName: string;
}
export declare type GraphiQLProps = Omit<GraphiQLProviderProps, 'children'> & GraphiQLInterfaceProps;

@@ -58,30 +49,14 @@

declare function GraphiQLToolbar<TProps>(props: PropsWithChildren<TProps>): default_2.JSX.Element;
declare function GraphiQLToolbar({ children, onCopyQuery, }: {
children?: ToolbarRenderProps;
}): JSX_2.Element;
declare namespace GraphiQLToolbar {
var displayName: string;
}
declare const THEMES: readonly ["light", "dark", "system"];
declare type GraphiQLToolbarConfig = {
additionalContent?: default_2.ReactNode;
additionalComponent?: default_2.JSXElementConstructor<any>;
};
declare type ToolbarRenderProps = (props: {
prettify: ReactNode;
copy: ReactNode;
merge: ReactNode;
}) => JSX_2.Element;
declare const THEMES: readonly ["light", "dark", "system"];
export { }
declare namespace GraphiQLLogo {
var displayName: string;
}
declare namespace GraphiQLToolbar {
var displayName: string;
}
declare namespace GraphiQLFooter {
var displayName: string;
}

@@ -44,2 +44,3 @@ "use strict";

}) {
var _a, _b;
if (typeof fetcher !== "function") {

@@ -50,2 +51,12 @@ throw new TypeError(

}
if ((_a = props.toolbar) == null ? void 0 : _a.additionalContent) {
throw new TypeError(
"`toolbar.additionalContent` was removed. Use render props on `GraphiQL.Toolbar` component instead."
);
}
if ((_b = props.toolbar) == null ? void 0 : _b.additionalComponent) {
throw new TypeError(
"`toolbar.additionalComponent` was removed. Use render props on `GraphiQL.Toolbar` component instead."
);
}
return /* @__PURE__ */ React.createElement(

@@ -96,3 +107,3 @@ react.GraphiQLProvider,

function GraphiQLInterface(props) {
var _a, _b, _c;
var _a;
const isHeadersEditorEnabled = props.isHeadersEditorEnabled ?? true;

@@ -108,5 +119,2 @@ const editorContext = react.useEditorContext({ nonNull: true });

);
const copy = react.useCopyQuery({ onCopyQuery: props.onCopyQuery });
const merge = react.useMergeQuery();
const prettify = react.usePrettifyEditors();
const { theme, setTheme } = react.useTheme();

@@ -160,18 +168,25 @@ React.useEffect(() => {

const [clearStorageStatus, setClearStorageStatus] = React.useState(null);
const children = React.Children.toArray(props.children);
const logo = children.find(
(child) => isChildComponentType(child, GraphiQL.Logo)
) || /* @__PURE__ */ React.createElement(GraphiQL.Logo, null);
const toolbar = children.find(
(child) => isChildComponentType(child, GraphiQL.Toolbar)
) || /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(react.ToolbarButton, { onClick: prettify, label: "Prettify query (Shift-Ctrl-P)" }, /* @__PURE__ */ React.createElement(react.PrettifyIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" })), /* @__PURE__ */ React.createElement(
react.ToolbarButton,
{
onClick: merge,
label: "Merge fragments into query (Shift-Ctrl-M)"
},
/* @__PURE__ */ React.createElement(react.MergeIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" })
), /* @__PURE__ */ React.createElement(react.ToolbarButton, { onClick: copy, label: "Copy query (Shift-Ctrl-C)" }, /* @__PURE__ */ React.createElement(react.CopyIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" })), (_b = props.toolbar) == null ? void 0 : _b.additionalContent, ((_c = props.toolbar) == null ? void 0 : _c.additionalComponent) && /* @__PURE__ */ React.createElement(props.toolbar.additionalComponent, null));
const footer = children.find(
(child) => isChildComponentType(child, GraphiQL.Footer)
const {
logo = /* @__PURE__ */ React.createElement(GraphiQL.Logo, null),
// @ts-expect-error -- Prop exists but hidden for users
toolbar = /* @__PURE__ */ React.createElement(GraphiQL.Toolbar, { onCopyQuery: props.onCopyQuery }),
footer
} = React.useMemo(
() => React.Children.toArray(props.children).reduce((acc, curr) => {
switch (getChildComponentType(curr)) {
case GraphiQL.Logo:
acc.logo = curr;
break;
case GraphiQL.Toolbar:
acc.toolbar = React.cloneElement(curr, {
onCopyQuery: props.onCopyQuery
});
break;
case GraphiQL.Footer:
acc.footer = curr;
break;
}
return acc;
}, {}),
[props.children, props.onCopyQuery]
);

@@ -260,8 +275,6 @@ const onClickReference = React.useCallback(() => {

}, []);
const hasMultipleTabs = editorContext.tabs.length > 1;
const className = props.className ? ` ${props.className}` : "";
return /* @__PURE__ */ React.createElement(react.Tooltip.Provider, null, /* @__PURE__ */ React.createElement("div", { className: `graphiql-container${className}` }, /* @__PURE__ */ React.createElement("div", { className: "graphiql-sidebar" }, /* @__PURE__ */ React.createElement("div", { className: "graphiql-sidebar-section" }, pluginContext == null ? void 0 : pluginContext.plugins.map((plugin, index) => {
return /* @__PURE__ */ React.createElement(react.Tooltip.Provider, null, /* @__PURE__ */ React.createElement("div", { className: `graphiql-container${className}` }, /* @__PURE__ */ React.createElement("div", { className: "graphiql-sidebar" }, pluginContext == null ? void 0 : pluginContext.plugins.map((plugin, index) => {
const isVisible = plugin === pluginContext.visiblePlugin;
const label = `${isVisible ? "Hide" : "Show"} ${plugin.title}`;
const Icon = plugin.icon;
return /* @__PURE__ */ React.createElement(react.Tooltip, { key: plugin.title, label }, /* @__PURE__ */ React.createElement(

@@ -276,5 +289,5 @@ react.UnStyledButton,

},
/* @__PURE__ */ React.createElement(Icon, { "aria-hidden": "true" })
/* @__PURE__ */ React.createElement(plugin.icon, { "aria-hidden": "true" })
));
})), /* @__PURE__ */ React.createElement("div", { className: "graphiql-sidebar-section" }, /* @__PURE__ */ React.createElement(react.Tooltip, { label: "Re-fetch GraphQL schema" }, /* @__PURE__ */ React.createElement(
}), /* @__PURE__ */ React.createElement(react.Tooltip, { label: "Re-fetch GraphQL schema" }, /* @__PURE__ */ React.createElement(
react.UnStyledButton,

@@ -285,3 +298,4 @@ {

onClick: handleRefetchSchema,
"aria-label": "Re-fetch GraphQL schema"
"aria-label": "Re-fetch GraphQL schema",
style: { marginTop: "auto" }
},

@@ -313,3 +327,3 @@ /* @__PURE__ */ React.createElement(

/* @__PURE__ */ React.createElement(react.SettingsIcon, { "aria-hidden": "true" })
)))), /* @__PURE__ */ React.createElement("div", { className: "graphiql-main" }, /* @__PURE__ */ React.createElement(
))), /* @__PURE__ */ React.createElement("div", { className: "graphiql-main" }, /* @__PURE__ */ React.createElement(
"div",

@@ -331,3 +345,3 @@ {

}
), /* @__PURE__ */ React.createElement("div", { ref: pluginResize.secondRef, className: "graphiql-sessions" }, /* @__PURE__ */ React.createElement("div", { className: "graphiql-session-header" }, hasMultipleTabs && /* @__PURE__ */ React.createElement(
), /* @__PURE__ */ React.createElement("div", { ref: pluginResize.secondRef, className: "graphiql-sessions" }, /* @__PURE__ */ React.createElement("div", { className: "graphiql-session-header" }, /* @__PURE__ */ React.createElement(
react.Tabs,

@@ -339,9 +353,10 @@ {

},
editorContext.tabs.map((tab, index) => /* @__PURE__ */ React.createElement(react.Tooltip, { key: tab.id, label: tab.title }, /* @__PURE__ */ React.createElement(
editorContext.tabs.map((tab, index, tabs) => /* @__PURE__ */ React.createElement(
react.Tab,
{
key: tab.id,
value: tab,
isActive: index === editorContext.activeTabIndex
},
/* @__PURE__ */ React.createElement(
/* @__PURE__ */ React.createElement(react.Tooltip, { label: tab.title }, /* @__PURE__ */ React.createElement(
react.Tab.Button,

@@ -357,4 +372,4 @@ {

tab.title
),
/* @__PURE__ */ React.createElement(
)),
tabs.length > 1 && /* @__PURE__ */ React.createElement(
react.Tab.Close,

@@ -370,3 +385,3 @@ {

)
)))
))
), /* @__PURE__ */ React.createElement(react.Tooltip, { label: "New tab" }, /* @__PURE__ */ React.createElement(

@@ -389,113 +404,102 @@ react.UnStyledButton,

},
/* @__PURE__ */ React.createElement("div", { ref: editorResize.firstRef }, /* @__PURE__ */ React.createElement(
"div",
/* @__PURE__ */ React.createElement("div", { ref: editorResize.firstRef }, /* @__PURE__ */ React.createElement("div", { className: "graphiql-editors" }, /* @__PURE__ */ React.createElement("div", { ref: editorToolsResize.firstRef }, /* @__PURE__ */ React.createElement(
"section",
{
className: "graphiql-editors",
style: hasMultipleTabs ? { borderTopLeftRadius: 0, borderTopRightRadius: 0 } : {
marginTop: "calc(var(--px-8) - var(--session-header-height))"
}
className: "graphiql-query-editor",
"aria-label": "Query Editor"
},
/* @__PURE__ */ React.createElement("div", { ref: editorToolsResize.firstRef }, /* @__PURE__ */ React.createElement(
"section",
/* @__PURE__ */ React.createElement(
react.QueryEditor,
{
className: "graphiql-query-editor",
"aria-label": "Query Editor"
},
/* @__PURE__ */ React.createElement(
react.QueryEditor,
{
editorTheme: props.editorTheme,
keyMap: props.keyMap,
onClickReference,
onCopyQuery: props.onCopyQuery,
onEdit: props.onEditQuery,
readOnly: props.readOnly
}
),
/* @__PURE__ */ React.createElement(
"div",
{
className: "graphiql-toolbar",
role: "toolbar",
"aria-label": "Editor Commands"
},
/* @__PURE__ */ React.createElement(react.ExecuteButton, null),
toolbar
)
)),
/* @__PURE__ */ React.createElement("div", { ref: editorToolsResize.dragBarRef }, /* @__PURE__ */ React.createElement("div", { className: "graphiql-editor-tools" }, /* @__PURE__ */ React.createElement(
react.UnStyledButton,
editorTheme: props.editorTheme,
keyMap: props.keyMap,
onClickReference,
onCopyQuery: props.onCopyQuery,
onEdit: props.onEditQuery,
readOnly: props.readOnly
}
),
/* @__PURE__ */ React.createElement(
"div",
{
type: "button",
className: activeSecondaryEditor === "variables" && editorToolsResize.hiddenElement !== "second" ? "active" : "",
onClick: handleToolsTabClick,
"data-name": "variables"
className: "graphiql-toolbar",
role: "toolbar",
"aria-label": "Editor Commands"
},
"Variables"
), isHeadersEditorEnabled && /* @__PURE__ */ React.createElement(
/* @__PURE__ */ React.createElement(react.ExecuteButton, null),
toolbar
)
)), /* @__PURE__ */ React.createElement("div", { ref: editorToolsResize.dragBarRef }, /* @__PURE__ */ React.createElement("div", { className: "graphiql-editor-tools" }, /* @__PURE__ */ React.createElement(
react.UnStyledButton,
{
type: "button",
className: activeSecondaryEditor === "variables" && editorToolsResize.hiddenElement !== "second" ? "active" : "",
onClick: handleToolsTabClick,
"data-name": "variables"
},
"Variables"
), isHeadersEditorEnabled && /* @__PURE__ */ React.createElement(
react.UnStyledButton,
{
type: "button",
className: activeSecondaryEditor === "headers" && editorToolsResize.hiddenElement !== "second" ? "active" : "",
onClick: handleToolsTabClick,
"data-name": "headers"
},
"Headers"
), /* @__PURE__ */ React.createElement(
react.Tooltip,
{
label: editorToolsResize.hiddenElement === "second" ? "Show editor tools" : "Hide editor tools"
},
/* @__PURE__ */ React.createElement(
react.UnStyledButton,
{
type: "button",
className: activeSecondaryEditor === "headers" && editorToolsResize.hiddenElement !== "second" ? "active" : "",
onClick: handleToolsTabClick,
"data-name": "headers"
onClick: toggleEditorTools,
"aria-label": editorToolsResize.hiddenElement === "second" ? "Show editor tools" : "Hide editor tools",
className: "graphiql-toggle-editor-tools"
},
"Headers"
), /* @__PURE__ */ React.createElement(
react.Tooltip,
{
label: editorToolsResize.hiddenElement === "second" ? "Show editor tools" : "Hide editor tools"
},
/* @__PURE__ */ React.createElement(
react.UnStyledButton,
editorToolsResize.hiddenElement === "second" ? /* @__PURE__ */ React.createElement(
react.ChevronUpIcon,
{
type: "button",
onClick: toggleEditorTools,
"aria-label": editorToolsResize.hiddenElement === "second" ? "Show editor tools" : "Hide editor tools",
className: "graphiql-toggle-editor-tools"
},
editorToolsResize.hiddenElement === "second" ? /* @__PURE__ */ React.createElement(
react.ChevronUpIcon,
{
className: "graphiql-chevron-icon",
"aria-hidden": "true"
}
) : /* @__PURE__ */ React.createElement(
react.ChevronDownIcon,
{
className: "graphiql-chevron-icon",
"aria-hidden": "true"
}
)
)
))),
/* @__PURE__ */ React.createElement("div", { ref: editorToolsResize.secondRef }, /* @__PURE__ */ React.createElement(
"section",
{
className: "graphiql-editor-tool",
"aria-label": activeSecondaryEditor === "variables" ? "Variables" : "Headers"
},
/* @__PURE__ */ React.createElement(
react.VariableEditor,
{
editorTheme: props.editorTheme,
isHidden: activeSecondaryEditor !== "variables",
keyMap: props.keyMap,
onEdit: props.onEditVariables,
onClickReference,
readOnly: props.readOnly
className: "graphiql-chevron-icon",
"aria-hidden": "true"
}
),
isHeadersEditorEnabled && /* @__PURE__ */ React.createElement(
react.HeaderEditor,
) : /* @__PURE__ */ React.createElement(
react.ChevronDownIcon,
{
editorTheme: props.editorTheme,
isHidden: activeSecondaryEditor !== "headers",
keyMap: props.keyMap,
onEdit: props.onEditHeaders,
readOnly: props.readOnly
className: "graphiql-chevron-icon",
"aria-hidden": "true"
}
)
))
)),
)
))), /* @__PURE__ */ React.createElement("div", { ref: editorToolsResize.secondRef }, /* @__PURE__ */ React.createElement(
"section",
{
className: "graphiql-editor-tool",
"aria-label": activeSecondaryEditor === "variables" ? "Variables" : "Headers"
},
/* @__PURE__ */ React.createElement(
react.VariableEditor,
{
editorTheme: props.editorTheme,
isHidden: activeSecondaryEditor !== "variables",
keyMap: props.keyMap,
onEdit: props.onEditVariables,
onClickReference,
readOnly: props.readOnly
}
),
isHeadersEditorEnabled && /* @__PURE__ */ React.createElement(
react.HeaderEditor,
{
editorTheme: props.editorTheme,
isHidden: activeSecondaryEditor !== "headers",
keyMap: props.keyMap,
onEdit: props.onEditHeaders,
readOnly: props.readOnly
}
)
)))),
/* @__PURE__ */ React.createElement(

@@ -618,4 +622,4 @@ "div",

}
function GraphiQLLogo(props) {
return /* @__PURE__ */ React.createElement("div", { className: "graphiql-logo" }, props.children || /* @__PURE__ */ React.createElement(
function GraphiQLLogo({
children = /* @__PURE__ */ React.createElement(
"a",

@@ -631,19 +635,43 @@ {

"QL"
));
)
}) {
return /* @__PURE__ */ React.createElement("div", { className: "graphiql-logo" }, children);
}
GraphiQLLogo.displayName = "GraphiQLLogo";
function GraphiQLToolbar(props) {
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
const DefaultToolbarRenderProps = ({
prettify,
copy,
merge
}) => /* @__PURE__ */ React.createElement(React.Fragment, null, prettify, merge, copy);
function GraphiQLToolbar({
children = DefaultToolbarRenderProps,
// @ts-expect-error -- Hide this prop for user, we use cloneElement to pass onCopyQuery
onCopyQuery
}) {
if (typeof children !== "function") {
throw new TypeError(
"The `GraphiQL.Toolbar` component requires a render prop function as its child."
);
}
const onCopy = react.useCopyQuery({ onCopyQuery });
const onMerge = react.useMergeQuery();
const onPrettify = react.usePrettifyEditors();
const prettify = /* @__PURE__ */ React.createElement(react.ToolbarButton, { onClick: onPrettify, label: "Prettify query (Shift-Ctrl-P)" }, /* @__PURE__ */ React.createElement(react.PrettifyIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" }));
const merge = /* @__PURE__ */ React.createElement(
react.ToolbarButton,
{
onClick: onMerge,
label: "Merge fragments into query (Shift-Ctrl-M)"
},
/* @__PURE__ */ React.createElement(react.MergeIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" })
);
const copy = /* @__PURE__ */ React.createElement(react.ToolbarButton, { onClick: onCopy, label: "Copy query (Shift-Ctrl-C)" }, /* @__PURE__ */ React.createElement(react.CopyIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" }));
return children({ prettify, copy, merge });
}
GraphiQLToolbar.displayName = "GraphiQLToolbar";
function GraphiQLFooter(props) {
return /* @__PURE__ */ React.createElement("div", { className: "graphiql-footer" }, props.children);
}
GraphiQLFooter.displayName = "GraphiQLFooter";
function isChildComponentType(child, component) {
var _a;
if (((_a = child == null ? void 0 : child.type) == null ? void 0 : _a.displayName) && child.type.displayName === component.displayName) {
return true;
function getChildComponentType(child) {
if (child && typeof child === "object" && "type" in child && typeof child.type === "function") {
return child.type;
}
return child.type === component;
}

@@ -650,0 +678,0 @@ Object.defineProperty(exports, "GraphiQLProvider", {

{
"name": "graphiql",
"version": "4.0.0-alpha.0",
"version": "4.0.0-alpha.1",
"description": "An graphical interactive in-browser GraphQL IDE.",

@@ -5,0 +5,0 @@ "contributors": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc