Skip to content

Commit 78e2d2e

Browse files
committed
Renaming GraphQL Types/Inputs
1 parent ef14ca5 commit 78e2d2e

11 files changed

+597
-571
lines changed

spec/ParseGraphQLServer.spec.js

Lines changed: 271 additions & 305 deletions
Large diffs are not rendered by default.

src/GraphQL/loaders/defaultGraphQLTypes.js

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,10 @@ const _options = {
759759
type: GraphQLString,
760760
};
761761

762-
const STRING_CONSTRAINT = new GraphQLInputObjectType({
763-
name: 'StringConstraint',
762+
const STRING_WHERE_INPUT = new GraphQLInputObjectType({
763+
name: 'StringWhereInput',
764764
description:
765-
'The StringConstraint input type is used in operations that involve filtering objects by a field of type String.',
765+
'The StringWhereInput input type is used in operations that involve filtering objects by a field of type String.',
766766
fields: {
767767
_eq: _eq(GraphQLString),
768768
_ne: _ne(GraphQLString),
@@ -785,10 +785,10 @@ const STRING_CONSTRAINT = new GraphQLInputObjectType({
785785
},
786786
});
787787

788-
const NUMBER_CONSTRAINT = new GraphQLInputObjectType({
789-
name: 'NumberConstraint',
788+
const NUMBER_WHERE_INPUT = new GraphQLInputObjectType({
789+
name: 'NumberWhereInput',
790790
description:
791-
'The NumberConstraint input type is used in operations that involve filtering objects by a field of type Number.',
791+
'The NumberWhereInput input type is used in operations that involve filtering objects by a field of type Number.',
792792
fields: {
793793
_eq: _eq(GraphQLFloat),
794794
_ne: _ne(GraphQLFloat),
@@ -804,10 +804,10 @@ const NUMBER_CONSTRAINT = new GraphQLInputObjectType({
804804
},
805805
});
806806

807-
const BOOLEAN_CONSTRAINT = new GraphQLInputObjectType({
808-
name: 'BooleanConstraint',
807+
const BOOLEAN_WHERE_INPUT = new GraphQLInputObjectType({
808+
name: 'BooleanWhereInput',
809809
description:
810-
'The BooleanConstraint input type is used in operations that involve filtering objects by a field of type Boolean.',
810+
'The BooleanWhereInput input type is used in operations that involve filtering objects by a field of type Boolean.',
811811
fields: {
812812
_eq: _eq(GraphQLBoolean),
813813
_ne: _ne(GraphQLBoolean),
@@ -817,10 +817,10 @@ const BOOLEAN_CONSTRAINT = new GraphQLInputObjectType({
817817
},
818818
});
819819

820-
const ARRAY_CONSTRAINT = new GraphQLInputObjectType({
821-
name: 'ArrayConstraint',
820+
const ARRAY_WHERE_INPUT = new GraphQLInputObjectType({
821+
name: 'ArrayWhereInput',
822822
description:
823-
'The ArrayConstraint input type is used in operations that involve filtering objects by a field of type Array.',
823+
'The ArrayWhereInput input type is used in operations that involve filtering objects by a field of type Array.',
824824
fields: {
825825
_eq: _eq(ANY),
826826
_ne: _ne(ANY),
@@ -861,10 +861,10 @@ const KEY_VALUE = new GraphQLInputObjectType({
861861
},
862862
});
863863

864-
const OBJECT_CONSTRAINT = new GraphQLInputObjectType({
865-
name: 'ObjectConstraint',
864+
const OBJECT_WHERE_INPUT = new GraphQLInputObjectType({
865+
name: 'ObjectWhereInput',
866866
description:
867-
'The ObjectConstraint input type is used in operations that involve filtering result by a field of type Object.',
867+
'The ObjectWhereInput input type is used in operations that involve filtering result by a field of type Object.',
868868
fields: {
869869
_eq: _eq(KEY_VALUE),
870870
_ne: _ne(KEY_VALUE),
@@ -880,10 +880,10 @@ const OBJECT_CONSTRAINT = new GraphQLInputObjectType({
880880
},
881881
});
882882

883-
const DATE_CONSTRAINT = new GraphQLInputObjectType({
884-
name: 'DateConstraint',
883+
const DATE_WHERE_INPUT = new GraphQLInputObjectType({
884+
name: 'DateWhereInput',
885885
description:
886-
'The DateConstraint input type is used in operations that involve filtering objects by a field of type Date.',
886+
'The DateWhereInput input type is used in operations that involve filtering objects by a field of type Date.',
887887
fields: {
888888
_eq: _eq(DATE),
889889
_ne: _ne(DATE),
@@ -899,10 +899,10 @@ const DATE_CONSTRAINT = new GraphQLInputObjectType({
899899
},
900900
});
901901

902-
const BYTES_CONSTRAINT = new GraphQLInputObjectType({
903-
name: 'BytesConstraint',
902+
const BYTES_WHERE_INPUT = new GraphQLInputObjectType({
903+
name: 'BytesWhereInput',
904904
description:
905-
'The BytesConstraint input type is used in operations that involve filtering objects by a field of type Bytes.',
905+
'The BytesWhereInput input type is used in operations that involve filtering objects by a field of type Bytes.',
906906
fields: {
907907
_eq: _eq(BYTES),
908908
_ne: _ne(BYTES),
@@ -918,10 +918,10 @@ const BYTES_CONSTRAINT = new GraphQLInputObjectType({
918918
},
919919
});
920920

921-
const FILE_CONSTRAINT = new GraphQLInputObjectType({
922-
name: 'FileConstraint',
921+
const FILE_WHERE_INPUT = new GraphQLInputObjectType({
922+
name: 'FileWhereInput',
923923
description:
924-
'The FILE_CONSTRAINT input type is used in operations that involve filtering objects by a field of type File.',
924+
'The FileWhereInput input type is used in operations that involve filtering objects by a field of type File.',
925925
fields: {
926926
_eq: _eq(FILE),
927927
_ne: _ne(FILE),
@@ -939,10 +939,10 @@ const FILE_CONSTRAINT = new GraphQLInputObjectType({
939939
},
940940
});
941941

942-
const GEO_POINT_CONSTRAINT = new GraphQLInputObjectType({
943-
name: 'GeoPointConstraint',
942+
const GEO_POINT_WHERE_INPUT = new GraphQLInputObjectType({
943+
name: 'GeoPointWhereInput',
944944
description:
945-
'The GeoPointConstraint input type is used in operations that involve filtering objects by a field of type GeoPoint.',
945+
'The GeoPointWhereInput input type is used in operations that involve filtering objects by a field of type GeoPoint.',
946946
fields: {
947947
_exists,
948948
_nearSphere: {
@@ -983,10 +983,10 @@ const GEO_POINT_CONSTRAINT = new GraphQLInputObjectType({
983983
},
984984
});
985985

986-
const POLYGON_CONSTRAINT = new GraphQLInputObjectType({
987-
name: 'PolygonConstraint',
986+
const POLYGON_WHERE_INPUT = new GraphQLInputObjectType({
987+
name: 'PolygonWhereInput',
988988
description:
989-
'The PolygonConstraint input type is used in operations that involve filtering objects by a field of type Polygon.',
989+
'The PolygonWhereInput input type is used in operations that involve filtering objects by a field of type Polygon.',
990990
fields: {
991991
_exists,
992992
_geoIntersects: {
@@ -1044,16 +1044,16 @@ const load = parseGraphQLSchema => {
10441044
parseGraphQLSchema.graphQLTypes.push(CENTER_SPHERE_OPERATOR);
10451045
parseGraphQLSchema.graphQLTypes.push(GEO_WITHIN_OPERATOR);
10461046
parseGraphQLSchema.graphQLTypes.push(GEO_INTERSECTS);
1047-
parseGraphQLSchema.graphQLTypes.push(STRING_CONSTRAINT);
1048-
parseGraphQLSchema.graphQLTypes.push(NUMBER_CONSTRAINT);
1049-
parseGraphQLSchema.graphQLTypes.push(BOOLEAN_CONSTRAINT);
1050-
parseGraphQLSchema.graphQLTypes.push(ARRAY_CONSTRAINT);
1051-
parseGraphQLSchema.graphQLTypes.push(OBJECT_CONSTRAINT);
1052-
parseGraphQLSchema.graphQLTypes.push(DATE_CONSTRAINT);
1053-
parseGraphQLSchema.graphQLTypes.push(BYTES_CONSTRAINT);
1054-
parseGraphQLSchema.graphQLTypes.push(FILE_CONSTRAINT);
1055-
parseGraphQLSchema.graphQLTypes.push(GEO_POINT_CONSTRAINT);
1056-
parseGraphQLSchema.graphQLTypes.push(POLYGON_CONSTRAINT);
1047+
parseGraphQLSchema.graphQLTypes.push(STRING_WHERE_INPUT);
1048+
parseGraphQLSchema.graphQLTypes.push(NUMBER_WHERE_INPUT);
1049+
parseGraphQLSchema.graphQLTypes.push(BOOLEAN_WHERE_INPUT);
1050+
parseGraphQLSchema.graphQLTypes.push(ARRAY_WHERE_INPUT);
1051+
parseGraphQLSchema.graphQLTypes.push(OBJECT_WHERE_INPUT);
1052+
parseGraphQLSchema.graphQLTypes.push(DATE_WHERE_INPUT);
1053+
parseGraphQLSchema.graphQLTypes.push(BYTES_WHERE_INPUT);
1054+
parseGraphQLSchema.graphQLTypes.push(FILE_WHERE_INPUT);
1055+
parseGraphQLSchema.graphQLTypes.push(GEO_POINT_WHERE_INPUT);
1056+
parseGraphQLSchema.graphQLTypes.push(POLYGON_WHERE_INPUT);
10571057
parseGraphQLSchema.graphQLTypes.push(FIND_RESULT);
10581058
parseGraphQLSchema.graphQLTypes.push(SIGN_UP_RESULT);
10591059
};
@@ -1128,16 +1128,16 @@ export {
11281128
_dontSelect,
11291129
_regex,
11301130
_options,
1131-
STRING_CONSTRAINT,
1132-
NUMBER_CONSTRAINT,
1133-
BOOLEAN_CONSTRAINT,
1134-
ARRAY_CONSTRAINT,
1135-
OBJECT_CONSTRAINT,
1136-
DATE_CONSTRAINT,
1137-
BYTES_CONSTRAINT,
1138-
FILE_CONSTRAINT,
1139-
GEO_POINT_CONSTRAINT,
1140-
POLYGON_CONSTRAINT,
1131+
STRING_WHERE_INPUT,
1132+
NUMBER_WHERE_INPUT,
1133+
BOOLEAN_WHERE_INPUT,
1134+
ARRAY_WHERE_INPUT,
1135+
OBJECT_WHERE_INPUT,
1136+
DATE_WHERE_INPUT,
1137+
BYTES_WHERE_INPUT,
1138+
FILE_WHERE_INPUT,
1139+
GEO_POINT_WHERE_INPUT,
1140+
POLYGON_WHERE_INPUT,
11411141
FIND_RESULT,
11421142
SIGN_UP_RESULT,
11431143
load,

src/GraphQL/loaders/objectsMutations.js

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
11
import { GraphQLNonNull, GraphQLBoolean, GraphQLObjectType } from 'graphql';
22
import * as defaultGraphQLTypes from './defaultGraphQLTypes';
33
import rest from '../../rest';
4-
5-
const parseMap = {
6-
_op: '__op',
7-
};
8-
9-
const transformToParse = fields => {
10-
if (!fields || typeof fields !== 'object') {
11-
return;
12-
}
13-
Object.keys(fields).forEach(fieldName => {
14-
const fieldValue = fields[fieldName];
15-
if (parseMap[fieldName]) {
16-
delete fields[fieldName];
17-
fields[parseMap[fieldName]] = fieldValue;
18-
}
19-
if (typeof fieldValue === 'object') {
20-
transformToParse(fieldValue);
21-
}
22-
});
23-
};
4+
import { transformMutationInputToParse } from '../transformers/mutation';
5+
import { transformClassNameToParse } from '../transformers/className';
246

257
const createObject = async (className, fields, config, auth, info) => {
268
if (!fields) {
279
fields = {};
2810
}
2911

30-
transformToParse(fields);
12+
transformMutationInputToParse(fields);
3113

3214
return (await rest.create(config, auth, className, fields, info.clientSDK))
3315
.response;
@@ -45,7 +27,7 @@ const updateObject = async (
4527
fields = {};
4628
}
4729

48-
transformToParse(fields);
30+
transformMutationInputToParse(fields);
4931

5032
return (await rest.update(
5133
config,
@@ -68,13 +50,14 @@ const load = parseGraphQLSchema => {
6850
'The create mutation can be used to create a new object of a certain class.',
6951
args: {
7052
className: defaultGraphQLTypes.CLASS_NAME_ATT,
71-
fields: defaultGraphQLTypes.FIELDS_ATT,
53+
input: defaultGraphQLTypes.FIELDS_ATT,
7254
},
7355
type: new GraphQLNonNull(defaultGraphQLTypes.CREATE_RESULT),
7456
async resolve(_source, args, context) {
7557
try {
76-
const { className, fields } = args;
58+
const { className: graphQLClassName, input: fields } = args;
7759
const { config, auth, info } = context;
60+
const className = transformClassNameToParse(graphQLClassName);
7861

7962
return await createObject(className, fields, config, auth, info);
8063
} catch (e) {
@@ -89,13 +72,14 @@ const load = parseGraphQLSchema => {
8972
args: {
9073
className: defaultGraphQLTypes.CLASS_NAME_ATT,
9174
objectId: defaultGraphQLTypes.OBJECT_ID_ATT,
92-
fields: defaultGraphQLTypes.FIELDS_ATT,
75+
input: defaultGraphQLTypes.FIELDS_ATT,
9376
},
9477
type: new GraphQLNonNull(defaultGraphQLTypes.UPDATE_RESULT),
9578
async resolve(_source, args, context) {
9679
try {
97-
const { className, objectId, fields } = args;
80+
const { className: graphQLClassName, objectId, input: fields } = args;
9881
const { config, auth, info } = context;
82+
const className = transformClassNameToParse(graphQLClassName);
9983

10084
return await updateObject(
10185
className,
@@ -121,8 +105,9 @@ const load = parseGraphQLSchema => {
121105
type: new GraphQLNonNull(GraphQLBoolean),
122106
async resolve(_source, args, context) {
123107
try {
124-
const { className, objectId } = args;
108+
const { className: graphQLClassName, objectId } = args;
125109
const { config, auth, info } = context;
110+
const className = transformClassNameToParse(graphQLClassName);
126111

127112
return await deleteObject(className, objectId, config, auth, info);
128113
} catch (e) {

0 commit comments

Comments
 (0)