Graphql tools v5 (#6611)

* Add test case for order option when extending the schema

* Remove fit

* upgrade to graphql-tools v5

revert #6515

Co-authored-by: Antonio Davi Macedo Coelho de Castro <adavimacedo@gmail.com>
This commit is contained in:
Yaacov Rydzinski
2020-04-21 01:16:48 -04:00
committed by GitHub
parent 84b2d072a6
commit a6300a2201
4 changed files with 232 additions and 186 deletions

View File

@@ -7,7 +7,7 @@ import { transformQueryInputToParse } from '../transformers/query';
/* eslint-disable*/
const needToGetAllKeys = (fields, keys, parseClasses) =>
keys
? keys.split(',').some(keyName => {
? keys.split(',').some((keyName) => {
const key = keyName.split('.');
if (fields[key[0]]) {
if (fields[key[0]].type === 'Pointer') {
@@ -30,20 +30,6 @@ const needToGetAllKeys = (fields, keys, parseClasses) =>
: true;
/* eslint-enable*/
const transformOrder = order =>
order
.map(o => {
const direction = o.indexOf('_ASC') > 0 ? '_ASC' : '_DESC';
let field = o.replace(direction, '');
field = field === 'id' ? 'objectId' : field;
if (direction === '_ASC') {
return `${field}`;
} else {
return `-${field}`;
}
})
.join(',');
const getObject = async (
className,
objectId,
@@ -168,7 +154,7 @@ const findObjects = async (
if (
selectedFields.find(
field => field.startsWith('edges.') || field.startsWith('pageInfo.')
(field) => field.startsWith('edges.') || field.startsWith('pageInfo.')
)
) {
if (limit || limit === 0) {
@@ -178,7 +164,7 @@ const findObjects = async (
}
if (options.limit !== 0) {
if (order) {
options.order = transformOrder(order);
options.order = order;
}
if (skip) {
options.skip = skip;