如何使用Graphql SPQR实现查询过滤器和排序?
我正在寻找使用Graphql SPQR解决方案的解决方案,该方案如下所示。
app.listen(port, () => console.log(`Running on port ${port}`))
答案 0 :(得分:0)
GraphQL SPQR依赖于代码优先方法。您需要创建Java类和解析器并正确注释它们:
public enum SortOrder {
@GraphQLEnumValue(name = "ASC") ASC,
@GraphQLEnumValue(name = "DESC") DESC
}
public class Article {
//Article implementation here
}
public class Feedback {
//Feedback implementation here
}
public class GraphQLResolver {
@GraphQLQuery(name = "getAllArticles", description = "Search articles")
public List<Article> getAllArticles(
@NotNull @GraphQLArgument(name = "pageNumber") int pageNumber,
@NotNull @GraphQLArgument(name = "pageSize") int pageSize,
@NotNull @GraphQLArgument(name = "sortOrder") SortOrder sortOrder,
@NotNull @GraphQLArgument(name = "sortBy") String sortBy) {
//Query implementation here
}
//implement other queries and mutation
}
按照https://github.com/leangen/graphql-spqr的自述文件公开您的graphql解析器。