Azure / Azure/data-api-builder
[Enhancement]: Predicate operators in REST for GraphQL parity
- Lenguaje dominante
- C#
- Estrellas
- 1.5k
- Forks
- 370
- Merge medio
- 3 d 22 h
- PR fusionados (30 d)
- 9
Descripción
## 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.
Guía de contribución
Línea de trabajo
Comienza con src/Core/Models/GraphQLFilterParsers.cs en las líneas 655-701 para entender el comportamiento existente de los operadores y, después, sigue el recorrido hasta donde se analizan las expresiones REST $filter. Se considera terminado cuando los filtros REST respaldados por SQL admiten in, contains, not contains, startsWith y endsWith, incluidas las combinaciones mostradas; verifica los ejemplos documentados comparándolos con las respuestas REST.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp, graphql, sql
- Área
- api, backend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 58/100