Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
apollo-server-plugin-base
Advanced tools
The apollo-server-plugin-base package provides an interface for creating plugins that can hook into, modify, or extend the functionality of Apollo Server. These plugins can be used for logging, performance monitoring, validating requests, and more, allowing developers to customize and optimize their GraphQL server.
Server Lifecycle Hooks
Plugins can define lifecycle hooks such as serverWillStart to perform actions during specific phases of the Apollo Server lifecycle. This example logs a message when the server is starting.
const myPlugin = {
serverWillStart(service) {
console.log(`GraphQL Server is starting!`);
}
};
Request Lifecycle Hooks
This feature allows plugins to hook into various phases of a GraphQL request's lifecycle, such as when a request starts or before a response is sent. The example logs the request query and the response.
const myPlugin = {
requestDidStart(requestContext) {
console.log(`Request started! Query:\n${requestContext.request.query}`);
return {
willSendResponse(requestContext) {
console.log(`Response:`, requestContext.response);
}
};
}
};
Error Handling
Plugins can also be used for error handling throughout the request lifecycle. This example logs any GraphQL errors that occur during a request.
const errorLoggingPlugin = {
requestDidStart(requestContext) {
return {
didEncounterErrors(requestContext) {
console.error(`GraphQL Errors:`, requestContext.errors);
}
};
}
};
graphql-middleware is a tool for creating middleware that can be applied to your GraphQL resolvers. It allows for a similar pattern of extending functionality but is focused on the resolver level rather than the entire server lifecycle.
express-graphql is an Express.js middleware designed specifically for executing GraphQL queries. While it doesn't offer a plugin system like Apollo Server, it allows for the integration of GraphQL with Express.js applications, demonstrating a different approach to extending GraphQL server capabilities.
apollo-server-plugin-base
FAQs
Apollo Server plugin base classes
The npm package apollo-server-plugin-base receives a total of 403,828 weekly downloads. As such, apollo-server-plugin-base popularity was classified as popular.
We found that apollo-server-plugin-base demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.