feat: replace GraphQL Apollo with GraphQL Yoga (#7967)
This commit is contained in:
@@ -89,13 +89,14 @@ class ParseGraphQLSchema {
|
||||
this.graphQLCustomTypeDefs = params.graphQLCustomTypeDefs;
|
||||
this.appId = params.appId || requiredParameter('You must provide the appId!');
|
||||
this.schemaCache = SchemaCache;
|
||||
this.logCache = {};
|
||||
}
|
||||
|
||||
async load() {
|
||||
const { parseGraphQLConfig } = await this._initializeSchemaAndConfig();
|
||||
const parseClassesArray = await this._getClassesForSchema(parseGraphQLConfig);
|
||||
const functionNames = await this._getFunctionNames();
|
||||
const functionNamesString = JSON.stringify(functionNames);
|
||||
const functionNamesString = functionNames.join();
|
||||
|
||||
const parseClasses = parseClassesArray.reduce((acc, clazz) => {
|
||||
acc[clazz.className] = clazz;
|
||||
@@ -331,6 +332,14 @@ class ParseGraphQLSchema {
|
||||
return this.graphQLSchema;
|
||||
}
|
||||
|
||||
_logOnce(severity, message) {
|
||||
if (this.logCache[message]) {
|
||||
return;
|
||||
}
|
||||
this.log[severity](message);
|
||||
this.logCache[message] = true;
|
||||
}
|
||||
|
||||
addGraphQLType(type, throwError = false, ignoreReserved = false, ignoreConnection = false) {
|
||||
if (
|
||||
(!ignoreReserved && RESERVED_GRAPHQL_TYPE_NAMES.includes(type.name)) ||
|
||||
@@ -341,7 +350,7 @@ class ParseGraphQLSchema {
|
||||
if (throwError) {
|
||||
throw new Error(message);
|
||||
}
|
||||
this.log.warn(message);
|
||||
this._logOnce('warn', message);
|
||||
return undefined;
|
||||
}
|
||||
this.graphQLTypes.push(type);
|
||||
@@ -357,7 +366,7 @@ class ParseGraphQLSchema {
|
||||
if (throwError) {
|
||||
throw new Error(message);
|
||||
}
|
||||
this.log.warn(message);
|
||||
this._logOnce('warn', message);
|
||||
return undefined;
|
||||
}
|
||||
this.graphQLQueries[fieldName] = field;
|
||||
@@ -373,7 +382,7 @@ class ParseGraphQLSchema {
|
||||
if (throwError) {
|
||||
throw new Error(message);
|
||||
}
|
||||
this.log.warn(message);
|
||||
this._logOnce('warn', message);
|
||||
return undefined;
|
||||
}
|
||||
this.graphQLMutations[fieldName] = field;
|
||||
@@ -482,7 +491,8 @@ class ParseGraphQLSchema {
|
||||
if (/^[_a-zA-Z][_a-zA-Z0-9]*$/.test(functionName)) {
|
||||
return true;
|
||||
} else {
|
||||
this.log.warn(
|
||||
this._logOnce(
|
||||
'warn',
|
||||
`Function ${functionName} could not be added to the auto schema because GraphQL names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/.`
|
||||
);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user