在我的Laravel应用程序中,我使用Laravel灯塔作为我的graphql服务器。现在,我已经将自定义查询和类型添加到graphql/schema.graphql文件中,我希望能够在位于Laravel项目中的TypeScript Vue 3应用程序中获得输入。但是,当我运行graphql-codegen --config codegen.yml命令时,它会失败,因为正在生成的查询与模式文件中的内容不匹配。
我的graphql/schema.graphql文件中的查询。
type Query {
posts: [Post!]! @paginate(defaultCount: 10)
}我在Vue组件中调用的查询
{
posts {
data {
uuid
body
user {
name
}
}
}
}下面的代码是我的codegen.yml文件
overwrite: true
schema: "./graphql/schema.graphql"
documents: "./resources/js/pages/**/*.vue"
generates:
./resources/js/generated.ts:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-vue-apollo-smart-ops"有什么想法,我需要指出它,或我如何使graphql-码元生成正确的类型?
发布于 2022-07-24 19:01:00
源模式由指令(如@paginate )转换。使用下面的artisan命令生成包含整个和最终模式的单个文件:
php artisan lighthouse:print-schema请参阅https://lighthouse-php.com/master/api-reference/commands.html#print-schema
https://stackoverflow.com/questions/73101095
复制相似问题