GraphQL: Remove underline from operators (#6024)

* Change _or, _and, _nor to OR, AND, NOR

* Renaming where operators maps

* Fix tests

* Fix tests

* Remove CreateResult and UpdateResult types

* Remove KEYS_ATT and INCLUDE_ATT

* Full text search test

* Change the operation generator functions names

* Fix object constraints

* Improve constraint transformation
This commit is contained in:
Antonio Davi Macedo Coelho de Castro
2019-09-04 10:57:51 -07:00
committed by GitHub
parent 618fe37c5a
commit 34f1bf384d
4 changed files with 455 additions and 441 deletions

View File

@@ -604,44 +604,6 @@ describe('ParseGraphQLServer', () => {
]); ]);
}); });
it('should have CreateResult object type', async () => {
const createResultType = (await apolloClient.query({
query: gql`
query CreateResultType {
__type(name: "CreateResult") {
kind
fields {
name
}
}
}
`,
})).data['__type'];
expect(createResultType.kind).toEqual('OBJECT');
expect(
createResultType.fields.map(field => field.name).sort()
).toEqual(['createdAt', 'id']);
});
it('should have UpdateResult object type', async () => {
const updateResultType = (await apolloClient.query({
query: gql`
query UpdateResultType {
__type(name: "UpdateResult") {
kind
fields {
name
}
}
}
`,
})).data['__type'];
expect(updateResultType.kind).toEqual('OBJECT');
expect(updateResultType.fields.map(field => field.name)).toEqual([
'updatedAt',
]);
});
it('should have Class interface type', async () => { it('should have Class interface type', async () => {
const classType = (await apolloClient.query({ const classType = (await apolloClient.query({
query: gql` query: gql`
@@ -740,12 +702,10 @@ describe('ParseGraphQLServer', () => {
const expectedTypes = [ const expectedTypes = [
'ParseObject', 'ParseObject',
'CreateResult',
'Date', 'Date',
'FileInfo', 'FileInfo',
'FindResult', 'FindResult',
'ReadPreference', 'ReadPreference',
'UpdateResult',
'Upload', 'Upload',
]; ];
expect( expect(
@@ -1376,78 +1336,86 @@ describe('ParseGraphQLServer', () => {
})).data.superCar; })).data.superCar;
expect(getSuperCar.id).toBe(superCar.id); expect(getSuperCar.id).toBe(superCar.id);
}); });
it('should only allow the supplied constraint fields for a class', async () => { it('should only allow the supplied constraint fields for a class', async () => {
const schemaController = await parseServer.config.databaseController.loadSchema(); try {
const schemaController = await parseServer.config.databaseController.loadSchema();
await schemaController.addClassIfNotExists('SuperCar', { await schemaController.addClassIfNotExists('SuperCar', {
model: { type: 'String' }, model: { type: 'String' },
engine: { type: 'String' }, engine: { type: 'String' },
doors: { type: 'Number' }, doors: { type: 'Number' },
price: { type: 'String' }, price: { type: 'String' },
mileage: { type: 'Number' }, mileage: { type: 'Number' },
insuranceCertificate: { type: 'String' }, insuranceCertificate: { type: 'String' },
}); });
await new Parse.Object('SuperCar').save({ await new Parse.Object('SuperCar').save({
model: 'McLaren', model: 'McLaren',
engine: 'petrol', engine: 'petrol',
doors: 3, doors: 3,
price: '£7500', price: '£7500',
mileage: 0, mileage: 0,
insuranceCertificate: 'private-file.pdf', insuranceCertificate: 'private-file.pdf',
}); });
await parseGraphQLServer.setGraphQLConfig({ await parseGraphQLServer.setGraphQLConfig({
classConfigs: [ classConfigs: [
{ {
className: 'SuperCar', className: 'SuperCar',
type: { type: {
constraintFields: ['engine', 'doors', 'price'], constraintFields: ['engine', 'doors', 'price'],
},
}, },
}, ],
], });
});
await resetGraphQLCache(); await resetGraphQLCache();
await expectAsync( await expectAsync(
apolloClient.query({ apolloClient.query({
query: gql` query: gql`
query FindSuperCar { query FindSuperCar {
superCars( superCars(
where: { insuranceCertificate: { _eq: "private-file.pdf" } } where: {
) { insuranceCertificate: { equalTo: "private-file.pdf" }
count }
) {
count
}
} }
} `,
`, })
}) ).toBeRejected();
).toBeRejected();
await expectAsync( await expectAsync(
apolloClient.query({ apolloClient.query({
query: gql` query: gql`
query FindSuperCar { query FindSuperCar {
superCars(where: { mileage: { _eq: 0 } }) { superCars(where: { mileage: { equalTo: 0 } }) {
count count
}
} }
} `,
`, })
}) ).toBeRejected();
).toBeRejected();
await expectAsync( await expectAsync(
apolloClient.query({ apolloClient.query({
query: gql` query: gql`
query FindSuperCar { query FindSuperCar {
superCars(where: { engine: { _eq: "petrol" } }) { superCars(where: { engine: { equalTo: "petrol" } }) {
count count
}
} }
} `,
`, })
}) ).toBeResolved();
).toBeResolved(); } catch (e) {
handleError(e);
}
}); });
it('should only allow the supplied sort fields for a class', async () => { it('should only allow the supplied sort fields for a class', async () => {
const schemaController = await parseServer.config.databaseController.loadSchema(); const schemaController = await parseServer.config.databaseController.loadSchema();
@@ -3411,12 +3379,12 @@ describe('ParseGraphQLServer', () => {
variables: { variables: {
where: { where: {
someField: { someField: {
_in: ['someValue1', 'someValue2', 'someValue3'], in: ['someValue1', 'someValue2', 'someValue3'],
}, },
_or: [ OR: [
{ {
pointerToUser: { pointerToUser: {
_eq: { equalTo: {
__type: 'Pointer', __type: 'Pointer',
className: '_User', className: '_User',
objectId: user5.id, objectId: user5.id,
@@ -3425,7 +3393,7 @@ describe('ParseGraphQLServer', () => {
}, },
{ {
id: { id: {
_eq: object1.id, equalTo: object1.id,
}, },
}, },
], ],
@@ -3445,7 +3413,7 @@ describe('ParseGraphQLServer', () => {
).toEqual(['someValue1', 'someValue3']); ).toEqual(['someValue1', 'someValue3']);
}); });
it('should support _or operation', async () => { it('should support OR operation', async () => {
await prepareData(); await prepareData();
await parseGraphQLServer.parseGraphQLSchema.databaseController.schemaCache.clear(); await parseGraphQLServer.parseGraphQLSchema.databaseController.schemaCache.clear();
@@ -3455,9 +3423,9 @@ describe('ParseGraphQLServer', () => {
query { query {
graphQLClasses( graphQLClasses(
where: { where: {
_or: [ OR: [
{ someField: { _eq: "someValue1" } } { someField: { equalTo: "someValue1" } }
{ someField: { _eq: "someValue2" } } { someField: { equalTo: "someValue2" } }
] ]
} }
) { ) {
@@ -3481,6 +3449,53 @@ describe('ParseGraphQLServer', () => {
).toEqual(['someValue1', 'someValue2']); ).toEqual(['someValue1', 'someValue2']);
}); });
it('should support full text search', async () => {
try {
const obj = new Parse.Object('FullTextSearchTest');
obj.set('field1', 'Parse GraphQL Server');
obj.set('field2', 'It rocks!');
await obj.save();
await parseGraphQLServer.parseGraphQLSchema.databaseController.schemaCache.clear();
const result = await apolloClient.query({
query: gql`
query FullTextSearchTests(
$where: FullTextSearchTestWhereInput
) {
fullTextSearchTests(where: $where) {
results {
id
}
}
}
`,
context: {
headers: {
'X-Parse-Master-Key': 'test',
},
},
variables: {
where: {
field1: {
text: {
search: {
term: 'graphql',
},
},
},
},
},
});
expect(result.data.fullTextSearchTests.results[0].id).toEqual(
obj.id
);
} catch (e) {
handleError(e);
}
});
it('should support order, skip and limit arguments', async () => { it('should support order, skip and limit arguments', async () => {
const promises = []; const promises = [];
for (let i = 0; i < 100; i++) { for (let i = 0; i < 100; i++) {
@@ -3516,7 +3531,7 @@ describe('ParseGraphQLServer', () => {
variables: { variables: {
where: { where: {
someField: { someField: {
_regex: '^someValue', matchesRegex: '^someValue',
}, },
}, },
order: ['numberField_DESC', 'someField_ASC'], order: ['numberField_DESC', 'someField_ASC'],
@@ -3538,12 +3553,12 @@ describe('ParseGraphQLServer', () => {
const where = { const where = {
someField: { someField: {
_in: ['someValue1', 'someValue2', 'someValue3'], in: ['someValue1', 'someValue2', 'someValue3'],
}, },
_or: [ OR: [
{ {
pointerToUser: { pointerToUser: {
_eq: { equalTo: {
__type: 'Pointer', __type: 'Pointer',
className: '_User', className: '_User',
objectId: user5.id, objectId: user5.id,
@@ -3552,7 +3567,7 @@ describe('ParseGraphQLServer', () => {
}, },
{ {
id: { id: {
_eq: object1.id, equalTo: object1.id,
}, },
}, },
], ],
@@ -3594,12 +3609,12 @@ describe('ParseGraphQLServer', () => {
const where = { const where = {
someField: { someField: {
_in: ['someValue1', 'someValue2', 'someValue3'], in: ['someValue1', 'someValue2', 'someValue3'],
}, },
_or: [ OR: [
{ {
pointerToUser: { pointerToUser: {
_eq: { equalTo: {
__type: 'Pointer', __type: 'Pointer',
className: '_User', className: '_User',
objectId: user5.id, objectId: user5.id,
@@ -3608,7 +3623,7 @@ describe('ParseGraphQLServer', () => {
}, },
{ {
id: { id: {
_eq: object1.id, equalTo: object1.id,
}, },
}, },
], ],
@@ -3654,7 +3669,7 @@ describe('ParseGraphQLServer', () => {
query: gql` query: gql`
query FindSomeObjects($limit: Int) { query FindSomeObjects($limit: Int) {
find: someClasses( find: someClasses(
where: { id: { _exists: true } } where: { id: { exists: true } }
limit: $limit limit: $limit
) { ) {
results { results {
@@ -3695,7 +3710,7 @@ describe('ParseGraphQLServer', () => {
`, `,
variables: { variables: {
where: { where: {
id: { _eq: object3.id }, id: { equalTo: object3.id },
}, },
}, },
context: { context: {
@@ -3720,7 +3735,7 @@ describe('ParseGraphQLServer', () => {
`, `,
variables: { variables: {
where: { where: {
id: { _eq: object3.id }, id: { equalTo: object3.id },
}, },
}, },
context: { context: {
@@ -3743,7 +3758,7 @@ describe('ParseGraphQLServer', () => {
const where = { const where = {
id: { id: {
_eq: object3.id, equalTo: object3.id,
}, },
}; };
@@ -3991,7 +4006,7 @@ describe('ParseGraphQLServer', () => {
variables: { variables: {
where: { where: {
pointerToUser: { pointerToUser: {
_inQuery: { where: {}, className: '_User' }, inQuery: { where: {}, className: '_User' },
}, },
}, },
}, },
@@ -5326,7 +5341,9 @@ describe('ParseGraphQLServer', () => {
someClass(id: $id) { someClass(id: $id) {
someField someField
} }
someClasses(where: { someField: { _eq: $someFieldValue } }) { someClasses(
where: { someField: { equalTo: $someFieldValue } }
) {
results { results {
someField someField
} }
@@ -5397,7 +5414,9 @@ describe('ParseGraphQLServer', () => {
someClass(id: $id) { someClass(id: $id) {
someField someField
} }
someClasses(where: { someField: { _eq: $someFieldValue } }) { someClasses(
where: { someField: { equalTo: $someFieldValue } }
) {
results { results {
someField someField
} }
@@ -5468,7 +5487,9 @@ describe('ParseGraphQLServer', () => {
someClass(id: $id) { someClass(id: $id) {
someField someField
} }
someClasses(where: { someField: { _eq: $someFieldValue } }) { someClasses(
where: { someField: { equalTo: $someFieldValue } }
) {
results { results {
someField someField
} }
@@ -5552,8 +5573,8 @@ describe('ParseGraphQLServer', () => {
} }
someClasses( someClasses(
where: { where: {
someFieldTrue: { _eq: $someFieldValueTrue } someFieldTrue: { equalTo: $someFieldValueTrue }
someFieldFalse: { _eq: $someFieldValueFalse } someFieldFalse: { equalTo: $someFieldValueFalse }
} }
) { ) {
results { results {
@@ -5633,7 +5654,7 @@ describe('ParseGraphQLServer', () => {
someClass(id: $id) { someClass(id: $id) {
someField someField
} }
someClasses(where: { someField: { _exists: true } }) { someClasses(where: { someField: { exists: true } }) {
results { results {
id id
} }
@@ -6101,7 +6122,7 @@ describe('ParseGraphQLServer', () => {
variables: { variables: {
where: { where: {
name: { name: {
_eq: 'imACompany2', equalTo: 'imACompany2',
}, },
}, },
fields: { fields: {
@@ -6198,7 +6219,7 @@ describe('ParseGraphQLServer', () => {
variables: { variables: {
id: country.id, id: country.id,
where: { where: {
name: { _eq: 'imACompany1' }, name: { equalTo: 'imACompany1' },
}, },
}, },
}); });
@@ -6314,7 +6335,7 @@ describe('ParseGraphQLServer', () => {
} }
} }
findSomeClass1: someClasses( findSomeClass1: someClasses(
where: { someField: { _exists: true } } where: { someField: { exists: true } }
) { ) {
results { results {
someField { someField {
@@ -6324,7 +6345,7 @@ describe('ParseGraphQLServer', () => {
} }
} }
findSomeClass2: someClasses( findSomeClass2: someClasses(
where: { someField: { _exists: true } } where: { someField: { exists: true } }
) { ) {
results { results {
someField { someField {
@@ -6408,10 +6429,10 @@ describe('ParseGraphQLServer', () => {
const where = { const where = {
someField: { someField: {
_eq: { _key: 'foo.bar', _value: 'baz' }, equalTo: { key: 'foo.bar', value: 'baz' },
_ne: { _key: 'foo.bar', _value: 'bat' }, notEqualTo: { key: 'foo.bar', value: 'bat' },
_gt: { _key: 'number', _value: 9 }, greaterThan: { key: 'number', value: 9 },
_lt: { _key: 'number', _value: 11 }, lessThan: { key: 'number', value: 11 },
}, },
}; };
const queryResult = await apolloClient.query({ const queryResult = await apolloClient.query({
@@ -6507,27 +6528,27 @@ describe('ParseGraphQLServer', () => {
}); });
const where = { const where = {
_and: [ AND: [
{ {
someField: { someField: {
_gt: { _key: 'number', _value: 9 }, greaterThan: { key: 'number', value: 9 },
}, },
}, },
{ {
someField: { someField: {
_lt: { _key: 'number', _value: 11 }, lessThan: { key: 'number', value: 11 },
}, },
}, },
{ {
_or: [ OR: [
{ {
someField: { someField: {
_eq: { _key: 'lorem', _value: 'ipsum' }, equalTo: { key: 'lorem', value: 'ipsum' },
}, },
}, },
{ {
someField: { someField: {
_eq: { _key: 'foo.test', _value: 'bar' }, equalTo: { key: 'foo.test', value: 'bar' },
}, },
}, },
], ],
@@ -6627,7 +6648,7 @@ describe('ParseGraphQLServer', () => {
} }
} }
} }
someClasses(where: { someField: { _exists: true } }) { someClasses(where: { someField: { exists: true } }) {
results { results {
id id
someField { someField {
@@ -6845,7 +6866,9 @@ describe('ParseGraphQLServer', () => {
someClass(id: $id) { someClass(id: $id) {
someField someField
} }
someClasses(where: { someField: { _eq: $someFieldValue } }) { someClasses(
where: { someField: { equalTo: $someFieldValue } }
) {
results { results {
id id
someField someField
@@ -6927,7 +6950,7 @@ describe('ParseGraphQLServer', () => {
longitude longitude
} }
} }
someClasses(where: { someField: { _exists: true } }) { someClasses(where: { someField: { exists: true } }) {
results { results {
id id
someField { someField {
@@ -7012,7 +7035,7 @@ describe('ParseGraphQLServer', () => {
longitude longitude
} }
} }
someClasses(where: { somePolygonField: { _exists: true } }) { someClasses(where: { somePolygonField: { exists: true } }) {
results { results {
id id
somePolygonField { somePolygonField {
@@ -7133,7 +7156,7 @@ describe('ParseGraphQLServer', () => {
variables: { variables: {
where: { where: {
someField: { someField: {
_eq: updatedSomeFieldValue.base64, equalTo: updatedSomeFieldValue.base64,
}, },
}, },
}, },

View File

@@ -402,11 +402,6 @@ const CLASS_NAME_ATT = {
type: new GraphQLNonNull(GraphQLString), type: new GraphQLNonNull(GraphQLString),
}; };
const FIELDS_ATT = {
description: 'These are the fields of the object.',
type: OBJECT,
};
const OBJECT_ID_ATT = { const OBJECT_ID_ATT = {
description: 'This is the object id.', description: 'This is the object id.',
type: OBJECT_ID, type: OBJECT_ID,
@@ -437,24 +432,10 @@ const CREATE_RESULT_FIELDS = {
createdAt: CREATED_AT_ATT, createdAt: CREATED_AT_ATT,
}; };
const CREATE_RESULT = new GraphQLObjectType({
name: 'CreateResult',
description:
'The CreateResult object type is used in the create mutations to return the data of the recent created object.',
fields: CREATE_RESULT_FIELDS,
});
const UPDATE_RESULT_FIELDS = { const UPDATE_RESULT_FIELDS = {
updatedAt: UPDATED_AT_ATT, updatedAt: UPDATED_AT_ATT,
}; };
const UPDATE_RESULT = new GraphQLObjectType({
name: 'UpdateResult',
description:
'The UpdateResult object type is used in the update mutations to return the data of the recent updated object.',
fields: UPDATE_RESULT_FIELDS,
});
const PARSE_OBJECT_FIELDS = { const PARSE_OBJECT_FIELDS = {
...CREATE_RESULT_FIELDS, ...CREATE_RESULT_FIELDS,
...UPDATE_RESULT_FIELDS, ...UPDATE_RESULT_FIELDS,
@@ -473,16 +454,6 @@ const SESSION_TOKEN_ATT = {
type: new GraphQLNonNull(GraphQLString), type: new GraphQLNonNull(GraphQLString),
}; };
const KEYS_ATT = {
description: 'The keys of the objects that will be returned.',
type: GraphQLString,
};
const INCLUDE_ATT = {
description: 'The pointers of the objects that will be returned.',
type: GraphQLString,
};
const READ_PREFERENCE = new GraphQLEnumType({ const READ_PREFERENCE = new GraphQLEnumType({
name: 'ReadPreference', name: 'ReadPreference',
description: description:
@@ -537,7 +508,7 @@ const COUNT_ATT = {
const SUBQUERY_INPUT = new GraphQLInputObjectType({ const SUBQUERY_INPUT = new GraphQLInputObjectType({
name: 'SubqueryInput', name: 'SubqueryInput',
description: description:
'The SubqueryInput type is used to specific a different query to a different class.', 'The SubqueryInput type is used to specify a sub query to another class.',
fields: { fields: {
className: CLASS_NAME_ATT, className: CLASS_NAME_ATT,
where: Object.assign({}, WHERE_ATT, { where: Object.assign({}, WHERE_ATT, {
@@ -549,7 +520,7 @@ const SUBQUERY_INPUT = new GraphQLInputObjectType({
const SELECT_INPUT = new GraphQLInputObjectType({ const SELECT_INPUT = new GraphQLInputObjectType({
name: 'SelectInput', name: 'SelectInput',
description: description:
'The SelectInput type is used to specify a $select operation on a constraint.', 'The SelectInput type is used to specify an inQueryKey or a notInQueryKey operation on a constraint.',
fields: { fields: {
query: { query: {
description: 'This is the subquery to be executed.', description: 'This is the subquery to be executed.',
@@ -566,23 +537,23 @@ const SELECT_INPUT = new GraphQLInputObjectType({
const SEARCH_INPUT = new GraphQLInputObjectType({ const SEARCH_INPUT = new GraphQLInputObjectType({
name: 'SearchInput', name: 'SearchInput',
description: description:
'The SearchInput type is used to specifiy a $search operation on a full text search.', 'The SearchInput type is used to specifiy a search operation on a full text search.',
fields: { fields: {
_term: { term: {
description: 'This is the term to be searched.', description: 'This is the term to be searched.',
type: new GraphQLNonNull(GraphQLString), type: new GraphQLNonNull(GraphQLString),
}, },
_language: { language: {
description: description:
'This is the language to tetermine the list of stop words and the rules for tokenizer.', 'This is the language to tetermine the list of stop words and the rules for tokenizer.',
type: GraphQLString, type: GraphQLString,
}, },
_caseSensitive: { caseSensitive: {
description: description:
'This is the flag to enable or disable case sensitive search.', 'This is the flag to enable or disable case sensitive search.',
type: GraphQLBoolean, type: GraphQLBoolean,
}, },
_diacriticSensitive: { diacriticSensitive: {
description: description:
'This is the flag to enable or disable diacritic sensitive search.', 'This is the flag to enable or disable diacritic sensitive search.',
type: GraphQLBoolean, type: GraphQLBoolean,
@@ -593,9 +564,9 @@ const SEARCH_INPUT = new GraphQLInputObjectType({
const TEXT_INPUT = new GraphQLInputObjectType({ const TEXT_INPUT = new GraphQLInputObjectType({
name: 'TextInput', name: 'TextInput',
description: description:
'The TextInput type is used to specify a $text operation on a constraint.', 'The TextInput type is used to specify a text operation on a constraint.',
fields: { fields: {
_search: { search: {
description: 'This is the search to be executed.', description: 'This is the search to be executed.',
type: new GraphQLNonNull(SEARCH_INPUT), type: new GraphQLNonNull(SEARCH_INPUT),
}, },
@@ -605,7 +576,7 @@ const TEXT_INPUT = new GraphQLInputObjectType({
const BOX_INPUT = new GraphQLInputObjectType({ const BOX_INPUT = new GraphQLInputObjectType({
name: 'BoxInput', name: 'BoxInput',
description: description:
'The BoxInput type is used to specifiy a $box operation on a within geo query.', 'The BoxInput type is used to specifiy a box operation on a within geo query.',
fields: { fields: {
bottomLeft: { bottomLeft: {
description: 'This is the bottom left coordinates of the box.', description: 'This is the bottom left coordinates of the box.',
@@ -621,9 +592,9 @@ const BOX_INPUT = new GraphQLInputObjectType({
const WITHIN_INPUT = new GraphQLInputObjectType({ const WITHIN_INPUT = new GraphQLInputObjectType({
name: 'WithinInput', name: 'WithinInput',
description: description:
'The WithinInput type is used to specify a $within operation on a constraint.', 'The WithinInput type is used to specify a within operation on a constraint.',
fields: { fields: {
_box: { box: {
description: 'This is the box to be specified.', description: 'This is the box to be specified.',
type: new GraphQLNonNull(BOX_INPUT), type: new GraphQLNonNull(BOX_INPUT),
}, },
@@ -633,7 +604,7 @@ const WITHIN_INPUT = new GraphQLInputObjectType({
const CENTER_SPHERE_INPUT = new GraphQLInputObjectType({ const CENTER_SPHERE_INPUT = new GraphQLInputObjectType({
name: 'CenterSphereInput', name: 'CenterSphereInput',
description: description:
'The CenterSphereInput type is used to specifiy a $centerSphere operation on a geoWithin query.', 'The CenterSphereInput type is used to specifiy a centerSphere operation on a geoWithin query.',
fields: { fields: {
center: { center: {
description: 'This is the center of the sphere.', description: 'This is the center of the sphere.',
@@ -649,13 +620,13 @@ const CENTER_SPHERE_INPUT = new GraphQLInputObjectType({
const GEO_WITHIN_INPUT = new GraphQLInputObjectType({ const GEO_WITHIN_INPUT = new GraphQLInputObjectType({
name: 'GeoWithinInput', name: 'GeoWithinInput',
description: description:
'The GeoWithinInput type is used to specify a $geoWithin operation on a constraint.', 'The GeoWithinInput type is used to specify a geoWithin operation on a constraint.',
fields: { fields: {
_polygon: { polygon: {
description: 'This is the polygon to be specified.', description: 'This is the polygon to be specified.',
type: POLYGON_INPUT, type: POLYGON_INPUT,
}, },
_centerSphere: { centerSphere: {
description: 'This is the sphere to be specified.', description: 'This is the sphere to be specified.',
type: CENTER_SPHERE_INPUT, type: CENTER_SPHERE_INPUT,
}, },
@@ -665,90 +636,90 @@ const GEO_WITHIN_INPUT = new GraphQLInputObjectType({
const GEO_INTERSECTS_INPUT = new GraphQLInputObjectType({ const GEO_INTERSECTS_INPUT = new GraphQLInputObjectType({
name: 'GeoIntersectsInput', name: 'GeoIntersectsInput',
description: description:
'The GeoIntersectsInput type is used to specify a $geoIntersects operation on a constraint.', 'The GeoIntersectsInput type is used to specify a geoIntersects operation on a constraint.',
fields: { fields: {
_point: { point: {
description: 'This is the point to be specified.', description: 'This is the point to be specified.',
type: GEO_POINT_INPUT, type: GEO_POINT_INPUT,
}, },
}, },
}); });
const _eq = type => ({ const equalTo = type => ({
description: description:
'This is the $eq operator to specify a constraint to select the objects where the value of a field equals to a specified value.', 'This is the equalTo operator to specify a constraint to select the objects where the value of a field equals to a specified value.',
type, type,
}); });
const _ne = type => ({ const notEqualTo = type => ({
description: description:
'This is the $ne operator to specify a constraint to select the objects where the value of a field do not equal to a specified value.', 'This is the notEqualTo operator to specify a constraint to select the objects where the value of a field do not equal to a specified value.',
type, type,
}); });
const _lt = type => ({ const lessThan = type => ({
description: description:
'This is the $lt operator to specify a constraint to select the objects where the value of a field is less than a specified value.', 'This is the lessThan operator to specify a constraint to select the objects where the value of a field is less than a specified value.',
type, type,
}); });
const _lte = type => ({ const lessThanOrEqualTo = type => ({
description: description:
'This is the $lte operator to specify a constraint to select the objects where the value of a field is less than or equal to a specified value.', 'This is the lessThanOrEqualTo operator to specify a constraint to select the objects where the value of a field is less than or equal to a specified value.',
type, type,
}); });
const _gt = type => ({ const greaterThan = type => ({
description: description:
'This is the $gt operator to specify a constraint to select the objects where the value of a field is greater than a specified value.', 'This is the greaterThan operator to specify a constraint to select the objects where the value of a field is greater than a specified value.',
type, type,
}); });
const _gte = type => ({ const greaterThanOrEqualTo = type => ({
description: description:
'This is the $gte operator to specify a constraint to select the objects where the value of a field is greater than or equal to a specified value.', 'This is the greaterThanOrEqualTo operator to specify a constraint to select the objects where the value of a field is greater than or equal to a specified value.',
type, type,
}); });
const _in = type => ({ const inOp = type => ({
description: description:
'This is the $in operator to specify a constraint to select the objects where the value of a field equals any value in the specified array.', 'This is the in operator to specify a constraint to select the objects where the value of a field equals any value in the specified array.',
type: new GraphQLList(type), type: new GraphQLList(type),
}); });
const _nin = type => ({ const notIn = type => ({
description: description:
'This is the $nin operator to specify a constraint to select the objects where the value of a field do not equal any value in the specified array.', 'This is the notIn operator to specify a constraint to select the objects where the value of a field do not equal any value in the specified array.',
type: new GraphQLList(type), type: new GraphQLList(type),
}); });
const _exists = { const exists = {
description: description:
'This is the $exists operator to specify a constraint to select the objects where a field exists (or do not exist).', 'This is the exists operator to specify a constraint to select the objects where a field exists (or do not exist).',
type: GraphQLBoolean, type: GraphQLBoolean,
}; };
const _select = { const inQueryKey = {
description: description:
'This is the $select operator to specify a constraint to select the objects where a field equals to a key in the result of a different query.', 'This is the inQueryKey operator to specify a constraint to select the objects where a field equals to a key in the result of a different query.',
type: SELECT_INPUT, type: SELECT_INPUT,
}; };
const _dontSelect = { const notInQueryKey = {
description: description:
'This is the $dontSelect operator to specify a constraint to select the objects where a field do not equal to a key in the result of a different query.', 'This is the notInQueryKey operator to specify a constraint to select the objects where a field do not equal to a key in the result of a different query.',
type: SELECT_INPUT, type: SELECT_INPUT,
}; };
const _regex = { const matchesRegex = {
description: description:
'This is the $regex operator to specify a constraint to select the objects where the value of a field matches a specified regular expression.', 'This is the matchesRegex operator to specify a constraint to select the objects where the value of a field matches a specified regular expression.',
type: GraphQLString, type: GraphQLString,
}; };
const _options = { const options = {
description: description:
'This is the $options operator to specify optional flags (such as "i" and "m") to be added to a $regex operation in the same set of constraints.', 'This is the options operator to specify optional flags (such as "i" and "m") to be added to a matchesRegex operation in the same set of constraints.',
type: GraphQLString, type: GraphQLString,
}; };
@@ -757,20 +728,20 @@ const STRING_WHERE_INPUT = new GraphQLInputObjectType({
description: description:
'The StringWhereInput input type is used in operations that involve filtering objects by a field of type String.', 'The StringWhereInput input type is used in operations that involve filtering objects by a field of type String.',
fields: { fields: {
_eq: _eq(GraphQLString), equalTo: equalTo(GraphQLString),
_ne: _ne(GraphQLString), notEqualTo: notEqualTo(GraphQLString),
_lt: _lt(GraphQLString), lessThan: lessThan(GraphQLString),
_lte: _lte(GraphQLString), lessThanOrEqualTo: lessThanOrEqualTo(GraphQLString),
_gt: _gt(GraphQLString), greaterThan: greaterThan(GraphQLString),
_gte: _gte(GraphQLString), greaterThanOrEqualTo: greaterThanOrEqualTo(GraphQLString),
_in: _in(GraphQLString), in: inOp(GraphQLString),
_nin: _nin(GraphQLString), notIn: notIn(GraphQLString),
_exists, exists,
_select, inQueryKey,
_dontSelect, notInQueryKey,
_regex, matchesRegex,
_options, options,
_text: { text: {
description: description:
'This is the $text operator to specify a full text search constraint.', 'This is the $text operator to specify a full text search constraint.',
type: TEXT_INPUT, type: TEXT_INPUT,
@@ -783,17 +754,17 @@ const NUMBER_WHERE_INPUT = new GraphQLInputObjectType({
description: description:
'The NumberWhereInput input type is used in operations that involve filtering objects by a field of type Number.', 'The NumberWhereInput input type is used in operations that involve filtering objects by a field of type Number.',
fields: { fields: {
_eq: _eq(GraphQLFloat), equalTo: equalTo(GraphQLFloat),
_ne: _ne(GraphQLFloat), notEqualTo: notEqualTo(GraphQLFloat),
_lt: _lt(GraphQLFloat), lessThan: lessThan(GraphQLFloat),
_lte: _lte(GraphQLFloat), lessThanOrEqualTo: lessThanOrEqualTo(GraphQLFloat),
_gt: _gt(GraphQLFloat), greaterThan: greaterThan(GraphQLFloat),
_gte: _gte(GraphQLFloat), greaterThanOrEqualTo: greaterThanOrEqualTo(GraphQLFloat),
_in: _in(GraphQLFloat), in: inOp(GraphQLFloat),
_nin: _nin(GraphQLFloat), notIn: notIn(GraphQLFloat),
_exists, exists,
_select, inQueryKey,
_dontSelect, notInQueryKey,
}, },
}); });
@@ -802,11 +773,11 @@ const BOOLEAN_WHERE_INPUT = new GraphQLInputObjectType({
description: description:
'The BooleanWhereInput input type is used in operations that involve filtering objects by a field of type Boolean.', 'The BooleanWhereInput input type is used in operations that involve filtering objects by a field of type Boolean.',
fields: { fields: {
_eq: _eq(GraphQLBoolean), equalTo: equalTo(GraphQLBoolean),
_ne: _ne(GraphQLBoolean), notEqualTo: notEqualTo(GraphQLBoolean),
_exists, exists,
_select, inQueryKey,
_dontSelect, notInQueryKey,
}, },
}); });
@@ -815,25 +786,25 @@ const ARRAY_WHERE_INPUT = new GraphQLInputObjectType({
description: description:
'The ArrayWhereInput input type is used in operations that involve filtering objects by a field of type Array.', 'The ArrayWhereInput input type is used in operations that involve filtering objects by a field of type Array.',
fields: { fields: {
_eq: _eq(ANY), equalTo: equalTo(ANY),
_ne: _ne(ANY), notEqualTo: notEqualTo(ANY),
_lt: _lt(ANY), lessThan: lessThan(ANY),
_lte: _lte(ANY), lessThanOrEqualTo: lessThanOrEqualTo(ANY),
_gt: _gt(ANY), greaterThan: greaterThan(ANY),
_gte: _gte(ANY), greaterThanOrEqualTo: greaterThanOrEqualTo(ANY),
_in: _in(ANY), in: inOp(ANY),
_nin: _nin(ANY), notIn: notIn(ANY),
_exists, exists,
_select, inQueryKey,
_dontSelect, notInQueryKey,
_containedBy: { containedBy: {
description: description:
'This is the $containedBy operator to specify a constraint to select the objects where the values of an array field is contained by another specified array.', 'This is the containedBy operator to specify a constraint to select the objects where the values of an array field is contained by another specified array.',
type: new GraphQLList(ANY), type: new GraphQLList(ANY),
}, },
_all: { contains: {
description: description:
'This is the $all operator to specify a constraint to select the objects where the values of an array field contain all elements of another specified array.', 'This is the contains operator to specify a constraint to select the objects where the values of an array field contain all elements of another specified array.',
type: new GraphQLList(ANY), type: new GraphQLList(ANY),
}, },
}, },
@@ -843,11 +814,11 @@ const KEY_VALUE_INPUT = new GraphQLInputObjectType({
name: 'KeyValueInput', name: 'KeyValueInput',
description: 'An entry from an object, i.e., a pair of key and value.', description: 'An entry from an object, i.e., a pair of key and value.',
fields: { fields: {
_key: { key: {
description: 'The key used to retrieve the value of this entry.', description: 'The key used to retrieve the value of this entry.',
type: new GraphQLNonNull(GraphQLString), type: new GraphQLNonNull(GraphQLString),
}, },
_value: { value: {
description: 'The value of the entry. Could be any type of scalar data.', description: 'The value of the entry. Could be any type of scalar data.',
type: new GraphQLNonNull(ANY), type: new GraphQLNonNull(ANY),
}, },
@@ -859,17 +830,17 @@ const OBJECT_WHERE_INPUT = new GraphQLInputObjectType({
description: description:
'The ObjectWhereInput input type is used in operations that involve filtering result by a field of type Object.', 'The ObjectWhereInput input type is used in operations that involve filtering result by a field of type Object.',
fields: { fields: {
_eq: _eq(KEY_VALUE_INPUT), equalTo: equalTo(KEY_VALUE_INPUT),
_ne: _ne(KEY_VALUE_INPUT), notEqualTo: notEqualTo(KEY_VALUE_INPUT),
_in: _in(KEY_VALUE_INPUT), in: inOp(KEY_VALUE_INPUT),
_nin: _nin(KEY_VALUE_INPUT), notIn: notIn(KEY_VALUE_INPUT),
_lt: _lt(KEY_VALUE_INPUT), lessThan: lessThan(KEY_VALUE_INPUT),
_lte: _lte(KEY_VALUE_INPUT), lessThanOrEqualTo: lessThanOrEqualTo(KEY_VALUE_INPUT),
_gt: _gt(KEY_VALUE_INPUT), greaterThan: greaterThan(KEY_VALUE_INPUT),
_gte: _gte(KEY_VALUE_INPUT), greaterThanOrEqualTo: greaterThanOrEqualTo(KEY_VALUE_INPUT),
_exists, exists,
_select, inQueryKey,
_dontSelect, notInQueryKey,
}, },
}); });
@@ -878,17 +849,17 @@ const DATE_WHERE_INPUT = new GraphQLInputObjectType({
description: description:
'The DateWhereInput input type is used in operations that involve filtering objects by a field of type Date.', 'The DateWhereInput input type is used in operations that involve filtering objects by a field of type Date.',
fields: { fields: {
_eq: _eq(DATE), equalTo: equalTo(DATE),
_ne: _ne(DATE), notEqualTo: notEqualTo(DATE),
_lt: _lt(DATE), lessThan: lessThan(DATE),
_lte: _lte(DATE), lessThanOrEqualTo: lessThanOrEqualTo(DATE),
_gt: _gt(DATE), greaterThan: greaterThan(DATE),
_gte: _gte(DATE), greaterThanOrEqualTo: greaterThanOrEqualTo(DATE),
_in: _in(DATE), in: inOp(DATE),
_nin: _nin(DATE), notIn: notIn(DATE),
_exists, exists,
_select, inQueryKey,
_dontSelect, notInQueryKey,
}, },
}); });
@@ -897,17 +868,17 @@ const BYTES_WHERE_INPUT = new GraphQLInputObjectType({
description: description:
'The BytesWhereInput input type is used in operations that involve filtering objects by a field of type Bytes.', 'The BytesWhereInput input type is used in operations that involve filtering objects by a field of type Bytes.',
fields: { fields: {
_eq: _eq(BYTES), equalTo: equalTo(BYTES),
_ne: _ne(BYTES), notEqualTo: notEqualTo(BYTES),
_lt: _lt(BYTES), lessThan: lessThan(BYTES),
_lte: _lte(BYTES), lessThanOrEqualTo: lessThanOrEqualTo(BYTES),
_gt: _gt(BYTES), greaterThan: greaterThan(BYTES),
_gte: _gte(BYTES), greaterThanOrEqualTo: greaterThanOrEqualTo(BYTES),
_in: _in(BYTES), in: inOp(BYTES),
_nin: _nin(BYTES), notIn: notIn(BYTES),
_exists, exists,
_select, inQueryKey,
_dontSelect, notInQueryKey,
}, },
}); });
@@ -916,19 +887,19 @@ const FILE_WHERE_INPUT = new GraphQLInputObjectType({
description: description:
'The FileWhereInput input type is used in operations that involve filtering objects by a field of type File.', 'The FileWhereInput input type is used in operations that involve filtering objects by a field of type File.',
fields: { fields: {
_eq: _eq(FILE), equalTo: equalTo(FILE),
_ne: _ne(FILE), notEqualTo: notEqualTo(FILE),
_lt: _lt(FILE), lessThan: lessThan(FILE),
_lte: _lte(FILE), lessThanOrEqualTo: lessThanOrEqualTo(FILE),
_gt: _gt(FILE), greaterThan: greaterThan(FILE),
_gte: _gte(FILE), greaterThanOrEqualTo: greaterThanOrEqualTo(FILE),
_in: _in(FILE), in: inOp(FILE),
_nin: _nin(FILE), notIn: notIn(FILE),
_exists, exists,
_select, inQueryKey,
_dontSelect, notInQueryKey,
_regex, matchesRegex,
_options, options,
}, },
}); });
@@ -937,40 +908,40 @@ const GEO_POINT_WHERE_INPUT = new GraphQLInputObjectType({
description: description:
'The GeoPointWhereInput input type is used in operations that involve filtering objects by a field of type GeoPoint.', 'The GeoPointWhereInput input type is used in operations that involve filtering objects by a field of type GeoPoint.',
fields: { fields: {
_exists, exists,
_nearSphere: { nearSphere: {
description: description:
'This is the $nearSphere operator to specify a constraint to select the objects where the values of a geo point field is near to another geo point.', 'This is the nearSphere operator to specify a constraint to select the objects where the values of a geo point field is near to another geo point.',
type: GEO_POINT_INPUT, type: GEO_POINT_INPUT,
}, },
_maxDistance: { maxDistance: {
description: description:
'This is the $maxDistance operator to specify a constraint to select the objects where the values of a geo point field is at a max distance (in radians) from the geo point specified in the $nearSphere operator.', 'This is the maxDistance operator to specify a constraint to select the objects where the values of a geo point field is at a max distance (in radians) from the geo point specified in the $nearSphere operator.',
type: GraphQLFloat, type: GraphQLFloat,
}, },
_maxDistanceInRadians: { maxDistanceInRadians: {
description: description:
'This is the $maxDistanceInRadians operator to specify a constraint to select the objects where the values of a geo point field is at a max distance (in radians) from the geo point specified in the $nearSphere operator.', 'This is the maxDistanceInRadians operator to specify a constraint to select the objects where the values of a geo point field is at a max distance (in radians) from the geo point specified in the $nearSphere operator.',
type: GraphQLFloat, type: GraphQLFloat,
}, },
_maxDistanceInMiles: { maxDistanceInMiles: {
description: description:
'This is the $maxDistanceInMiles operator to specify a constraint to select the objects where the values of a geo point field is at a max distance (in miles) from the geo point specified in the $nearSphere operator.', 'This is the maxDistanceInMiles operator to specify a constraint to select the objects where the values of a geo point field is at a max distance (in miles) from the geo point specified in the $nearSphere operator.',
type: GraphQLFloat, type: GraphQLFloat,
}, },
_maxDistanceInKilometers: { maxDistanceInKilometers: {
description: description:
'This is the $maxDistanceInKilometers operator to specify a constraint to select the objects where the values of a geo point field is at a max distance (in kilometers) from the geo point specified in the $nearSphere operator.', 'This is the maxDistanceInKilometers operator to specify a constraint to select the objects where the values of a geo point field is at a max distance (in kilometers) from the geo point specified in the $nearSphere operator.',
type: GraphQLFloat, type: GraphQLFloat,
}, },
_within: { within: {
description: description:
'This is the $within operator to specify a constraint to select the objects where the values of a geo point field is within a specified box.', 'This is the within operator to specify a constraint to select the objects where the values of a geo point field is within a specified box.',
type: WITHIN_INPUT, type: WITHIN_INPUT,
}, },
_geoWithin: { geoWithin: {
description: description:
'This is the $geoWithin operator to specify a constraint to select the objects where the values of a geo point field is within a specified polygon or sphere.', 'This is the geoWithin operator to specify a constraint to select the objects where the values of a geo point field is within a specified polygon or sphere.',
type: GEO_WITHIN_INPUT, type: GEO_WITHIN_INPUT,
}, },
}, },
@@ -981,10 +952,10 @@ const POLYGON_WHERE_INPUT = new GraphQLInputObjectType({
description: description:
'The PolygonWhereInput input type is used in operations that involve filtering objects by a field of type Polygon.', 'The PolygonWhereInput input type is used in operations that involve filtering objects by a field of type Polygon.',
fields: { fields: {
_exists, exists,
_geoIntersects: { geoIntersects: {
description: description:
'This is the $geoIntersects operator to specify a constraint to select the objects where the values of a polygon field intersect a specified point.', 'This is the geoIntersects operator to specify a constraint to select the objects where the values of a polygon field intersect a specified point.',
type: GEO_INTERSECTS_INPUT, type: GEO_INTERSECTS_INPUT,
}, },
}, },
@@ -1003,20 +974,9 @@ const FIND_RESULT = new GraphQLObjectType({
}, },
}); });
const SIGN_UP_RESULT = new GraphQLObjectType({
name: 'SignUpResult',
description:
'The SignUpResult object type is used in the users sign up mutation to return the data of the recent created user.',
fields: {
...CREATE_RESULT_FIELDS,
sessionToken: SESSION_TOKEN_ATT,
},
});
const ELEMENT = new GraphQLObjectType({ const ELEMENT = new GraphQLObjectType({
name: 'Element', name: 'Element',
description: description: "The Element object type is used to return array items' value.",
'The SignUpResult object type is used in the users sign up mutation to return the data of the recent created user.',
fields: { fields: {
value: { value: {
description: 'Return the value of the element in the array', description: 'Return the value of the element in the array',
@@ -1072,8 +1032,6 @@ const load = parseGraphQLSchema => {
parseGraphQLSchema.addGraphQLType(FILE_INFO, true); parseGraphQLSchema.addGraphQLType(FILE_INFO, true);
parseGraphQLSchema.addGraphQLType(GEO_POINT_INPUT, true); parseGraphQLSchema.addGraphQLType(GEO_POINT_INPUT, true);
parseGraphQLSchema.addGraphQLType(GEO_POINT, true); parseGraphQLSchema.addGraphQLType(GEO_POINT, true);
parseGraphQLSchema.addGraphQLType(CREATE_RESULT, true);
parseGraphQLSchema.addGraphQLType(UPDATE_RESULT, true);
parseGraphQLSchema.addGraphQLType(PARSE_OBJECT, true); parseGraphQLSchema.addGraphQLType(PARSE_OBJECT, true);
parseGraphQLSchema.addGraphQLType(READ_PREFERENCE, true); parseGraphQLSchema.addGraphQLType(READ_PREFERENCE, true);
parseGraphQLSchema.addGraphQLType(SUBQUERY_INPUT, true); parseGraphQLSchema.addGraphQLType(SUBQUERY_INPUT, true);
@@ -1097,7 +1055,6 @@ const load = parseGraphQLSchema => {
parseGraphQLSchema.addGraphQLType(GEO_POINT_WHERE_INPUT, true); parseGraphQLSchema.addGraphQLType(GEO_POINT_WHERE_INPUT, true);
parseGraphQLSchema.addGraphQLType(POLYGON_WHERE_INPUT, true); parseGraphQLSchema.addGraphQLType(POLYGON_WHERE_INPUT, true);
parseGraphQLSchema.addGraphQLType(FIND_RESULT, true); parseGraphQLSchema.addGraphQLType(FIND_RESULT, true);
parseGraphQLSchema.addGraphQLType(SIGN_UP_RESULT, true);
parseGraphQLSchema.addGraphQLType(ELEMENT, true); parseGraphQLSchema.addGraphQLType(ELEMENT, true);
parseGraphQLSchema.addGraphQLType(OBJECT_ID, true); parseGraphQLSchema.addGraphQLType(OBJECT_ID, true);
}; };
@@ -1127,21 +1084,16 @@ export {
POLYGON, POLYGON,
OBJECT_ID, OBJECT_ID,
CLASS_NAME_ATT, CLASS_NAME_ATT,
FIELDS_ATT,
OBJECT_ID_ATT, OBJECT_ID_ATT,
UPDATED_AT_ATT, UPDATED_AT_ATT,
CREATED_AT_ATT, CREATED_AT_ATT,
ACL_ATT, ACL_ATT,
INPUT_FIELDS, INPUT_FIELDS,
CREATE_RESULT_FIELDS, CREATE_RESULT_FIELDS,
CREATE_RESULT,
UPDATE_RESULT_FIELDS, UPDATE_RESULT_FIELDS,
UPDATE_RESULT,
PARSE_OBJECT_FIELDS, PARSE_OBJECT_FIELDS,
PARSE_OBJECT, PARSE_OBJECT,
SESSION_TOKEN_ATT, SESSION_TOKEN_ATT,
KEYS_ATT,
INCLUDE_ATT,
READ_PREFERENCE, READ_PREFERENCE,
READ_PREFERENCE_ATT, READ_PREFERENCE_ATT,
INCLUDE_READ_PREFERENCE_ATT, INCLUDE_READ_PREFERENCE_ATT,
@@ -1159,19 +1111,19 @@ export {
CENTER_SPHERE_INPUT, CENTER_SPHERE_INPUT,
GEO_WITHIN_INPUT, GEO_WITHIN_INPUT,
GEO_INTERSECTS_INPUT, GEO_INTERSECTS_INPUT,
_eq, equalTo,
_ne, notEqualTo,
_lt, lessThan,
_lte, lessThanOrEqualTo,
_gt, greaterThan,
_gte, greaterThanOrEqualTo,
_in, inOp,
_nin, notIn,
_exists, exists,
_select, inQueryKey,
_dontSelect, notInQueryKey,
_regex, matchesRegex,
_options, options,
STRING_WHERE_INPUT, STRING_WHERE_INPUT,
NUMBER_WHERE_INPUT, NUMBER_WHERE_INPUT,
BOOLEAN_WHERE_INPUT, BOOLEAN_WHERE_INPUT,
@@ -1184,7 +1136,6 @@ export {
GEO_POINT_WHERE_INPUT, GEO_POINT_WHERE_INPUT,
POLYGON_WHERE_INPUT, POLYGON_WHERE_INPUT,
FIND_RESULT, FIND_RESULT,
SIGN_UP_RESULT,
ARRAY_RESULT, ARRAY_RESULT,
ELEMENT, ELEMENT,
load, load,

View File

@@ -341,21 +341,21 @@ const load = (
name: classGraphQLConstraintTypeName, name: classGraphQLConstraintTypeName,
description: `The ${classGraphQLConstraintTypeName} input type is used in operations that involve filtering objects by a pointer field to ${graphQLClassName} class.`, description: `The ${classGraphQLConstraintTypeName} input type is used in operations that involve filtering objects by a pointer field to ${graphQLClassName} class.`,
fields: { fields: {
_eq: defaultGraphQLTypes._eq(classGraphQLScalarType), equalTo: defaultGraphQLTypes.equalTo(classGraphQLScalarType),
_ne: defaultGraphQLTypes._ne(classGraphQLScalarType), notEqualTo: defaultGraphQLTypes.notEqualTo(classGraphQLScalarType),
_in: defaultGraphQLTypes._in(classGraphQLScalarType), in: defaultGraphQLTypes.inOp(classGraphQLScalarType),
_nin: defaultGraphQLTypes._nin(classGraphQLScalarType), notIn: defaultGraphQLTypes.notIn(classGraphQLScalarType),
_exists: defaultGraphQLTypes._exists, exists: defaultGraphQLTypes.exists,
_select: defaultGraphQLTypes._select, inQueryKey: defaultGraphQLTypes.inQueryKey,
_dontSelect: defaultGraphQLTypes._dontSelect, notInQueryKey: defaultGraphQLTypes.notInQueryKey,
_inQuery: { inQuery: {
description: description:
'This is the $inQuery operator to specify a constraint to select the objects where a field equals to any of the ids in the result of a different query.', 'This is the inQuery operator to specify a constraint to select the objects where a field equals to any of the ids in the result of a different query.',
type: defaultGraphQLTypes.SUBQUERY_INPUT, type: defaultGraphQLTypes.SUBQUERY_INPUT,
}, },
_notInQuery: { notInQuery: {
description: description:
'This is the $notInQuery operator to specify a constraint to select the objects where a field do not equal to any of the ids in the result of a different query.', 'This is the notInQuery operator to specify a constraint to select the objects where a field do not equal to any of the ids in the result of a different query.',
type: defaultGraphQLTypes.SUBQUERY_INPUT, type: defaultGraphQLTypes.SUBQUERY_INPUT,
}, },
}, },
@@ -370,6 +370,12 @@ const load = (
description: `The ${classGraphQLConstraintsTypeName} input type is used in operations that involve filtering objects of ${graphQLClassName} class.`, description: `The ${classGraphQLConstraintsTypeName} input type is used in operations that involve filtering objects of ${graphQLClassName} class.`,
fields: () => ({ fields: () => ({
...classConstraintFields.reduce((fields, field) => { ...classConstraintFields.reduce((fields, field) => {
if (['OR', 'AND', 'NOR'].includes(field)) {
parseGraphQLSchema.log.warn(
`Field ${field} could not be added to the auto schema ${classGraphQLConstraintsTypeName} because it collided with an existing one.`
);
return fields;
}
const parseField = field === 'id' ? 'objectId' : field; const parseField = field === 'id' ? 'objectId' : field;
const type = transformConstraintTypeToGraphQL( const type = transformConstraintTypeToGraphQL(
parseClass.fields[parseField].type, parseClass.fields[parseField].type,
@@ -388,16 +394,16 @@ const load = (
return fields; return fields;
} }
}, {}), }, {}),
_or: { OR: {
description: 'This is the $or operator to compound constraints.', description: 'This is the OR operator to compound constraints.',
type: new GraphQLList(new GraphQLNonNull(classGraphQLConstraintsType)), type: new GraphQLList(new GraphQLNonNull(classGraphQLConstraintsType)),
}, },
_and: { AND: {
description: 'This is the $and operator to compound constraints.', description: 'This is the AND operator to compound constraints.',
type: new GraphQLList(new GraphQLNonNull(classGraphQLConstraintsType)), type: new GraphQLList(new GraphQLNonNull(classGraphQLConstraintsType)),
}, },
_nor: { NOR: {
description: 'This is the $nor operator to compound constraints.', description: 'This is the NOR operator to compound constraints.',
type: new GraphQLList(new GraphQLNonNull(classGraphQLConstraintsType)), type: new GraphQLList(new GraphQLNonNull(classGraphQLConstraintsType)),
}, },
}), }),
@@ -491,7 +497,7 @@ const load = (
return await objectsQueries.findObjects( return await objectsQueries.findObjects(
source[field].className, source[field].className,
{ {
_relatedTo: { $relatedTo: {
object: { object: {
__type: 'Pointer', __type: 'Pointer',
className: className, className: className,

View File

@@ -1,54 +1,53 @@
const parseMap = { const parseQueryMap = {
id: 'objectId', id: 'objectId',
_or: '$or', OR: '$or',
_and: '$and', AND: '$and',
_nor: '$nor', NOR: '$nor',
_relatedTo: '$relatedTo',
_eq: '$eq',
_ne: '$ne',
_lt: '$lt',
_lte: '$lte',
_gt: '$gt',
_gte: '$gte',
_in: '$in',
_nin: '$nin',
_exists: '$exists',
_select: '$select',
_dontSelect: '$dontSelect',
_inQuery: '$inQuery',
_notInQuery: '$notInQuery',
_containedBy: '$containedBy',
_all: '$all',
_regex: '$regex',
_options: '$options',
_text: '$text',
_search: '$search',
_term: '$term',
_language: '$language',
_caseSensitive: '$caseSensitive',
_diacriticSensitive: '$diacriticSensitive',
_nearSphere: '$nearSphere',
_maxDistance: '$maxDistance',
_maxDistanceInRadians: '$maxDistanceInRadians',
_maxDistanceInMiles: '$maxDistanceInMiles',
_maxDistanceInKilometers: '$maxDistanceInKilometers',
_within: '$within',
_box: '$box',
_geoWithin: '$geoWithin',
_polygon: '$polygon',
_centerSphere: '$centerSphere',
_geoIntersects: '$geoIntersects',
_point: '$point',
}; };
const transformQueryInputToParse = ( const parseConstraintMap = {
equalTo: '$eq',
notEqualTo: '$ne',
lessThan: '$lt',
lessThanOrEqualTo: '$lte',
greaterThan: '$gt',
greaterThanOrEqualTo: '$gte',
in: '$in',
notIn: '$nin',
exists: '$exists',
inQueryKey: '$select',
notInQueryKey: '$dontSelect',
inQuery: '$inQuery',
notInQuery: '$notInQuery',
containedBy: '$containedBy',
contains: '$all',
matchesRegex: '$regex',
options: '$options',
text: '$text',
search: '$search',
term: '$term',
language: '$language',
caseSensitive: '$caseSensitive',
diacriticSensitive: '$diacriticSensitive',
nearSphere: '$nearSphere',
maxDistance: '$maxDistance',
maxDistanceInRadians: '$maxDistanceInRadians',
maxDistanceInMiles: '$maxDistanceInMiles',
maxDistanceInKilometers: '$maxDistanceInKilometers',
within: '$within',
box: '$box',
geoWithin: '$geoWithin',
polygon: '$polygon',
centerSphere: '$centerSphere',
geoIntersects: '$geoIntersects',
point: '$point',
};
const transformQueryConstraintInputToParse = (
constraints, constraints,
parentFieldName, parentFieldName,
parentConstraints parentConstraints
) => { ) => {
if (!constraints || typeof constraints !== 'object') {
return;
}
Object.keys(constraints).forEach(fieldName => { Object.keys(constraints).forEach(fieldName => {
let fieldValue = constraints[fieldName]; let fieldValue = constraints[fieldName];
@@ -59,13 +58,13 @@ const transformQueryInputToParse = (
* From: * From:
* { * {
* "someField": { * "someField": {
* "_lt": { * "lessThan": {
* "_key":"foo.bar", * "key":"foo.bar",
* "_value": 100 * "value": 100
* }, * },
* "_gt": { * "greaterThan": {
* "_key":"foo.bar", * "key":"foo.bar",
* "_value": 10 * "value": 10
* } * }
* } * }
* } * }
@@ -79,19 +78,19 @@ const transformQueryInputToParse = (
* } * }
*/ */
if ( if (
fieldValue._key && fieldValue.key &&
fieldValue._value && fieldValue.value &&
parentConstraints && parentConstraints &&
parentFieldName parentFieldName
) { ) {
delete parentConstraints[parentFieldName]; delete parentConstraints[parentFieldName];
parentConstraints[`${parentFieldName}.${fieldValue._key}`] = { parentConstraints[`${parentFieldName}.${fieldValue.key}`] = {
...parentConstraints[`${parentFieldName}.${fieldValue._key}`], ...parentConstraints[`${parentFieldName}.${fieldValue.key}`],
[parseMap[fieldName]]: fieldValue._value, [parseConstraintMap[fieldName]]: fieldValue.value,
}; };
} else if (parseMap[fieldName]) { } else if (parseConstraintMap[fieldName]) {
delete constraints[fieldName]; delete constraints[fieldName];
fieldName = parseMap[fieldName]; fieldName = parseConstraintMap[fieldName];
constraints[fieldName] = fieldValue; constraints[fieldName] = fieldValue;
} }
switch (fieldName) { switch (fieldName) {
@@ -147,9 +146,44 @@ const transformQueryInputToParse = (
break; break;
} }
if (typeof fieldValue === 'object') { if (typeof fieldValue === 'object') {
transformQueryInputToParse(fieldValue, fieldName, constraints); if (fieldName === 'where') {
transformQueryInputToParse(fieldValue);
} else {
transformQueryConstraintInputToParse(
fieldValue,
fieldName,
constraints
);
}
} }
}); });
}; };
export { transformQueryInputToParse }; const transformQueryInputToParse = constraints => {
if (!constraints || typeof constraints !== 'object') {
return;
}
Object.keys(constraints).forEach(fieldName => {
const fieldValue = constraints[fieldName];
if (parseQueryMap[fieldName]) {
delete constraints[fieldName];
fieldName = parseQueryMap[fieldName];
constraints[fieldName] = fieldValue;
if (fieldName !== 'objectId') {
fieldValue.forEach(fieldValueItem => {
transformQueryInputToParse(fieldValueItem);
});
return;
}
}
if (typeof fieldValue === 'object') {
transformQueryConstraintInputToParse(fieldValue, fieldName, constraints);
}
});
};
export { transformQueryConstraintInputToParse, transformQueryInputToParse };