Skip to content

Commit f108051

Browse files
committed
Introduce IdWhereInput
1 parent 94e0053 commit f108051

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/GraphQL/loaders/defaultGraphQLTypes.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,25 @@ const options = {
744744
type: GraphQLString,
745745
};
746746

747+
const ID_WHERE_INPUT = new GraphQLInputObjectType({
748+
name: 'IdWhereInput',
749+
description:
750+
'The IdWhereInput input type is used in operations that involve filtering objects by an id.',
751+
fields: {
752+
equalTo: equalTo(GraphQLID),
753+
notEqualTo: notEqualTo(GraphQLID),
754+
lessThan: lessThan(GraphQLID),
755+
lessThanOrEqualTo: lessThanOrEqualTo(GraphQLID),
756+
greaterThan: greaterThan(GraphQLID),
757+
greaterThanOrEqualTo: greaterThanOrEqualTo(GraphQLID),
758+
in: inOp(GraphQLID),
759+
notIn: notIn(GraphQLID),
760+
exists,
761+
inQueryKey,
762+
notInQueryKey,
763+
},
764+
});
765+
747766
const STRING_WHERE_INPUT = new GraphQLInputObjectType({
748767
name: 'StringWhereInput',
749768
description:
@@ -1065,6 +1084,7 @@ const load = parseGraphQLSchema => {
10651084
parseGraphQLSchema.addGraphQLType(CENTER_SPHERE_INPUT, true);
10661085
parseGraphQLSchema.addGraphQLType(GEO_WITHIN_INPUT, true);
10671086
parseGraphQLSchema.addGraphQLType(GEO_INTERSECTS_INPUT, true);
1087+
parseGraphQLSchema.addGraphQLType(ID_WHERE_INPUT, true);
10681088
parseGraphQLSchema.addGraphQLType(STRING_WHERE_INPUT, true);
10691089
parseGraphQLSchema.addGraphQLType(NUMBER_WHERE_INPUT, true);
10701090
parseGraphQLSchema.addGraphQLType(BOOLEAN_WHERE_INPUT, true);
@@ -1148,6 +1168,7 @@ export {
11481168
notInQueryKey,
11491169
matchesRegex,
11501170
options,
1171+
ID_WHERE_INPUT,
11511172
STRING_WHERE_INPUT,
11521173
NUMBER_WHERE_INPUT,
11531174
BOOLEAN_WHERE_INPUT,

src/GraphQL/loaders/parseClassTypes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ const load = (
298298
const type = transformConstraintTypeToGraphQL(
299299
parseClass.fields[parseField].type,
300300
parseClass.fields[parseField].targetClass,
301-
parseGraphQLSchema.parseClassTypes
301+
parseGraphQLSchema.parseClassTypes,
302+
field
302303
);
303304
if (type) {
304305
return {

src/GraphQL/transformers/constraintType.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import * as defaultGraphQLTypes from '../loaders/defaultGraphQLTypes';
33
const transformConstraintTypeToGraphQL = (
44
parseType,
55
targetClass,
6-
parseClassTypes
6+
parseClassTypes,
7+
fieldName
78
) => {
9+
if (fieldName === 'id' || fieldName === 'objectId') {
10+
return defaultGraphQLTypes.ID_WHERE_INPUT;
11+
}
12+
813
switch (parseType) {
914
case 'String':
1015
return defaultGraphQLTypes.STRING_WHERE_INPUT;

0 commit comments

Comments
 (0)