我真的很喜歡 SPQR 易于集成的方式 圖形對于現(xiàn)有系統(tǒng),我唯一想看到的是.graphqls文件,以便我可以了解有關(guān) GraphQL 語法的更多信息。有沒有辦法從集成了 SPQR 注釋的現(xiàn)有代碼生成方案文件?為了提供一些代碼,讓我們使用來自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; }}服務(wù)等級:class UserService { @GraphQLQuery(name = "user") public User getById(@GraphQLArgument(name = "id") Integer id) { ... }}預(yù)期輸出:type User { id: Int! name: String! registrationDate: String}Query{ user(Int):User }
2 回答

aluckdog
TA貢獻1847條經(jīng)驗 獲得超7個贊
這并不是 SPQR 特有的。所有需要的類都由 graphql-java 本身提供:
new SchemaPrinter().print(schema);
要獲得更詳細的輸出(使用標(biāo)量、自省類型等),請為打印機提供以下選項:
new SchemaPrinter(
// Tweak the options accordingly
SchemaPrinter.Options.defaultOptions()
.includeScalarTypes(true)
.includeExtendedScalarTypes(true)
.includeIntrospectionTypes(true)
.includeSchemaDefintion(true)
).print(schema);
添加回答
舉報
0/150
提交
取消