Remove nested operations from GraphQL API (#5931)

* Remove nested operations

* Improve error log

* Fix bug schema to load

* Fix ParseGraphQLSchema tests

* Fix tests

* Fix failing tests

* Rename call to callCloudCode
This commit is contained in:
Antonio Davi Macedo Coelho de Castro
2019-08-17 11:02:19 -07:00
committed by Antoine Cormouls
parent 47d1a74ac0
commit ee5aeeaff5
14 changed files with 1157 additions and 1619 deletions

View File

@@ -1,4 +1,4 @@
import { GraphQLNonNull, GraphQLObjectType } from 'graphql';
import { GraphQLNonNull } from 'graphql';
import getFieldNames from 'graphql-list-fields';
import Parse from 'parse/node';
import rest from '../../rest';
@@ -49,34 +49,25 @@ const load = parseGraphQLSchema => {
if (parseGraphQLSchema.isUsersClassDisabled) {
return;
}
const fields = {};
fields.viewer = {
description:
'The viewer query can be used to return the current user data.',
type: new GraphQLNonNull(parseGraphQLSchema.viewerType),
async resolve(_source, _args, context, queryInfo) {
try {
const { config, info } = context;
return await getUserFromSessionToken(config, info, queryInfo);
} catch (e) {
parseGraphQLSchema.handleError(e);
}
parseGraphQLSchema.addGraphQLQuery(
'viewer',
{
description:
'The viewer query can be used to return the current user data.',
type: new GraphQLNonNull(parseGraphQLSchema.viewerType),
async resolve(_source, _args, context, queryInfo) {
try {
const { config, info } = context;
return await getUserFromSessionToken(config, info, queryInfo);
} catch (e) {
parseGraphQLSchema.handleError(e);
}
},
},
};
const usersQuery = new GraphQLObjectType({
name: 'UsersQuery',
description: 'UsersQuery is the top level type for users queries.',
fields,
});
parseGraphQLSchema.addGraphQLType(usersQuery, true, true);
parseGraphQLSchema.graphQLQueries.users = {
description: 'This is the top level for users queries.',
type: usersQuery,
resolve: () => new Object(),
};
true,
true
);
};
export { load, getUserFromSessionToken };