LogoLogo
Siteglide.comAdminRoadmap
  • 👋Welcome
  • Get Started
    • 🚀Quickstart Guides
    • ❔Support & FAQs
      • ℹ️Siteglide Support Policy
      • ℹ️Siteglide Technology Stack
      • ℹ️External Resources
      • ℹ️Front-end Browser Support
  • Portal
    • Account
    • Sites
      • 🚀Quickstart: Create a Site
      • ℹ️Site Details
      • ℹ️Site Users
      • 📋Install & Manage Modules
      • 💳Go Live
      • 💳Subscription
      • 🌍Domains
        • 📋Add a Fully Delegated Domain
        • 📋Add an External Domain
        • 💻Subdomain on a separate instance
        • 📋How to setup a multi domain start page
      • ☁️Site Backups and Disaster Recovery
    • Users
      • 📋User Roles
      • 📋Invite & Manage Users
    • Billing
      • 💳Billing Setup
      • 💳Subscriptions and Changes
      • 💳Automatic Site Upgrades
      • 💳Invoices
    • Tickets
    • Marketplace
    • Agencies
      • 👩‍💻Agency Account
      • 👩‍💻Clients
      • 👩‍💻Site Copies
      • 👩‍💻Agency Whitelabelling
  • Developer Tools
    • CLI
      • 🚀Quickstart: CLI
      • ℹ️About
      • 📋Site Setup
      • ❔Troubleshooting
      • 💻Reference
      • 🛳️CLI Changelog
      • 🧙‍♂️Go Further: CLI
        • Creating WebApps via CLI
    • Liquid
      • ℹ️About
      • 💻Reference
      • Accessing Data in Liquid Variables - Tutorial 1 - Using Dot Notation
      • Accessing Data in Liquid Variables - Tutorial 2 - Iterating over Arrays and Objects
      • Using Collections with WebApps and Modules
      • Accessing Data from the Global Context Variable
      • Truthiness - Using Liquid to determine if a field is empty or blank
      • 📋Alternatives to Storing and Executing Liquid from Database Items
    • GraphQL
      • ℹ️About GraphQL
      • 📋Tutorials
        • Tutorial 1 - Your First Query
        • Tutorial 2 - Pagination
        • Tutorial 3 - Filtering the Results
        • Tutorial 3 - (Answers)
        • Tutorial 4 - Advanced Filtering
        • Tutorial 4 - (Answers)
        • Tutorial 5 - Using Liquid to run GraphQL queries on your Site
        • Tutorial 6 - Variables
        • Tutorial 6 - (Answers)
        • Tutorial 7 - Sorting
        • Tutorial 8 - Building a Liquid API GET Endpoint Page powered by GraphQL queries
        • Tutorial 9 - Using Mutations to Create New Records
        • Tutorial 10 - Using Mutations to Edit a Record
        • Tutorial 11 - Using Mutations to Delete an Item
        • Tutorial 12 - Related Records and Datasources
    • Configuration
      • ℹ️Field Types
      • ℹ️Custom Field IDs
    • Zapier Integration
      • ℹ️Formatting arrays correctly
    • Developer Marketplace
      • ℹ️About Building Modules
      • ℹ️Module Setup
      • ℹ️Site Template Modules - and How to Make Your Own
      • ℹ️Create Folder Structure
      • ℹ️Updating Modules
      • ℹ️Submit Module for Approval
      • ℹ️Adding Payment to a Module
      • ℹ️Theme Module Example
      • ℹ️Data & UI Module Example
      • 💻Reference
      • 🌳File Structure
    • Release Notes
      • 🛳️Siteglide Admin/API - Changelog
      • 🛳️Module - System Files - Changelog
      • 🛳️Module - eCommerce - Changelog
      • 🛳️Module - Menu - Changelog
      • 🛳️Module - Slider - Changelog
      • 🛳️Module - Secure Zones - Changelog
      • 🛳️Module - FAQ - Changelog
      • 🛳️Module - Events - Changelog
      • 🛳️Module - Blog - Changelog
  • SiteBuilder
    • Build Sites Faster
      • 🚀Quickstart: SiteBuilder
      • About
      • Site Setup
        • 🏗️Marketplace Themes & Templates
        • 🏗️Create Site From Template
        • 🏗️Install SiteBuilder Module
        • 🏗️Create a Page Template
        • 🏗️Set Up Tailwind CSS with the recommended CLI method
      • Styling
        • 🏗️Editing Tailwind CSS using the recommended CLI method
        • 🏗️Tailwind CSS Themes - Choosing a Build Method
        • 🏗️Tailwind CSS - Preview Mode
        • 🏗️Tailwind's JIT Compiler Via CDN (deprecated)
        • 🏗️Theme Presets
        • 🏗️Example Tailwind Project Setup
      • Layouts
        • 🏗️Insert Static Layouts
        • 🏗️Installing Dynamic Layouts
        • 🏗️Editing Dynamic Layouts
        • About Layouts
          • 🏗️Dynamic Layouts
          • 🏗️Static and Dynamic Form Layouts
          • 🏗️Sliders
      • 💻Reference
    • Advanced Features
      • 🧞SiteBuilder Live Updates API
        • 👀Live Updates Reference
        • 🔹Live Updates Markup Example
        • 📋Steps to Setting Up Live Updates API in a Module/WebApp Layout
        • 🔹Live Updates Example - Enforcing Filters
        • 📋Steps to Use Live Updates Methods
        • 📋Steps to Initialise Live Updates with JS
        • 🗓️Live Updates Changelog
      • ℹ️SiteBuilder JavaScript
        • ℹ️Forms JS
        • ℹ️Social Sharing JS
        • ℹ️Sliders JS
        • ℹ️Dark Mode JS
        • ℹ️Cookie Settings JS
      • ℹ️SiteBuilder Liquid Includes
        • ℹ️Pagination
      • ℹ️SiteBuilder Liquid Functions
        • ℹ️Detail Page Valid
        • ℹ️Field Mapping
        • ℹ️Get Table Config
        • ℹ️Case From Order ID
      • 🗓️SiteBuilder Changelog
    • Extend SiteBuilder
      • ℹ️Create SiteBuilder Themes
      • ℹ️Create Marketplace Modules
      • ℹ️Adding Dynamic Layouts to Themes & Modules
      • ℹ️Adding Static Layouts to your Theme
      • 💻Reference
  • CMS
    • Dashboard
    • Pages
      • 🚀Quickstart: Pages
      • 🎨Studio Alpha Release
      • ℹ️Studio
      • ℹ️Code View & Toolbox
      • ℹ️About Pages
        • ℹ️Page Settings
        • ℹ️Custom Fields in Pages
        • ℹ️Pages with Siteglide CLI
      • ℹ️About Page Templates
        • ℹ️Page Templates with Siteglide CLI
        • Preventing Duplicate Content
      • ℹ️System Pages
      • 💻Reference
      • 🌳File Structure
    • Content Sections
    • File Manager
      • 🔹About Assets
      • 🔹Linking to Assets Explained
      • 🔧Assets Troubleshooting
      • 🔹Siteglide Scripts Explained
      • 💻Assets with CLI
      • 🔼Migrating Assets
      • 📋Steps to Optimise Images on the Fly with Cloudinary
      • 🔹siteglide_head_scripts and siteglide_footer_scripts Explained
      • 🌳Assets File Structure
      • 👀Tags for Assets
    • Forms
      • Quickstart: Forms
      • ℹ️About Forms
      • 📋Guides: Forms
        • 📋Steps to Using Separate Fields for First Name and Surname in a Form
        • 📋Steps to Programmatically Redirecting after a Form Submission
        • 📋Steps to Adding Form Confirmation Pages
        • 📋Steps to Adding a Progress Bar
        • 📋Steps to Changing Form Styling on Submission Using CSS
        • 📋Steps to Using Custom Field Set fields in a Form's Custom Layout
      • 🧙‍♂️Go Further: Forms
        • ℹ️Migrating Forms
        • ℹ️Explained - Preventing Spam Form Submissions and Captchas
        • ℹ️Explained - Show Clearly When a User is Already Logged in When Submitting a Form
        • ℹ️Forms Error Callback and Validation
        • ℹ️Forms Success Callback
        • ℹ️File Upload Previews
      • 🌳Forms File Structure
      • 💻Reference
      • ❔Troubleshooting
    • Automations
      • 🚀Quickstart: Automations
      • ℹ️About
        • ℹ️Email Templates
        • ℹ️Email Automations and Email Templates with Siteglide CLI
      • 📋Guides
        • ℹ️Integration Automations
        • ℹ️A Transactional Email Example
        • ℹ️An API Call Action Example
        • ℹ️A Custom Liquid Action Example
        • 📋Steps to Testing Emails on a Staging Site
        • 📋Steps to Authenticating Sendgrid Emails on Live Sites
      • 🧙‍♂️Go Further
      • 💻Reference
      • 🌳File Structure
    • Categories
      • 🚀Quickstart: Categories
      • ℹ️About
        • ℹ️Outputting Categories on WebApp / Module / eCommerce Layouts
        • ℹ️Filtering WebApps and Modules by Categories Using Liquid Parameters
      • 🌳File Structure
      • 💻Reference
    • Company Information
      • ℹ️About
      • 💻Reference
      • ❔Troubleshooting
    • URL Redirects
  • Modules
    • Core Modules
      • MenuBuilder
        • 🚀Quickstart: Menu Builder
        • ℹ️About
      • Secure Zones
        • 🚀Quickstart: Secure Zones
        • ℹ️About
          • 📋Dynamically Assign a Secure Zone during Form Submission
        • 🧙‍♂️Go Further
          • ℹ️Secure Zones with Siteglide CLI
          • ℹ️Using the context.current_user object
      • Media Downloads
        • 🚀Quickstart: Media Downloads
        • ℹ️Layouts
        • 💻Reference
      • Blog & Authors
        • 🚀Quickstart: Blog & Authors
        • 🔹Blog Archive & Date Filtering
        • 🔹Blog Search
        • 🔹Blog Filter by Category
        • 🔹Blog Filter by Author
        • 🌳File Structure
        • 💻Reference
      • Events
        • 🚀Quickstart: Events
        • ℹ️Standard List View
        • ℹ️Getting Started with Event Filtering & Searching
        • ℹ️Filter by Category
        • ℹ️Filter By Host (Author)
        • ℹ️Filter by Event Dates
        • ℹ️Datasourcing the Event Host
        • ℹ️Search
        • ℹ️Map List View
        • ℹ️Calendar List View
      • FAQ
        • 🚀Quickstart: FAQ
        • 💻Reference
      • Testimonials
        • 🚀Quickstart: Testimonials
        • 💻Reference
      • Slider
        • 🚀Quickstart: Slider
        • 💻Reference: Slider
    • Community Modules
      • 🏗️SiteBuilder
      • 🚀CRM Sync
        • ℹ️About CRM Sync Module
        • 📋Steps to Set Up CRM Sync on an Automation
        • 🗓️CRM Sync Changelog
    • Go Further: Modules
      • ℹ️Front-end Submit Modules
  • WebApps
    • 🚀Quickstart: WebApps
    • WebApp Items
      • 📋Create WebApp Items
      • 📋Importing and Exporting
    • Layouts
      • ℹ️WebApp List Layout
      • ℹ️WebApp Detail Layouts
    • Go Further: WebApps
      • 📋Searching by Location
      • 📋Searching - Advanced Filtering
      • 📋Searching - By Keyword
      • 📋Front End Create Forms
      • 📋Front End Update Forms
      • 📋Front End Delete
  • WebApp Troubleshooting
  • eCommerce
    • 🚀Quickstart: eCommerce
    • Get Started
      • 💡About the eCommerce Module
      • Settings
      • 📂Cart, Checkout and Quotes
        • 💡About Cart, Checkout and Quotes
        • 📋Steps to Implement a Guest Checkout Flow
        • 📂Product Views
          • 🔹Product Layouts
          • 🔹Product List Layout
          • 🔹Product Detail Layout
          • 🔹Add to Cart Button
          • 📋Steps to Datasource and Display Related Products
          • 🔹Dynamic Product Layouts based on Categories
          • 📂Attribute Selection
            • 🔹Attribute Layout - Presenting the Choice to the Customer
            • 🔹Attributes - Changing Product Price after Change
          • 📂Discount Selection
            • Discount Codes Layout
            • Minimum Payments
          • 📂Shipping Selection
            • Shipping Options Layout
        • Managing Products
          • Creating and Editing
          • Securing Products
          • Location
          • Custom Fields
          • Edit Module Structure
          • Product Custom Field Sets
          • Inventory
          • Managing Attributes
          • Pricing
          • Product Categories
          • Open Graph Fields
          • SEO Fields
          • Standard Fields
          • Product Import and Export
          • Discounts
        • 📂Cart
          • 🔹Cart Layouts
          • Checking Inventory in Cart
          • Updating Quantity in Cart
          • Updating Displayed Cart Quantity
        • 📋How to Set Up a Shopping Cart and Guest Checkout - Tutorial
        • 📂Checkout Forms
          • 🔹Checkout Form Layouts
          • 🔹Checkout Forms with PayPal
        • 📂Orders
          • Order Confirmation
          • Re-Ordering
          • 🔹Orders Layouts
        • 📋Steps to Add Secure Zones and User Orders View to your Checkout Flow
        • Quotes
        • Selling Digital Products
        • 🔹Volume Pricing
        • 📋Steps - Alternatives to Product Grouping
      • 📂Basic Payment Forms
        • 💡About Basic Payment Forms
        • 📋Steps to Set up a Basic Payment Form (with a Fixed Payment Amount)
        • 📋Authorize.net Basic Payment Forms
        • 📋PayPal Basic Payment Forms
        • 📋Steps to Allow User to Decide Amount they Will Pay
        • 📋Step-by-step Basic Payment Confirmations
        • 👀Basic Payment Forms Reference
        • ℹ️ecommerce/basic_payment
      • 📂Payment Gateways
        • 💻Building a Custom Payment Gateway
          • 📋Steps to Support Basic Payment Forms with your Custom Payment Gateway
          • 📋Steps to Support Checkout with your Custom Payment Gateway
        • 🔹Paypal Custom Parameters
        • 🔹Styling Stripe Card Elements
        • 💡About Payment Gateways
        • 📋Steps to Switching Payment Gateway
        • 🔹Test Cards
      • 📂Currency and Tax
        • 💡About Tax Codes
        • Currency Changer
        • Tax Code Changer
        • Formatting Currency
      • 📂Subscriptions
        • 💡About Subscriptions
        • Managing Subscriptions
          • Creating Subscription Products
          • Changing Price and Billing Interval
          • Creating a Form for Signing Up and Changing Payment Details
          • Subscription Order Status Explained
          • Terms and Conditions (Good Practice)
        • 📋Subscriptions Payment Gateway Setup
        • Subscriptions List Layout
        • Subscriptions Detail Layout
        • User's Active Subscriptions
        • Subscription Action Required
        • Cancelling Subscriptions
      • 🌳Basic Payment Forms Folder Structure
      • 🌳Cart and Checkout Folder Structure
  • CRM
    • 🚀Quickstart: CRM
    • Users
      • User Details
      • User Secure Zones
      • How Users Edit their Email and Password Front End
      • Custom Field Sets & CRM Custom Fields
      • Storing User's Favourite WebApp / Module Items
    • Companies
    • Cases
      • User's Form Submissions (Cases)
  • Site Manager
    • Code Editor
    • Templates (Pages & Email)
    • Headers & Footers
    • Code Snippets (Includes)
      • 🔧Includes Troubleshooting
      • 👀constants_json
      • 👀constants
      • 🌳Includes File Structure
      • 💻Includes with Siteglide CLI
      • 🔧Tags for Includes
    • System Pages
      • Automatic Site Maps
    • System Emails
    • Data Management
    • Admin Menu Editor
    • Integrations
  • Reporting
    • 🚀Quickstart: Reports
  • Miscellaneous
    • System Features
      • Pagination on Liquid Tags
      • Custom Pagination Layouts
      • Timezones in the Siteglide Admin and on the front-end of your Site
      • Module/WebApp Caching
      • Getting Started with Liquid Caching - to Reduce Server Response time and Improve Performance
      • Translating Dates
      • Site Search
      • About Site Search
      • AI Tools for the Rich Text Editor
      • Cookies on Siteglide Sites
    • Front-End Performance
      • Video Embeds
      • Forms Above the Fold
Powered by GitBook
On this page
  • Prerequisites
  • Introduction
  • Filtering by Properties
  • Filtering Data Types Other than Strings
  • Filtering by Booleans
  • Filtering by Integers and Epoch Timestamp Dates
  • Filtering by Arrays
  • Filtering by Multiple Fields
  • Filtering by whether a Property Exists - or doesn't exist!
  • *New* Filtering with OR logic
  • Challenge!
  • Next Time

Was this helpful?

Export as PDF
  1. Developer Tools
  2. GraphQL
  3. Tutorials

Tutorial 4 - Advanced Filtering

PreviousTutorial 3 - (Answers)NextTutorial 4 - (Answers)

Last updated 4 months ago

Was this helpful?

Following on from the previous tutorial, we'll look at more advanced filtering options and show how you can filter with multiple rules.

Prerequisites

  • You have completed the Learning GraphQL tutorials 1 - 3

  • - optional- Read more about GraphQL and when it might be best used.

Introduction

In the last tutorial, we looked at how to filter your results so that only items from webapp_1 were returned. We also challenged you to see if you could adjust the query so that it returned all WebApp items.

This time, we'll look at:

  • filtering by different fields, or properties

  • filtering with different kinds of rules

  • using more than one filter at once

Filtering by Properties

Some fields in recordsare defined in the GraphQL schema, like table, this often means they have their own filter option in the documentation. Siteglide fields, and your own custom fields, are very likely to be custom "properties" which are not directly defined by the schema.

If you're not sure, check the schema for the field you're looking for. If you can't find it, it's a property.

For example, release_date is not a custom field in the Siteglide Admin, but it's not in the list of available fields to filter by in the schema- so we'll need to use properties.

A brief note on name . You'll see the term name available in the schema- but this is a deprecated way of referring to the tablee.g. webapp_1. To fetch the name of the item in the Siteglide Admin, you'll need properties.name.

In our next example query, we'll demonstrate this. Let's search for items with a properties.name that have the exact value of the string "music".

Code:

query get_items_with_musical_names {
  records(
    page: 1
    per_page: 20
    filter: {
      properties: {
        name: "name", value: "music"
      }
    }
  ) {
    total_pages
    results {
      table
      properties
    }
  }
}

Notes:

  • See that properties uses a colon : and then curly braces { } as we have usually used so far. Properties can instead be used to store an array of filter objects, but we'll look at this later.

  • Note that we have to specify inside the curly braces both the name of the property we want to filter by (which happens here to also be called name, but it could also have been something else like release_date) and the method we'll be matching the value by, in this case contains: music.

Explorer: Adding a single filter to properties can be done with the Explorer wizard. However, if you want to be able to filter by an array of different properties, Explorer has no support for this yet, but it is possible by writing in the query manually.

This section of the docs used to have an example which used the "contains" comparison rather than "value". Good practice is to use "value" where possible for the best speed and performance. If you need "contains" functionality, consider whether using fulltext: {keyword: $search_keywords} search will meet your requirements instead?

Filtering Data Types Other than Strings

In the examples so far, we've only filtered by strings- or in other words, groups of letters or characters. Next we'll look at some other data types:

  • Booleans

  • Integers / Epoch Date stamps

  • Arrays

Filtering by Booleans

A good example of a Boolean property in Siteglide is enabled. This is a property which is stored as either true or false . Let's find all the items which are currently enabled:

Code:

query get_enabled_items {
  records(
    page: 1
    per_page: 20
    filter: {
      properties: {
        name: "enabled", value_boolean: true
      }
    }
  ) {
    total_pages
    results {
      table
      properties
    }
  }
}

Notes:

  • Again, we need to specify the name of the property we'll be filtering by, this time: enabled.

  • We'll use value_boolean as the most appropriate way to match an exact Boolean value. It's not the only method we could choose from the documentation, but it's more specialised to filtering Booleans, so is potentially faster.

Explorer:

Filtering by Integers and Epoch Timestamp Dates

When filtering by integers (which also includes Siteglide's release_date and expiry_date fields, as these are stored as Epoch Timestamps) you've got a choice whether to filter by values or a range of values.

Filtering for properties which match an exact integer

Code:

query get_heavily_weighted_items {
  records(
    page: 1
    per_page: 20
    filter: {
      properties: {
        name: "weighting", value_int: 1
      }
    }
  ) {
    total_pages
    results {
      table
      properties
    }
  }
}

Notes:

  • value_int works the same as value_boolean but is designed to handle the different type of data more efficiently.

  • Be aware that running this query yourself on a Starter Site may produce no results. This is the correct result, because Starter Site does not at the time of writing ship with any weightings set. If you add a weighting of 1 in the Admin, you'll see it appear in the results.

Explorer:

Filtering for integer properties which fall inside a range

Most often, you'll want to use more complex comparisons for integers. We'll look at how to do this next- at the same time, we'll take a look at how Siteglide normally formats dates.

In this example, I'll use the time at the current time of writing: 1582108820. Let's query for all items which have already been released. In other words, the value stored in release_date should be less than, or equal to, the current timestamp. When you're thinking about dates, you can think of "less than" as meaning "before" and "greater than" as meaning "after". So here we're asking for "items with a release_date before now".

Code:

query items_already_released {
  records(
    page: 1
    per_page: 20
    filter: {
      properties: {
        name: "release_date", range: {lte: "1582108820"}
      }
    }
  ) {
    total_pages
    results {
      table
      properties
    }
  }
}

Notes:

  • The range filter requires you create a new object { } containing some logical comparison operators. You can choose between the operators in the documentation panel- see below.

Documentation Panel:

  • Available operators can be seen under RangeFilter. They are short for Greater Than , Greater Than or Equal , Less Than and Less Than or Equal.

Explorer:

Filtering by Arrays

An array is a list of data. One good example in Siteglide is category_array, which stores a list of unique IDs that refer to categories. We can now write a query to find items in a particular category.

Code:

query mens_clothing {
  records(
    page: 1
    per_page: 2000
    filter: {
      properties: {
        name: "category_array", value_in: ["158198"]
      }
    }
  ) {
    total_pages
    results {
      table
      properties
    }
  }
}

Notes:

  • value_in is special to fields which have an array data type.

  • It takes an array of strings ["string_1", "string_2"] as its value. Here we are just using one category ID as an example. You could experiment with combinations of category_ids.

Explorer: Only partial support is currently available in Explorer for this. It's not so good at handling arrays. So you can select the property in Explorer, but you'll need to add the value manually into your query.

So firstly, implement with the wizard:

Secondly, change the value manually in the code from:

value_in: "158198"...to: value_in: ["158198"]

Filtering by Multiple Fields

For all the filters you've learned in this Article and the previous Article, you can apply more than one at once.

query released_mens_clothing_products {
  records(
    page: 1
    per_page: 2000
    filter: { 
      table: {value: "module_14/product"}
      properties: [
        { name: "category_array", value_in: ["158198"] },
        { name: "release_date", range: {lte: "1582108820"} }
      ]
    }
  ) {
    total_pages
    results {
      table
      properties
    }
  }
}

Notes:

  • In this example, tableand properties are both chosen as filter options.

  • properties takes an array (denoted by square brackets [ ] ) of objects (denoted by curly braces { }

  • Each pair of curly braces { } inside properties should contain the name of the property and an independent filtering method e.g. range or value which will be used.

  • Using a combination of filters in this way generally follows AND logic. Items must pass all of the filtering tests you choose before they are returned.

Explorer: Unfortunately, arrays are not currently supported in Explorer, so you'll have to enter this section of the query manually for now.

Filtering by whether a Property Exists - or doesn't exist!

You can also find items where a property does, or doesn't exist.

In this example, we're looking for WebApps where a meta_title was not added.

Code:

query webapps_missing_meta_descriptions {
  records(
    page: 1
    per_page: 2000
    filter: { 
      table: {starts_with: "webapp"}
      properties: [
        {
          name: "meta_title", exists: false
        }
      ]
    }
  ) {
    total_pages
    results {
      table
      properties
    }
  }
}

Notes:

  • exists accepts a Boolean, so you can use false or true. This shouldn't be wrapped in quotes, because Booleans don't require them.

Explorer:

*New* Filtering with OR logic

What if you are looking to filter records so you can find records which fit either one rule or another- but don't need to match both rules?

Here's an example from the pOS team of how you can use the "or" option when filtering. In this example we get records where either a webapp_field_1_1 exists OR a field parent exists.

query {
  records(
    per_page: 2000,
    filter: {
      or: [
        { 
          properties: [
            { name: "webapp_field_1_1", exists: true } 
          ]
        },
        {
          properties: [
            {name: "parent", exists: true}
          ]
        } 
      ] 
    }
  ) { 
    results {
      id
      table
      properties
    }
  }
}

Notes:

  • Inside filter we add an or property and an array with square brackets []

  • This array takes one or more objects with curly braces {} each Object is compared with OR logic. Within the object, you can use the same properties you might normally use inside filter.

You can add multiple filter properties inside each object, but these will be compared with AND logic. So, to filter records by those which have both ( webapp_field_1_1 AND webapp_field_1_2) OR "parent", you would do the following:

query { 
  records(per_page: 2000, filter: { 
    or: [ 
      {  
        properties: [ 
          { name: "webapp_field_1_1", exists: true },
          { name: "webapp_field_1_2", exists: true }  
      	] 
      }, 
      { 
        properties: [ 
          {name: "parent", exists: true} 
        ] 
      } 
    ] 
  }) { 
    results { 
      id 
      table
      properties 
    } 
  } 
} 

Challenge!

See if you can write one query which uses multiple filters. Try and return recordswhich meet these criteria:

  • They are an item from a recordwith a tablestarting with module_ .

  • They are enabled

  • They have already been released

  • They have not yet expired

  • They have a weighting between 1 and 3

  • They have a meta_title

  • They fall into the posters category

Hint: This search is so specific, that by default on Starter Site it will return no results. Try creating an eCommerce Product which meets these criteria before you start- that way, you'll know when you've succeeded.

It's unusual to run this many filters at once. Most of the time in a real use case, you'd have less to write than this! However, putting together everything you've done so far will be good practice.

We'll look at the answer to this Challenge in the next Article.

Next Time

We'll look at a possible solution to our latest challenge question.

After that, we'll look at how to run a query on a real Siteglide Site for the first time- and look at what you can do with the results.

The dates are stored in Epoch Timestamp format, which is an integer storing the number of seconds which have elapsed since the Epoch. You can convert a date of your choice to this format here:

📋
About GraphQL
https://www.epochconverter.com/