GraphQL

Tutorial 3 - Answers to the First Filtering Challenge

5min
we look at a possible answer to tutorial 3's challenge this shows how to write a query which fetches all webapp items, not module items prerequisites this article shows the answers to a challenge if you've not had a go at the challenge yet, we'd recommend you head there first about graphql optional read more about graphql and when it might be best used challenge answers the trick here was to examine the tables and spot the common patterns in their values the two types of records we wanted had these tables beginning with "webapp " webapp 1 webapp 2 the types of records we don't want have table values without "webapp ", for example module 3 (blog module) module 14 (ecommerce module) form 1 newsletter sign up form submissions so, in order to filter for the records we do want and not the records we don't want, we need records which start with the string webapp code query get all webapps { records( page 1 per page 20 filter { table { starts with "webapp " } } ) { total pages results { table properties } } } notes in this method, there is no need to write one filter to include webapp items and another to remove module and form items from the results this is because the given rule efficiently achieves both at once explorer this is just one possible answer, you may have found a different method try and make sure you choose the best method for your use case you should always be looking out for a more efficient way of doing things next time we'll continue to look at filtering queries in more detail, including filtering by different fields, or properties filtering with different kinds of rules using more than one filter at once let's go!