python-3.x - 如何使用“flask-graphql”将资源管理器添加到 GraphiQL?
问题描述
我正在使用 GraphiQL 服务,flask-graphql
但没有看到任何方法可以在不使用 Node.JS 的情况下启用 GraphiQL 的“资源管理器”。有没有办法为 Python ( flask-graphql
) 后端启用资源管理器?
解决方案
Node.js 不是必需的,但 React是graphiql
必需的,因为两者graphiql-explorer
都是 React 组件。flask-graphql
只需使用 React 呈现 GraphiQL 界面的脚本来呈现 HTML 页面,如下所示。
在通过此处graphiql_template
显示的选项创建 GraphQLView 时,您应该能够提供自己的模板来呈现此页面。
复制并粘贴现有模板,然后为库添加脚本标签:
<script src="//cdn.jsdelivr.net/npm/graphiql-explorer@0.4.6/graphiqlExplorer.min.js"></script>
并按照此处所示实现组件。由于您没有转换此代码,因此您将无法使用 JSX,因此您需要执行类似...
React.createElement(
"div",
{ className: "graphiql-container" },
React.createElement(
GraphiQLExplorer,
{ /* props here */ },
),
React.createElement(
GraphiQL,
{ /* props here */ },
)
)
推荐阅读
- azure-ad-graph-api - 获取 https://graph.microsoft.com/v1.0/groups
- html - Shiny bsPopover中单个文本元素的字体颜色
- python - 从具有重复行的两个列表创建列 - Pandas
- angular - 将 ngx-charts 作为单独组件导入 Angular 时出错:错误 NG8001:'ngx-charts-tree-map' 不是已知元素
- python - 无需重复代码即可添加到众多列表 Python
- reactjs - 'ChangeEvent<{}>' 类型的参数不可分配 - 与 TypeScript 反应
- python - 如何正确指定pyinstaller资源文件?
- c++ - clang 和 gcc 不实现 std::hardware_{constructive, destroyive}_interference_size 的原因是什么?
- javascript - 选择不同的值时 setInterval 无法正常工作
- build - 自托管构建代理花费太多时间来成功运行作业