Skip to content

Commit f1facb1

Browse files
committed
Fix some tests
1 parent 809ea1a commit f1facb1

File tree

8 files changed

+134
-163
lines changed

8 files changed

+134
-163
lines changed

spec/ParseGraphQLServer.spec.js

Lines changed: 117 additions & 151 deletions
Large diffs are not rendered by default.

src/GraphQL/loaders/objectsMutations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { GraphQLNonNull, GraphQLBoolean, GraphQLObjectType } from 'graphql';
22
import * as defaultGraphQLTypes from './defaultGraphQLTypes';
33
import rest from '../../rest';
4-
import { transformMutationInputToParse } from '../transformes/mutation';
4+
import { transformMutationInputToParse } from '../transformers/mutation';
55
import { transformClassNameToParse } from '../transformers/className';
66

77
const createObject = async (className, fields, config, auth, info) => {

src/GraphQL/loaders/parseClassQueries.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const load = function(
1818
parseClassConfig: ?ParseGraphQLClassConfig
1919
) {
2020
const className = transformClassNameToGraphQL(parseClass.className);
21-
2221
const {
2322
get: isGetEnabled = true,
2423
find: isFindEnabled = true,
@@ -32,7 +31,7 @@ const load = function(
3231

3332
if (isGetEnabled) {
3433
const getGraphQLQueryName =
35-
className.charAt(0).toUpperCase() + className.slice(1);
34+
className.charAt(0).toLowerCase() + className.slice(1);
3635
parseGraphQLSchema.graphQLObjectsQueries[getGraphQLQueryName] = {
3736
description: `The ${getGraphQLQueryName} query can be used to get an object of the ${className} class by its id.`,
3837
args: {
@@ -71,7 +70,7 @@ const load = function(
7170

7271
if (isFindEnabled) {
7372
const findGraphQLQueryName =
74-
className.charAt(0).toUpperCase() + className.slice(1) + 's';
73+
className.charAt(0).toLowerCase() + className.slice(1) + 's';
7574
parseGraphQLSchema.graphQLObjectsQueries[findGraphQLQueryName] = {
7675
description: `The ${findGraphQLQueryName} query can be used to find objects of the ${className} class.`,
7776
args: classGraphQLFindArgs,

src/GraphQL/loaders/parseClassTypes.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import getFieldNames from 'graphql-list-fields';
1414
import * as defaultGraphQLTypes from './defaultGraphQLTypes';
1515
import * as objectsQueries from './objectsQueries';
1616
import { ParseGraphQLClassConfig } from '../../Controllers/ParseGraphQLController';
17+
import { transformClassNameToGraphQL } from '../transformers/className';
1718

1819
const mapInputType = (parseType, targetClass, parseClassTypes) => {
1920
switch (parseType) {
@@ -253,7 +254,7 @@ const load = (
253254
parseClass,
254255
parseClassConfig: ?ParseGraphQLClassConfig
255256
) => {
256-
const { className } = parseClass;
257+
const className = transformClassNameToGraphQL(parseClass.className);
257258
const {
258259
classCreateFields,
259260
classUpdateFields,
@@ -669,7 +670,7 @@ const load = (
669670
classGraphQLFindResultType,
670671
};
671672

672-
if (className === '_User') {
673+
if (className === transformClassNameToGraphQL('_User')) {
673674
const meType = new GraphQLObjectType({
674675
name: 'Me',
675676
description: `The Me object type is used in operations that involve outputting the current user data.`,
@@ -682,7 +683,7 @@ const load = (
682683
parseGraphQLSchema.meType = meType;
683684
parseGraphQLSchema.graphQLTypes.push(meType);
684685

685-
const userSignUpInputTypeName = '_UserSignUpFields';
686+
const userSignUpInputTypeName = 'UserSignUpFields';
686687
const userSignUpInputType = new GraphQLInputObjectType({
687688
name: userSignUpInputTypeName,
688689
description: `The ${userSignUpInputTypeName} input type is used in operations that involve inputting objects of ${className} class when signing up.`,
@@ -710,7 +711,7 @@ const load = (
710711
}, {}),
711712
});
712713
parseGraphQLSchema.parseClassTypes[
713-
'_User'
714+
transformClassNameToGraphQL('_User')
714715
].signUpInputType = userSignUpInputType;
715716
parseGraphQLSchema.graphQLTypes.push(userSignUpInputType);
716717
}

src/GraphQL/loaders/usersMutations.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import UsersRouter from '../../Routers/UsersRouter';
88
import * as defaultGraphQLTypes from './defaultGraphQLTypes';
99
import * as objectsMutations from './objectsMutations';
10+
import { transformClassNameToGraphQL } from '../transformers/className';
1011

1112
const usersRouter = new UsersRouter();
1213

@@ -21,7 +22,10 @@ const load = parseGraphQLSchema => {
2122
args: {
2223
fields: {
2324
descriptions: 'These are the fields of the user.',
24-
type: parseGraphQLSchema.parseClassTypes['_User'].signUpInputType,
25+
type:
26+
parseGraphQLSchema.parseClassTypes[
27+
transformClassNameToGraphQL('_User')
28+
].signUpInputType,
2529
},
2630
},
2731
type: new GraphQLNonNull(defaultGraphQLTypes.SIGN_UP_RESULT),
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import logger from '../logger';
1+
import logger from '../../logger';
22

33
const parseMap = {
44
Role: '_Role',
55
User: '_User',
66
Files: 'Files',
7+
Session: '_Session',
78
};
89
const reverseParseMap = {};
910
// Dynamically fill reverseParseMap based on parseMap
@@ -14,15 +15,15 @@ const transformClassNameToParse = className => {
1415
logger.error(
1516
`Native Parse Class collision detected, please change the name of your class ${className}`
1617
);
17-
parseMap[className] ? parseMap[className] : className;
18+
return parseMap[className] ? parseMap[className] : className;
1819
};
1920

2021
const transformClassNameToGraphQL = className => {
2122
if (parseMap[className])
2223
logger.error(
2324
`Native Parse Class collision detected, please change the name of your class ${className}`
2425
);
25-
reverseParseMap[className] ? reverseParseMap[className] : className;
26+
return reverseParseMap[className] ? reverseParseMap[className] : className;
2627
};
2728

2829
export { transformClassNameToGraphQL, transformClassNameToParse };
File renamed without changes.

0 commit comments

Comments
 (0)