@@ -14,7 +14,10 @@ import getFieldNames from 'graphql-list-fields';
14
14
import * as defaultGraphQLTypes from './defaultGraphQLTypes' ;
15
15
import * as objectsQueries from './objectsQueries' ;
16
16
import { ParseGraphQLClassConfig } from '../../Controllers/ParseGraphQLController' ;
17
- import { transformClassNameToGraphQL } from '../transformers/className' ;
17
+ import {
18
+ transformClassNameToGraphQL ,
19
+ transformClassNameToParse ,
20
+ } from '../transformers/className' ;
18
21
19
22
const mapInputType = ( parseType , targetClass , parseClassTypes ) => {
20
23
switch ( parseType ) {
@@ -58,6 +61,7 @@ const mapInputType = (parseType, targetClass, parseClassTypes) => {
58
61
} ;
59
62
60
63
const mapOutputType = ( parseType , targetClass , parseClassTypes ) => {
64
+ targetClass = transformClassNameToGraphQL ( targetClass ) ;
61
65
switch ( parseType ) {
62
66
case 'String' :
63
67
return GraphQLString ;
@@ -268,7 +272,7 @@ const load = (
268
272
if ( typeof value === 'string' ) {
269
273
return {
270
274
__type : 'Pointer' ,
271
- className,
275
+ className : transformClassNameToParse ( className ) ,
272
276
objectId : value ,
273
277
} ;
274
278
} else if (
@@ -277,7 +281,7 @@ const load = (
277
281
value . className === className &&
278
282
typeof value . objectId === 'string'
279
283
) {
280
- return value ;
284
+ return { ... value , className : transformClassNameToParse ( className ) } ;
281
285
}
282
286
283
287
throw new defaultGraphQLTypes . TypeValidationError (
@@ -295,7 +299,7 @@ const load = (
295
299
} else if (
296
300
typeof value === 'object' &&
297
301
value . __type === 'Pointer' &&
298
- value . className === className &&
302
+ transformClassNameToGraphQL ( value . className ) === className &&
299
303
typeof value . objectId === 'string'
300
304
) {
301
305
return value . objectId ;
@@ -539,7 +543,7 @@ const load = (
539
543
if ( parseClass . fields [ field ] . type === 'Relation' ) {
540
544
const targetParseClassTypes =
541
545
parseGraphQLSchema . parseClassTypes [
542
- parseClass . fields [ field ] . targetClass
546
+ transformClassNameToGraphQL ( parseClass . fields [ field ] . targetClass )
543
547
] ;
544
548
const args = targetParseClassTypes
545
549
? targetParseClassTypes . classGraphQLFindArgs
@@ -569,14 +573,14 @@ const load = (
569
573
. filter ( field => field . includes ( '.' ) )
570
574
. map ( field => field . slice ( field . indexOf ( '.' ) + 1 ) )
571
575
) ;
572
-
576
+ console . log ( source [ field ] . className ) ;
573
577
return await objectsQueries . findObjects (
574
578
source [ field ] . className ,
575
579
{
576
580
_relatedTo : {
577
581
object : {
578
582
__type : 'Pointer' ,
579
- className,
583
+ className : transformClassNameToParse ( className ) ,
580
584
objectId : source . objectId ,
581
585
} ,
582
586
key : field ,
0 commit comments