Ale*_*zev 5 javascript node.js apollo graphql
我有许多包含不同查询的类型定义的文件,如下所示:
const typeDefs = gql`
type Query {
hello: String
}
`
// Provide resolver functions for your schema fields
const resolvers = {
Query: {
hello: () => 'Hello world!'
},
}
const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
export default schema
Run Code Online (Sandbox Code Playgroud)
我有很多这样的文件,后来它们被组合成一个模式。
我想为每个 typeDef 生成打字稿类型。
我找到了几种从 graphql 生成类型的解决方案,例如:https://graphql-code-generator.com
但它们都是基于将内省查询结果解析为运行 API 来工作的。
我认为,这对于我的开发过程来说非常笨重 - 必须运行类型生成,我必须事先运行服务器,我还必须添加所需的身份验证标头,尽管事实上生成完全独立于服务器,但它只取决于我声明的 typeDefs。
是否有任何工具可以将 typedef 作为参数传递给某个函数并基于它生成打字稿?
| 归档时间: |
|
| 查看次数: |
407 次 |
| 最近记录: |