在supabase中,我在哪里可以找到GraphiQL资源管理器?
您是否知道在哪里,如何使用GraphiQl Explorer来查看我的模式并使用Supabase进行一些GraphQl请求?
Do you know where and how can i use a graphiql explorer to to see my schema and do some graphql request with Supabase ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用 graphiql 来探索您的模式并提出请求。
您也可以按照此快速启动指南(在此复制)。
克隆回购:
演示
然后,使用Docker-Composer: GraphIQL启动 a>。
You can use the GraphiQL to explore your schema and make requests.
You can also follow this quick-start guide (copied here).
Clone the repo:
Then, launch the demo with docker-composer:
GraphiQL will be available at http://localhost:4000/.
从
https://app.supabase.com/project/_/api/graphiql
从我可以看出的话,该编辑器在基于Docker的Supabase中不可用然而。
As of the Feb 2023 news release, there is now a GraphiQL editor in the dashboard. You can find it by clicking on the nav icon for API Docs (it's in shape of a document) or clicking the following link:
https://app.supabase.com/project/_/api/graphiql
From what I can tell, this editor isn't available in the self-hosted, Docker-based Supabase yet.
我将指出一种对我有用的解决方案,这应该为您提供足够的信息启动。
graphiql
使用graphiql有很多方法。您应该选择适合您案件的一种。更多信息在他们的
”它是使用在线graphiql app ( hasura ?)。
请注意,将其用于探索一个小测试项目应该可以,但是您应该提防您正在使用不属于您的在线应用程序并授予其身份证书。
URL和标头
URL应处于形式:
{your-app-url}/graphql/v1
您还需要至少添加标头
apikey
,我相信的值应该是您的supabase项目中找到的匿名公共密钥。您可能还需要
授权
标题(在我的基本测试中,我没有超出该测试),如果您想访问API作为特定用户。标题的值应为该用户的有效JWT。请注意,匿名公共密钥本身就是JWT。 “ https://jwt.io/”中查看其内容
您可以在
如果您对此有任何疑问,请参见此“ nofollow noreferrer”> postgrest fivese 。
或者,您可以自己构建JWT,因为您可以在Supabase项目中获得秘密。在线应该有很多资源来教授如何做到这一点。
一个不合时宜的用户的实践示例:
您可以将普通的Anon-Public-Key用于Apikey标头。这意味着,有一个虚构的项目
anon-public-key = gdgdgdgdgdgdgd.jhygtgg
标题将具有此表格:apikey:gdgdgdgdgdgdgdgdgd.jhygtgg
,如果一切都正确,则应在右上看到文档探索者用GraphQL模式填充自动。
I will indicate a solution that worked for me and that should give you enough info to start.
Graphiql
There are many ways to use Graphiql. You should choose the one that is adequate to your case. More info in their repo
A quick way to test it is to use the online Graphiql app (built by hasura?).
Note that using it for exploring a little test project should be ok, but you should beware that you are using an online app that do not belong to you and giving it auth credentials.
URL and Header
The url should be in the form:
{your-app-url}/graphql/v1
You will also need to add at least a header
apikey
, the value which, i believe, should be the anonym public key that is found in your supabase project.You might also need an
authorization
header (in my basic test i didn't test beyond that), if you want to access the API as a specific user. The value of the header should be a valid JWT for that user.Note that the anonym public key is itself a JWT. You can view its content in https://jwt.io/
A good way to obtain the values for those headers is to get them from the API tab and the auto generated curl that it give you.
If you have any doubt about this, see this PostgREST video.
Or you could just construct the JWT yourself since you can get the secret in your supabase project. There should be many resources online that teach how to do it.
A practical example for an anonimous user:
You can use the normal anon-public-key for the apikey header. That means that with a project that has a fictitious
anon-public-key= gdgdgdgdgdgd.jhygtgg
the headers will have this form:apikey: gdgdgdgdgdgd.jhygtgg
If everything is correct, you should see the documentation explorer on the right being auto populated with the graphql schema.
避免Hasura的在线编辑的预防措施将是一个好主意。有一个轻巧的工具我们的团队已经使用了。
Would be a good idea to avoid Hasura's online editor as a precaution. There's a lightweight tool that our teams have been using.