Azure / Azure/data-api-builder
[Enhancement]: Predicate operators in REST for GraphQL parity
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 370
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 8
Description
## Graphql currently supports:
- `in`: checks if a column's value exists in a specified set of values.
- `contains`: finds a fragment anywhere in a string
- `notContains`: excludes strings containing a fragment
- `startsWith`: matches the beginning of a string
- `endsWith`: matches the end of a string
https://github.com/Azure/data-api-builder/blob/main/src/Core/Models/GraphQLFilterParsers.cs#L655-L701
## What?
Bring REST in parity with GraphQL.
## Why?
REST is our most popular endpoint type.
## How?
Here are the SQL `WHERE` clause equivalents for each `$filter` expression:
### `$filter=Category in ('Books', 'Movies', 'Games')`
```sql
WHERE Category IN ('Books', 'Movies', 'Games')
```
### `$filter=contains(Name, 'son')`
```sql
WHERE Name LIKE '%son%'
```
### `$filter=not contains(Description,'beta')`
or
### `$filter=not(contains(Description, 'beta'))`
```sql
WHERE Description NOT LIKE '%beta%'
```
### `$filter=startsWith(Name, 'Al')`
```sql
WHERE Name LIKE 'Al%'
```
### `$filter=endsWith(Name, 'son')`
```sql
WHERE Name LIKE '%son'
```
### `$filter=contains(Name, 'son') and Category in ('Books', 'Movies')`
```sql
WHERE Name LIKE '%son%' AND Category IN ('Books', 'Movies')
```
## Support
GraphQL only supports these for SQL, we can start there with REST.
Contributor guide
Assessment
This issue has not been assessed yet.