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

@makerx/graphql-apollo-server

v1.3.0

Published

A set of MakerX plugins for Apollo Server

Downloads

277

Readme

GraphQL Apollo Server

A set of MakerX plugins for Apollo Server

GraphQL operation logging plugin

graphqlOperationLoggingPlugin logs GraphQL operations using the logger from the GraphQL context.

Logging is performed via the willSendResponse and willSendSubsequentPayload hooks, which will run for all query, mutation and subscription operations (including those with errors).

Logging of context creation failure can be enabled by supplying a logger to the contextCreationFailureLogger option.

Options

  • logLevel: the log level to use (default: info)
  • ignoreIntrospectionQueries: if true, introspection queries will not be logged (default: true)
  • contextCreationFailureLogger: The plugin does not have access to a logger prior to context creation, so if you wish to log context creation failures, supply a logger here (it will only be called for context creation failure).
  • contextCreationDidFail: If you wish to custom log or otherwise react to context creation failures, supply a handler for the plugin contextCreationDidFail hook (this will be called instead of logging to contextCreationFailureLogger).
  • shouldIgnore: an optional callback that can be used to ignore certain operations, e.g. if you have a healthcheck operation that you prefer not to be logged.
  • includeResponseData: if true, the operation's result.data will be included in the log output (default: false)
  • includeMutationResponseData: if true, the operation's result.data will be included in the log output for mutations only (default: false)
  • adjustVariables: an optional callback that can be used to adjust the operation's variables before logging
  • adjustResultData: an optional callback that can be used to adjust the operation's result.data before logging
const plugins: ApolloServerPlugin<GraphQLContext>[] = [
  graphqlOperationLoggingPlugin<GraphQLContext, Logger>({
    logLevel: 'audit',
    contextCreationFailureLogger: logger,
    includeMutationResponseData: true,
    adjustVariables: (variables) => pruneKeys(variables, 'headers'),
  }),
]

Output includes:

  • type: the GraphQL operation type: query, mutation or subscription
  • operationName: the optional operation name
  • query: the formatted operation
  • duration: milliseconds taken to process the operation from context creation to willSendResponse hook
  • variables: the optional operation variables, optionally adjusted by the adjustVariables callback
  • result.errors: the operation's GraphQLFormattedError[], if any
  • result.data: the operation's data result, if includeResponseData is true or includeMutationResponseData is true and the operation is a mutation, optionally adjusted by the adjustResultData callback
  • isIncrementalResponse: true if the operation is part of an incremental delivery response (@defer or @stream)
  • isSubsequentPayload: true if the operation is a subsequent payload of an incremental delivery response

Introspection Control Plugin

introspectionControlPlugin implements a standard pattern of rejecting unauthorized introspection requests in production.

  • Unauthorized requests are those that do not have a user set on the GraphQL context.
  • Production is determined according to NODE_ENV === 'production' via node-common