Fix Prettier (#7066)

This commit is contained in:
Diamond Lewis
2020-12-13 11:19:04 -06:00
committed by GitHub
parent d4948572a8
commit 033a0bd443
64 changed files with 697 additions and 1887 deletions

View File

@@ -1,11 +1,6 @@
import * as defaultGraphQLTypes from '../loaders/defaultGraphQLTypes';
const transformConstraintTypeToGraphQL = (
parseType,
targetClass,
parseClassTypes,
fieldName
) => {
const transformConstraintTypeToGraphQL = (parseType, targetClass, parseClassTypes, fieldName) => {
if (fieldName === 'id' || fieldName === 'objectId') {
return defaultGraphQLTypes.ID_WHERE_INPUT;
}

View File

@@ -1,16 +1,7 @@
import {
GraphQLString,
GraphQLFloat,
GraphQLBoolean,
GraphQLList,
} from 'graphql';
import { GraphQLString, GraphQLFloat, GraphQLBoolean, GraphQLList } from 'graphql';
import * as defaultGraphQLTypes from '../loaders/defaultGraphQLTypes';
const transformInputTypeToGraphQL = (
parseType,
targetClass,
parseClassTypes
) => {
const transformInputTypeToGraphQL = (parseType, targetClass, parseClassTypes) => {
switch (parseType) {
case 'String':
return GraphQLString;

View File

@@ -14,19 +14,13 @@ const transformTypes = async (
classGraphQLUpdateType,
config: { isCreateEnabled, isUpdateEnabled },
} = parseGraphQLSchema.parseClassTypes[className];
const parseClass = parseGraphQLSchema.parseClasses.find(
(clazz) => clazz.className === className
);
const parseClass = parseGraphQLSchema.parseClasses.find(clazz => clazz.className === className);
if (fields) {
const classGraphQLCreateTypeFields =
isCreateEnabled && classGraphQLCreateType
? classGraphQLCreateType.getFields()
: null;
isCreateEnabled && classGraphQLCreateType ? classGraphQLCreateType.getFields() : null;
const classGraphQLUpdateTypeFields =
isUpdateEnabled && classGraphQLUpdateType
? classGraphQLUpdateType.getFields()
: null;
const promises = Object.keys(fields).map(async (field) => {
isUpdateEnabled && classGraphQLUpdateType ? classGraphQLUpdateType.getFields() : null;
const promises = Object.keys(fields).map(async field => {
let inputTypeField;
if (inputType === 'create' && classGraphQLCreateTypeFields) {
inputTypeField = classGraphQLCreateTypeFields[field];
@@ -84,18 +78,15 @@ const transformers = {
}
throw new Parse.Error(Parse.Error.FILE_SAVE_ERROR, 'Invalid file upload.');
},
polygon: (value) => ({
polygon: value => ({
__type: 'Polygon',
coordinates: value.map((geoPoint) => [
geoPoint.latitude,
geoPoint.longitude,
]),
coordinates: value.map(geoPoint => [geoPoint.latitude, geoPoint.longitude]),
}),
geoPoint: (value) => ({
geoPoint: value => ({
...value,
__type: 'GeoPoint',
}),
ACL: (value) => {
ACL: value => {
const parseACL = {};
if (value.public) {
parseACL['*'] = {
@@ -104,7 +95,7 @@ const transformers = {
};
}
if (value.users) {
value.users.forEach((rule) => {
value.users.forEach(rule => {
const globalIdObject = fromGlobalId(rule.userId);
if (globalIdObject.type === '_User') {
rule.userId = globalIdObject.id;
@@ -116,7 +107,7 @@ const transformers = {
});
}
if (value.roles) {
value.roles.forEach((rule) => {
value.roles.forEach(rule => {
parseACL[`role:${rule.roleName}`] = {
read: rule.read,
write: rule.write,
@@ -125,13 +116,7 @@ const transformers = {
}
return parseACL;
},
relation: async (
targetClass,
field,
value,
parseGraphQLSchema,
{ config, auth, info }
) => {
relation: async (targetClass, field, value, parseGraphQLSchema, { config, auth, info }) => {
if (Object.keys(value).length === 0)
throw new Parse.Error(
Parse.Error.INVALID_POINTER,
@@ -147,22 +132,16 @@ const transformers = {
if (value.createAndAdd) {
nestedObjectsToAdd = (
await Promise.all(
value.createAndAdd.map(async (input) => {
value.createAndAdd.map(async input => {
const parseFields = await transformTypes('create', input, {
className: targetClass,
parseGraphQLSchema,
req: { config, auth, info },
});
return objectsMutations.createObject(
targetClass,
parseFields,
config,
auth,
info
);
return objectsMutations.createObject(targetClass, parseFields, config, auth, info);
})
)
).map((object) => ({
).map(object => ({
__type: 'Pointer',
className: targetClass,
objectId: object.objectId,
@@ -171,7 +150,7 @@ const transformers = {
if (value.add || nestedObjectsToAdd.length > 0) {
if (!value.add) value.add = [];
value.add = value.add.map((input) => {
value.add = value.add.map(input => {
const globalIdObject = fromGlobalId(input);
if (globalIdObject.type === targetClass) {
input = globalIdObject.id;
@@ -191,7 +170,7 @@ const transformers = {
if (value.remove) {
op.ops.push({
__op: 'RemoveRelation',
objects: value.remove.map((input) => {
objects: value.remove.map(input => {
const globalIdObject = fromGlobalId(input);
if (globalIdObject.type === targetClass) {
input = globalIdObject.id;
@@ -206,13 +185,7 @@ const transformers = {
}
return op;
},
pointer: async (
targetClass,
field,
value,
parseGraphQLSchema,
{ config, auth, info }
) => {
pointer: async (targetClass, field, value, parseGraphQLSchema, { config, auth, info }) => {
if (Object.keys(value).length > 1 || Object.keys(value).length === 0)
throw new Parse.Error(
Parse.Error.INVALID_POINTER,

View File

@@ -1,17 +1,7 @@
import * as defaultGraphQLTypes from '../loaders/defaultGraphQLTypes';
import {
GraphQLString,
GraphQLFloat,
GraphQLBoolean,
GraphQLList,
GraphQLNonNull,
} from 'graphql';
import { GraphQLString, GraphQLFloat, GraphQLBoolean, GraphQLList, GraphQLNonNull } from 'graphql';
const transformOutputTypeToGraphQL = (
parseType,
targetClass,
parseClassTypes
) => {
const transformOutputTypeToGraphQL = (parseType, targetClass, parseClassTypes) => {
switch (parseType) {
case 'String':
return GraphQLString;
@@ -41,9 +31,7 @@ const transformOutputTypeToGraphQL = (
parseClassTypes[targetClass] &&
parseClassTypes[targetClass].classGraphQLFindResultType
) {
return new GraphQLNonNull(
parseClassTypes[targetClass].classGraphQLFindResultType
);
return new GraphQLNonNull(parseClassTypes[targetClass].classGraphQLFindResultType);
} else {
return new GraphQLNonNull(defaultGraphQLTypes.OBJECT);
}

View File

@@ -51,9 +51,7 @@ const transformQueryConstraintInputToParse = (
parentConstraints,
parseClasses
) => {
const fields = parseClasses.find(
parseClass => parseClass.className === className
).fields;
const fields = parseClasses.find(parseClass => parseClass.className === className).fields;
if (parentFieldName === 'id' && className) {
Object.keys(constraints).forEach(constraintName => {
const constraintValue = constraints[constraintName];
@@ -110,12 +108,7 @@ const transformQueryConstraintInputToParse = (
* }
* }
*/
if (
fieldValue.key &&
fieldValue.value &&
parentConstraints &&
parentFieldName
) {
if (fieldValue.key && fieldValue.value && parentConstraints && parentFieldName) {
delete parentConstraints[parentFieldName];
parentConstraints[`${parentFieldName}.${fieldValue.key}`] = {
...parentConstraints[`${parentFieldName}.${fieldValue.key}`],
@@ -123,8 +116,7 @@ const transformQueryConstraintInputToParse = (
};
} else if (
fields[parentFieldName] &&
(fields[parentFieldName].type === 'Pointer' ||
fields[parentFieldName].type === 'Relation')
(fields[parentFieldName].type === 'Pointer' || fields[parentFieldName].type === 'Relation')
) {
const { targetClass } = fields[parentFieldName];
if (fieldName === 'exists') {
@@ -193,11 +185,7 @@ const transformQueryConstraintInputToParse = (
}
break;
case 'box':
if (
typeof fieldValue === 'object' &&
fieldValue.bottomLeft &&
fieldValue.upperRight
) {
if (typeof fieldValue === 'object' && fieldValue.bottomLeft && fieldValue.upperRight) {
fieldValue = [
{
__type: 'GeoPoint',
@@ -221,11 +209,7 @@ const transformQueryConstraintInputToParse = (
}
break;
case 'centerSphere':
if (
typeof fieldValue === 'object' &&
fieldValue.center &&
fieldValue.distance
) {
if (typeof fieldValue === 'object' && fieldValue.center && fieldValue.distance) {
fieldValue = [
{
__type: 'GeoPoint',

View File

@@ -22,20 +22,12 @@ const transformToParse = (graphQLSchemaFields, existingFields) => {
}
if (
graphQLSchemaFields.remove &&
graphQLSchemaFields.remove.find(
removeField => removeField.name === field.name
)
graphQLSchemaFields.remove.find(removeField => removeField.name === field.name)
) {
return parseSchemaFields;
}
if (
parseSchemaFields[field.name] ||
(existingFields && existingFields[field.name])
) {
throw new Parse.Error(
Parse.Error.INVALID_KEY_NAME,
`Duplicated field name: ${field.name}`
);
if (parseSchemaFields[field.name] || (existingFields && existingFields[field.name])) {
throw new Parse.Error(Parse.Error.INVALID_KEY_NAME, `Duplicated field name: ${field.name}`);
}
if (type === 'Relation' || type === 'Pointer') {
return {