How to implement query filters and sorting using Graphql SPQR?
I'm looking for a solution with Graphql SPQR for schema which looks something like this.
schema {
query: Query
mutation: Mutation
}
enumSortOrder {
ASC
DESC
}
type Article {
id: String
name: String
createdByUserId: String
createdOn: String
lastUpdatedOn: String
}
type Feedback {
id: String
feedbackText: String
articleId: String
createdByUserId: String
createdOn: String
lastUpdatedOn: String
}
type Query {
getAllArticles(pageNumber: Int!, pageSize : Int!, sortOrder: SortOrder!, sortBy: String!): [Article]
getFeedBacksForArticle(articleId: String!): [Feedback]
}
type Mutation {
createArticle(name: String!, createdByUserId: String!): Article
createNewFeedback(feedbackText: String!, articleId: String!, createdByUserId: String!): Feedback
}
GraphQL SPQR relies on a code-first approach. You need to create your java classes and resolver and annotate them properly:
Follow the readme at https://github.com/leangen/graphql-spqr to expose your graphql resolver.