GraphQL: Allow true GraphQL Schema Customization (#6360)
* Allow real GraphQL Schema via ParseServer.start * wip * working * tests ok * add tests about enum/input use case * Add async function based merge * Better naming * remove useless condition
This commit is contained in:
@@ -3,6 +3,11 @@ import { offsetToCursor, cursorToOffset } from 'graphql-relay';
|
||||
import rest from '../../rest';
|
||||
import { transformQueryInputToParse } from '../transformers/query';
|
||||
|
||||
const needToGetAllKeys = (fields, keys) =>
|
||||
keys
|
||||
? !!keys.split(',').find(keyName => !fields[keyName.split('.')[0]])
|
||||
: true;
|
||||
|
||||
const getObject = async (
|
||||
className,
|
||||
objectId,
|
||||
@@ -12,10 +17,11 @@ const getObject = async (
|
||||
includeReadPreference,
|
||||
config,
|
||||
auth,
|
||||
info
|
||||
info,
|
||||
parseClass
|
||||
) => {
|
||||
const options = {};
|
||||
if (keys) {
|
||||
if (!needToGetAllKeys(parseClass.fields, keys)) {
|
||||
options.keys = keys;
|
||||
}
|
||||
if (include) {
|
||||
@@ -133,7 +139,14 @@ const findObjects = async (
|
||||
// Silently replace the limit on the query with the max configured
|
||||
options.limit = config.maxLimit;
|
||||
}
|
||||
if (keys) {
|
||||
if (
|
||||
!needToGetAllKeys(
|
||||
parseClasses.find(
|
||||
({ className: parseClassName }) => className === parseClassName
|
||||
).fields,
|
||||
keys
|
||||
)
|
||||
) {
|
||||
options.keys = keys;
|
||||
}
|
||||
if (includeAll === true) {
|
||||
@@ -313,4 +326,4 @@ const calculateSkipAndLimit = (
|
||||
};
|
||||
};
|
||||
|
||||
export { getObject, findObjects, calculateSkipAndLimit };
|
||||
export { getObject, findObjects, calculateSkipAndLimit, needToGetAllKeys };
|
||||
|
||||
Reference in New Issue
Block a user