我有一个用src/schema.graphql编写的客户端模式和一些用src/graphql/queries.ts编写的查询。
目前,我的所有查询都包含@rest directive from apollo-link-rest,我正在尝试使用以下命令使用apollo client:codegen为它们生成Typescript类型:
apollo client:codegen ./src/__generated__/types.ts --outputFlat --includes=./src/**/queries.ts --addTypename --localSchemaFile=./src/schema.graphql --target=typescript这总是会导致
.../src/graphql/queries.ts: Unknown directive "rest".
ToolError: Validation of GraphQL query document failed我不明白我做错了什么。根据the docs here的说法,阿波罗应该开箱即用地支持@client和@rest客户端指令。
有没有人成功地用@rest或@client指令生成了查询类型?
发布于 2019-10-10 20:02:40
嗯,一堆文档页面之后,似乎如果我在src/schema.graphql中声明如下指令,它似乎可以工作:
directive @rest(
type: String!
path: String!
method: String
) on FIELD注意:此声明不包含所有可能的参数。请参阅docs for the complete list of arguments。
有没有人能确认这是正确的做法?
https://stackoverflow.com/questions/58319543
复制相似问题