我真的很喜欢 SPQR 易于集成的方式 图形对于现有系统,我唯一想看到的是.graphqls文件,以便我可以了解有关 GraphQL 语法的更多信息。有没有办法从集成了 SPQR 注释的现有代码生成方案文件?为了提供一些代码,让我们使用来自GitHub 站点的相同代码实体:public class User { private String name; private Integer id; private Date registrationDate; @GraphQLQuery(name = "name", description = "A person's name") public String getName() { return name; } @GraphQLQuery public Integer getId() { return id; } @GraphQLQuery(name = "regDate", description = "Date of registration") public Date getRegistrationDate() { return registrationDate; }}服务等级:class UserService { @GraphQLQuery(name = "user") public User getById(@GraphQLArgument(name = "id") Integer id) { ... }}预期输出:type User { id: Int! name: String! registrationDate: String}Query{ user(Int):User }
2 回答
aluckdog
TA贡献1847条经验 获得超7个赞
这并不是 SPQR 特有的。所有需要的类都由 graphql-java 本身提供:
new SchemaPrinter().print(schema);
要获得更详细的输出(使用标量、自省类型等),请为打印机提供以下选项:
new SchemaPrinter(
// Tweak the options accordingly
SchemaPrinter.Options.defaultOptions()
.includeScalarTypes(true)
.includeExtendedScalarTypes(true)
.includeIntrospectionTypes(true)
.includeSchemaDefintion(true)
).print(schema);
添加回答
举报
0/150
提交
取消