Skip to content

GraphQL

Gilles Djawa edited this page Dec 4, 2024 · 4 revisions

Example of a simple search searchBooks( filter: { and: [{ author: { pet: { name: { containsic: "ex" } } } }] } // and is optional if the list has only one Map element ) { data{ title id genre author(join: RIGHT) { // Specifying the join type is optional id name pet(join: LEFT) { id name } } } currentPage // You can specify what paging information you want to be returned currentPageCount total totalPages pageSize } } ** Example of a more complex search** query MyQuery { complexBooksSearch(filter: {title: {containsic: "lorax"}}, paging : {page: 1, size: 10, sortOrders: [{ field: "Book.title", sortDirection: ASC }]}, aggregates: {count: [Book_genre]}, fields: [Book_id, Book_title, Book_genre] ) }

** Example of a count query** query test{ countBooks( filter: {and: [{author: {name: {contains: "ss"}}}, {title: {containsic: "lorax"}}]}, clause: {distinct: true}, fields: Book_title // The field to count on ) }

Aggregates are not supported in the count query Since a Count query is already an aggregate query The fields parameter is optional and is used to specify the fields to be returned in the response The aggregates parameter is optional and is used to specify the fields to be aggregated The paging parameter is optional and is used to specify the paging information The clause parameter is optional and is used to specify the SQL clause to be used in the query. For now only distinct is supported The filter parameter is optional and is used to specify the filter criteria Joins can't be used with aggregates Aggregates return a JSON object since the result shape is not known

Application independent part of the schema is located in the components-expression/src/main/resources/graphql folder Other Scalars can be added in the customScalars.graphqls file. Please follow the instructions in the file

Clone this wiki locally