Filter for first letter / starts with in graphql?

Hello,

is in graphql a way to query for articles which start with a specific letter?

In sql I mean something like this:

SELECT *
FROM articles
WHERE title LIKE 'e%'

How can I do this with strapi in a graphql query?

Thanks for some help!

Best regards,

Timo

Hi @iparker, great question. Currently, you can’t do that natively in Strapi. I imagine the support for each and every possible database operation made available by DBMSs would create a rather bloated and impractical API. I would recommend, creating a custom controller that performs a custom query similar to what you need :slight_smile:. This probably would need more modification as your use case evolves. For reference take a look at these three articles on the Strapi docs:

  1. Customizing the GraphQL schema - GraphQL - Strapi Developer Documentation
  2. Writing Custom Queries - Backend customization - Strapi Developer Documentation
  3. Creating Controllers - Backend customization - Strapi Developer Documentation

Hi Richard,

thanks for your answer and your feedback.

This kind of customizations seems like much effort for this “simply and tiny” requirement.

I’m looking to find another solution, maybe handle this on client side.

Best regards,

Timo