如何从GraphQl API端点获取模式

发布于 2025-01-22 15:18:51 字数 259 浏览 3 评论 0原文

我需要从GraphQL API端点获取模式。 因此,结果必须是一个字符串:

  type User {
    id: ID!
    name: String!
  }

  type Home {
    user: User!
    address: String
    country: String!
  }

  type Query {
    MyUsers: User!
  }

是否可以使用CodeGen可以执行吗?

I need to fetch a schema from graphQL API endpoint.
So the result must be a string like:

  type User {
    id: ID!
    name: String!
  }

  type Home {
    user: User!
    address: String
    country: String!
  }

  type Query {
    MyUsers: User!
  }

Is it possible to do by using codegen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

°如果伤别离去 2025-01-29 15:18:51

它确实取决于您正在使用的GraphQL Server,某些GraphQL服务器提供了GraphQl Explorer。 GraphQl Explorer是一个页面,您可以在其中手动输入GraphQl查询到页面,例如GraphIQL

其他方法是尝试 graphql-cli 您可以使用以下命令来完成

get-graphql-schema ENDPOINT_URL -j > schema.json

It really depends on the GraphQL server you are using, Some GraphQL servers provide a GraphQL Explorer. The GraphQL Explorer is a page where you can manually input GraphQL queries into the page such as Graphiql

Other way is to try out graphql-cli you can do with the below command,

get-graphql-schema ENDPOINT_URL -j > schema.json
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文