我正在使用flask-graphql
提供GraphiQL,但是如果不使用Node.JS,则看不到任何启用GraphiQL的“资源管理器”的方法。有没有办法为Python(flask-graphql
)后端启用资源管理器?
Node.js不是必需的,但是React is,因为graphiql
和graphiql-explorer
都是React组件。 flask-graphql
只是使用脚本渲染HTML页面,该脚本使用here所示的React来渲染GraphiQL接口。
[如图graphiql_template
所示,通过here选项创建GraphQLView时,您应该能够提供自己的模板来呈现此页面。
复制并粘贴现有模板,然后为库添加脚本标签:
<script src="//cdn.jsdelivr.net/npm/[email protected]/graphiqlExplorer.min.js"></script>
并执行here所示的组件。由于您没有在编译此代码,因此您将无法使用JSX,因此您需要执行以下操作...
React.createElement(
"div",
{ className: "graphiql-container" },
React.createElement(
GraphiQLExplorer,
{ /* props here */ },
),
React.createElement(
GraphiQL,
{ /* props here */ },
)
)