Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
? await plugin.middleware({ config })
: plugin.middleware;
if (Array.isArray(middleware)) {
registeredMiddleware.push(...middleware);
} else {
registeredMiddleware.push(middleware);
}
}
config.middleware && registeredMiddleware.push(config.middleware);
if (registeredMiddleware.length) {
schema = applyMiddleware(schema, ...registeredMiddleware);
}
addSchemaLevelResolveFunction(schema, async (root, args, context, info) => {
// Make sure we do not block this resolver from processing subsequent requests!
// This is something that is baked into the graphql-tools and cannot be avoided another way.
delete info.operation["__runAtMostOnce"];
// Process `graphql-context` plugins
const ctxPlugins = getPlugins("graphql-context");
for (let i = 0; i < ctxPlugins.length; i++) {
const ctxPlugin = ctxPlugins[i];
if (typeof ctxPlugin.preApply === "function") {
await ctxPlugin.preApply(context);
}
}
for (let i = 0; i < ctxPlugins.length; i++) {
const ctxPlugin = ctxPlugins[i];
const middleware =
typeof plugin.middleware === "function"
? await plugin.middleware({ plugins })
: plugin.middleware;
if (Array.isArray(middleware)) {
registeredMiddleware.push(...middleware);
} else {
registeredMiddleware.push(middleware);
}
}
if (registeredMiddleware.length) {
schema = applyMiddleware(schema, ...registeredMiddleware);
}
addSchemaLevelResolveFunction(schema, async (root, args, context, info) => {
// Make sure we do not block this resolver from processing subsequent requests!
// This is something that is baked into the graphql-tools and cannot be avoided another way.
delete info.operation["__runAtMostOnce"];
// Process `graphql-context` plugins
const ctxPlugins = plugins.byType("graphql-context");
for (let i = 0; i < ctxPlugins.length; i++) {
if (typeof ctxPlugins[i].preApply === "function") {
await ctxPlugins[i].preApply(context);
}
}
for (let i = 0; i < ctxPlugins.length; i++) {
if (typeof ctxPlugins[i].apply === "function") {
await ctxPlugins[i].apply(context);
}
? await plugin.middleware({ config })
: plugin.middleware;
if (Array.isArray(middleware)) {
registeredMiddleware.push(...middleware);
} else {
registeredMiddleware.push(middleware);
}
}
config.middleware && registeredMiddleware.push(config.middleware);
if (registeredMiddleware.length) {
schema = applyMiddleware(schema, ...registeredMiddleware);
}
addSchemaLevelResolveFunction(schema, async (root, args, context, info) => {
// Make sure we do not block this resolver from processing subsequent requests!
// This is something that is baked into the graphql-tools and cannot be avoided another way.
delete info.operation["__runAtMostOnce"];
// Process `graphql-context` plugins
const ctxPlugins = getPlugins("graphql-context");
for (let i = 0; i < ctxPlugins.length; i++) {
if (typeof ctxPlugins[i].preApply === "function") {
await ctxPlugins[i].preApply(context);
}
}
for (let i = 0; i < ctxPlugins.length; i++) {
if (typeof ctxPlugins[i].apply === "function") {
await ctxPlugins[i].apply(context);
}
Notification,
Meta,
Invoice,
Search,
],
resolvers,
schemaDirectives: IS_PROD
? {
rateLimit,
}
: {},
});
if (process.env.REACT_APP_MAINTENANCE_MODE === 'enabled') {
console.error('\n\n⚠️ ----MAINTENANCE MODE ENABLED----⚠️\n\n');
addSchemaLevelResolveFunction(schema, () => {
throw new UserError(
"We're currently undergoing planned maintenance. We'll be back soon, please check https://twitter.com/withspectrum for ongoing updates!"
);
});
}
module.exports = schema;
addSchemaResolvers: rootResolveFunction =>
addSchemaLevelResolveFunction(this.schema, rootResolveFunction),
addDirectivesResolvers: directivesResolvers =>
.forEach(({ plugin, schemaLevelResolveFunction }) => {
debug(`added schemaLevelResolveFunction from plugin '${plugin.name}'`);
addSchemaLevelResolveFunction(schema, schemaLevelResolveFunction);
});