Spring boot 集成 Graphql
重要文件
root.graphqls
定義方法參數以及返回值
type Query{
listTest(count: Int): [TestModel]
allTest: [TestModel]
}
schema.graphqls
定義實體的結構
type TestModel{
id: Int
name: String
version: String
testTime: Long
example: TestExampleModel
}
type TestExampleModel{
id: Int
name: String
desc: String
}
代碼
Query
查詢相關的操作
- 實現
GraphQLQueryResolver
對應root.graphqls
當中查詢方法的定義 - 實現
GraphQLResolver<T>
可以注入GraphQLQueryResolver
返回結果的屬性中
Mutation
修改相關的操作
Schema
類型
- type
- enum
- interface
注釋
"""
注釋
"""
描述
# 描述
描述可以顯示在
graphiql
的文檔中,方便查閱