npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wahi/apollo-plugins

v1.0.1

Published

Apollo plugins for Nest.js

Downloads

1,439

Readme

Apollo Plugins

A collection of Apollo Server plugins by Wahi to enhance server functionality and provide seamless integrations.

Installation

Using npm:

npm install @wahi/apollo-plugins

Or using Yarn:

yarn add @wahi/apollo-plugins

Features

  • DatadogNestPlugin: Monitors and logs the number of GraphQL requests, tracks and logs the number of GraphQL errors, and logs request durations, highlighting slow requests.

    • Request Metrics: Captures and increments a count of GraphQL requests, tagging them with relevant metadata for Datadog.
    • Error Tracking: Increments an error count in Datadog when a GraphQL request encounters errors, again tagging with relevant metadata.
    • Request Duration: Measures the duration of each GraphQL request, reporting the timing to Datadog. It also logs requests that exceed a specified slow threshold, providing detailed information such as operation type, operation name, variables, and user-agent.
    • Environment Tagging: Automatically tags all metrics with the environment the application is running in, defaulting to 'unknown' if not specified.
    • Slow Request Logging: Identifies slow GraphQL requests (taking more than 1000ms), logging detailed information to assist with debugging and performance optimization.
  • QueryLoggerNestPlugin: The QueryLoggerNestPlugin is a custom Apollo Server plugin designed to enhance logging capabilities for GraphQL requests. It captures and logs detailed information about each GraphQL request, including operation names, types, user IDs, and request IDs. Additionally, it logs errors encountered during the execution of GraphQL operations, providing insights into the nature and source of these errors.

    • Detailed Request Logging: Captures key details about GraphQL requests, such as operation name, operation type (query, mutation, subscription), user ID, and request ID.
    • Error Logging: Logs errors encountered during GraphQL request execution, including error messages, paths, and stack traces. It differentiates between warning and error levels based on the nature of the error.
    • Request Context Preservation: Utilizes express-http-context to maintain a request-scoped context, ensuring that logs can be correlated with specific request instances.
    • Flexible Integration: Designed to work with both Apollo Server and NestJS, making it a versatile choice for a wide range of GraphQL applications.
  • More plugins will be added in the future.

Usage

  1. Import the required plugins from the library.
import { DatadogNestPlugin } from '@wahi/apollo-plugins';
  1. Add DatadogNestPlugin to the providers array in your NestJS module:
@Module({
  // ... other configurations
  providers: [
    DatadogNestPlugin,
    // ... other providers
  ],
})
export class YourModule { };
  1. The plugins will now automatically integrate with your Apollo server instance within your NestJS application.

Configuration

Ensure that the required dependencies and environment settings are correctly configured for the plugins. For instance, the DatadogNestPlugin requires the Datadog agent running in your environment and the necessary environment variables set for communication with Datadog.

Upcoming Plugins

We're continuously working to expand the functionalities offered by our Apollo plugins. Stay tuned for more!

Contributing

Contributions are always welcome! If you have a plugin idea, improvements, or optimizations, please feel free to submit a pull request.

License

MIT License