Skip to content

Commit

Permalink
[core] GraphQL: Explicitly add all filters for all types for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
saasen committed Feb 27, 2020
1 parent 0ce072f commit c318fde
Show file tree
Hide file tree
Showing 8 changed files with 309 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function createBooleanFilters() {
return {
name: 'BooleanFilter',
kind: 'InputObject',
fields: [
{
fieldName: 'eq',
type: 'Boolean',
description: 'Checks if the value is equal to the given input.'
},
{
fieldName: 'neq',
type: 'Boolean',
description: 'Checks if the value is not equal to the given input.'
}
]
}
}

module.exports = createBooleanFilters
40 changes: 40 additions & 0 deletions packages/@sanity/core/src/actions/graphql/filters/dateFilters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function createDateFilters() {
return {
name: 'DateFilter',
kind: 'InputObject',
fields: [
{
fieldName: 'eq',
type: 'Date',
description: 'Checks if the value is equal to the given input.'
},
{
fieldName: 'neq',
type: 'Date',
description: 'Checks if the value is not equal to the given input.'
},
{
fieldName: 'gt',
type: 'Date',
description: 'Checks if the value is greater than the given input.'
},
{
fieldName: 'gte',
type: 'Date',
description: 'Checks if the value is greater than or equal to the given input.'
},
{
fieldName: 'lt',
type: 'Date',
description: 'Checks if the value is lesser than the given input.'
},
{
fieldName: 'lte',
type: 'Date',
description: 'Checks if the value is lesser than or equal to the given input.'
}
]
}
}

module.exports = createDateFilters
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function createDateTimeFilters() {
return {
name: 'DatetimeFilter',
kind: 'InputObject',
fields: [
{
fieldName: 'eq',
type: 'Datetime',
description: 'Checks if the value is equal to the given input.'
},
{
fieldName: 'neq',
type: 'Datetime',
description: 'Checks if the value is not equal to the given input.'
},
{
fieldName: 'gt',
type: 'Datetime',
description: 'Checks if the value is greater than the given input.'
},
{
fieldName: 'gte',
type: 'Datetime',
description: 'Checks if the value is greater than or equal to the given input.'
},
{
fieldName: 'lt',
type: 'Datetime',
description: 'Checks if the value is lesser than the given input.'
},
{
fieldName: 'lte',
type: 'Datetime',
description: 'Checks if the value is lesser than or equal to the given input.'
}
]
}
}

module.exports = createDateTimeFilters
40 changes: 40 additions & 0 deletions packages/@sanity/core/src/actions/graphql/filters/floatFilters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function createFloatFilters() {
return {
name: 'FloatFilter',
kind: 'InputObject',
fields: [
{
fieldName: 'eq',
type: 'Float',
description: 'Checks if the value is equal to the given input.'
},
{
fieldName: 'neq',
type: 'Float',
description: 'Checks if the value is not equal to the given input.'
},
{
fieldName: 'gt',
type: 'Float',
description: 'Checks if the value is greater than the given input.'
},
{
fieldName: 'gte',
type: 'Float',
description: 'Checks if the value is greater than or equal to the given input.'
},
{
fieldName: 'lt',
type: 'Float',
description: 'Checks if the value is lesser than the given input.'
},
{
fieldName: 'lte',
type: 'Float',
description: 'Checks if the value is lesser than or equal to the given input.'
}
]
}
}

module.exports = createFloatFilters
43 changes: 43 additions & 0 deletions packages/@sanity/core/src/actions/graphql/filters/idFilters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function createIdFilters() {
return {
name: 'IDFilter',
kind: 'InputObject',
fields: [
{
fieldName: 'eq',
type: 'ID',
description: 'Checks if the value is equal to the given input.'
},
{
fieldName: 'neq',
type: 'ID',
description: 'Checks if the value is not equal to the given input.'
},
{
fieldName: 'matches',
type: 'ID',
description: 'Checks if the value matches the given word/words.'
},
{
fieldName: 'in',
kind: 'List',
children: {
type: 'ID',
isNullable: false
},
description: 'Checks if the value is equal to one of the given values.'
},
{
fieldName: 'nin',
kind: 'List',
children: {
type: 'ID',
isNullable: false
},
description: 'Checks if the value is not equal to one of the given values.'
}
]
}
}

module.exports = createIdFilters
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function createIntegerFilters() {
return {
name: 'IntFilter',
kind: 'InputObject',
fields: [
{
fieldName: 'eq',
type: 'Int',
description: 'Checks if the value is equal to the given input.'
},
{
fieldName: 'neq',
type: 'Int',
description: 'Checks if the value is not equal to the given input.'
},
{
fieldName: 'gt',
type: 'Int',
description: 'Checks if the value is greater than the given input.'
},
{
fieldName: 'gte',
type: 'Int',
description: 'Checks if the value is greater than or equal to the given input.'
},
{
fieldName: 'lt',
type: 'Int',
description: 'Checks if the value is lesser than the given input.'
},
{
fieldName: 'lte',
type: 'Int',
description: 'Checks if the value is lesser than or equal to the given input.'
}
]
}
}

module.exports = createIntegerFilters
43 changes: 43 additions & 0 deletions packages/@sanity/core/src/actions/graphql/filters/stringFilters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function createStringFilters() {
return {
name: 'StringFilter',
kind: 'InputObject',
fields: [
{
fieldName: 'eq',
type: 'String',
description: 'Checks if the value is equal to the given input.'
},
{
fieldName: 'neq',
type: 'String',
description: 'Checks if the value is not equal to the given input.'
},
{
fieldName: 'matches',
type: 'String',
description: 'Checks if the value matches the given word/words.'
},
{
fieldName: 'in',
kind: 'List',
children: {
type: 'String',
isNullable: false
},
description: 'Checks if the value is equal to one of the given values.'
},
{
fieldName: 'nin',
kind: 'List',
children: {
type: 'String',
isNullable: false
},
description: 'Checks if the value is not equal to one of the given values.'
}
]
}
}

module.exports = createStringFilters
43 changes: 43 additions & 0 deletions packages/@sanity/core/src/actions/graphql/filters/urlFilters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function createUrlFilters() {
return {
name: 'UrlFilter',
kind: 'InputObject',
fields: [
{
fieldName: 'eq',
type: 'Url',
description: 'Checks if the value is equal to the given input.'
},
{
fieldName: 'neq',
type: 'Url',
description: 'Checks if the value is not equal to the given input.'
},
{
fieldName: 'matches',
type: 'Url',
description: 'Checks if the value matches the given word/words.'
},
{
fieldName: 'in',
kind: 'List',
children: {
type: 'Url',
isNullable: false
},
description: 'Checks if the value is equal to one of the given values.'
},
{
fieldName: 'nin',
kind: 'List',
children: {
type: 'Url',
isNullable: false
},
description: 'Checks if the value is not equal to one of the given values.'
}
]
}
}

module.exports = createUrlFilters

0 comments on commit c318fde

Please sign in to comment.