Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @ts-ignore
req.aclManager,
user,
this.logger,
this.pluginContext,
this.concurrency
);
/**
* This is the main reason to extend, to access graphqlExpress(),
* to be able to modify the schema based on the request
* It binds to our new object, since the parent accesses the schema
* from this.schema etc.
*/
return graphqlExpress(
// @ts-ignore
super.createGraphQLServerOptions.bind({
...serverObj,
graphqlPath: path,
/* Retrieves a custom graphql schema based on request */
schema: roleSchema,
formatError,
introspection: !!user.role,
plugins: [
makeComplexityPlugin(
this.logger,
this.complexitySize,
roleSchema,
user.id
)
],
res.end();
return;
}
}
/* Not necessary, but removing to ensure schema built on the request */
// tslint:disable-next-line
const { schema, ...serverObj } = this;
/**
* This is the main reason to extend, to access graphqlExpress(),
* to be able to modify the schema based on the request
* It binds to our new object, since the parent accesses the schema
* from this.schema etc.
*/
return graphqlExpress(
// @ts-ignore
super.createGraphQLServerOptions.bind({
...serverObj,
graphqlPath: path,
/* Retrieves a custom graphql schema based on request */
schema: makeExecutableSchema({
typeDefs,
resolvers,
inheritResolversFromInterfaces: true,
}),
formatError: utils.formatError,
playground: {
settings: {
'request.credentials': 'include',
}
} as apollo.PlaygroundConfig
app.use(
this.config.graphQLPath,
graphqlUploadExpress({
maxFileSize: this._transformMaxUploadSizeToBytes(
this.parseServer.config.maxUploadSize || '20mb'
),
})
);
app.use(this.config.graphQLPath, corsMiddleware());
app.use(this.config.graphQLPath, bodyParser.json());
app.use(this.config.graphQLPath, handleParseHeaders);
app.use(this.config.graphQLPath, handleParseErrors);
app.use(
this.config.graphQLPath,
graphqlExpress(async req => await this._getGraphQLOptions(req))
);
}