mirror of
https://github.com/strapi/strapi.git
synced 2025-12-26 06:35:47 +00:00
fix: review comments and added graphql operator
This commit is contained in:
parent
41fb55b899
commit
a7131ca000
@ -13,7 +13,7 @@ const OPERATORS = [
|
||||
'$in',
|
||||
'$notIn',
|
||||
'$eq',
|
||||
'$eqsi',
|
||||
'$eqi',
|
||||
'$ne',
|
||||
'$gt',
|
||||
'$gte',
|
||||
@ -223,7 +223,7 @@ const applyOperator = (qb, column, operator, value) => {
|
||||
break;
|
||||
}
|
||||
|
||||
case '$eqsi': {
|
||||
case '$eqi': {
|
||||
if (value === null) {
|
||||
qb.whereNull(column);
|
||||
break;
|
||||
|
||||
@ -168,14 +168,14 @@ describe('Filtering API', () => {
|
||||
});
|
||||
});
|
||||
describe('Filter equals with case insensitive', () => {
|
||||
test('Should be usable with eqsi suffix', async () => {
|
||||
test('Should be usable with eqi suffix', async () => {
|
||||
const res = await rq({
|
||||
method: 'GET',
|
||||
url: '/products',
|
||||
qs: {
|
||||
filters: {
|
||||
name: {
|
||||
$eqsi: 'PRODuct 1',
|
||||
$eqi: 'PRODuct 1',
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -192,7 +192,7 @@ describe('Filtering API', () => {
|
||||
qs: {
|
||||
filters: {
|
||||
name: {
|
||||
$eqsi: 'Product non existant',
|
||||
$eqi: 'Product non existant',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const EQI_FIELD_NAME = 'eqi';
|
||||
|
||||
module.exports = () => ({
|
||||
fieldName: EQI_FIELD_NAME,
|
||||
|
||||
strapiOperator: '$eqi',
|
||||
|
||||
add(t, type) {
|
||||
t.field(EQI_FIELD_NAME, { type });
|
||||
},
|
||||
});
|
||||
@ -8,6 +8,7 @@ const operators = {
|
||||
not: require('./not'),
|
||||
|
||||
eq: require('./eq'),
|
||||
eqi: require('./eqi'),
|
||||
ne: require('./ne'),
|
||||
|
||||
startsWith: require('./starts-with'),
|
||||
|
||||
@ -85,6 +85,7 @@ const allOperators = [
|
||||
'not',
|
||||
|
||||
'eq',
|
||||
'eqi',
|
||||
'ne',
|
||||
|
||||
'startsWith',
|
||||
|
||||
@ -292,6 +292,12 @@ describe('Test Graphql API End to End', () => {
|
||||
},
|
||||
[postsPayload[1]],
|
||||
],
|
||||
[
|
||||
{
|
||||
category: { eqi: 'Blog' },
|
||||
},
|
||||
[postsPayload[0]],
|
||||
],
|
||||
[
|
||||
{
|
||||
name: { contains: 'post' },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user