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:
Antoine Cormouls
2020-02-22 00:12:49 +01:00
committed by GitHub
parent d4690ca425
commit c7f96c92cd
8 changed files with 411 additions and 141 deletions

View File

@@ -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 };