You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何默认显示GraphiQL Explorer?(Laravel环境)

如何在Laravel的GraphiQL实例中默认显示GraphiQL Explorer

要让GraphiQL Explorer默认展开显示,你需要在GraphiQLPluginExplorer.useExplorerPlugin的配置参数中添加defaultOpen: true——这是该插件官方提供的控制默认可见性的参数,你之前尝试的isVisible、visibility等并非正确配置项。

修改后的代码如下:

function GraphiQLWithExplorer() {
const [query, setQuery] = React.useState('');

    return React.createElement(GraphiQL, {
        fetcher: fetcher,
        query: query,
        onEditQuery: setQuery,
        defaultEditorToolsVisibility: true,
        plugins: [
            GraphiQLPluginExplorer.useExplorerPlugin({
                query: query,
                onEdit: setQuery,
                defaultOpen: true // 添加这一行开启默认显示
            })
        ],
    });
}

添加defaultOpen: true后,每次加载GraphiQL界面时,Explorer面板会自动展开显示,无需用户手动点击开启。

内容的提问来源于stack exchange,提问作者Michiel Bellen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 00:07:01