You shall not pass! This time, we'll look at how you can use filters to only return results based on specified rules.
models in the database have a model_schema_name which tells us which WebApp or Module they belong to. This time, we'll look at how you can use filters to only return results with a particular model_schema_name, or with a model_schema_name which matches a certain pattern.
The Starter Site comes packaged with a ready-built WebApp with the id of 1 and the name webapp_1.
We'll return to our query from the previous tutorial, but this time, we'll rename it from get_all_models to get_webapp_1 to reflect the different purpose we intend for it. We'll also be wanting to look at page 1 again. Code:
Next, we'll add a filter argument: Code:
In this tutorial we'll choose the model_schema_name to apply the filter to, because we're looking for items with the model_schema_name of webapp_1. Code:
We now have a choice about:
Explorer: When implementing this using the Explorer, the wizard will help you get the type of value correct. In this case, it provides you with quotes so that you can enter the value as a String:
You can adjust the filter to return items from a specific Module item only. In this example, we'll specify module_3 which is the Blog Module. Code:
This should return Blog Posts from the Blog Module.
You can adjust the filter to return Form Submissions from a specific Form only. In this example, we'll specify form_1 which is the Newsletter Sign Up Form. Code:
In order to learn GraphQL, you'll need to start experimenting with what you've picked up from this tutorials.
To help you do this, we'll now start to set you some challenges. These will ask you to tweak the examples we've given you so far and see if you can achieve the desired results.
We'll always give you the answers to the challenge in the following Article, so don't worry if you get stuck.
To carry out this challenge, you will need to create a second WebApp and add a couple of items in the Admin. By experimenting with the options in the documentation panel, see if you can filter the results so that:
We'll go over the answer to this challenge in the next Article.
We'll look at a possible solution to our challenge. After that, we'll continue to look at filtering queries in more detail, including: