Apollo server plugins

Apollo server plugins DEFAULT

New in Apollo Server 3: All plugin lifecycle methods are , except for and .

You can create your own Apollo Server plugins to perform custom operations in response to certain events. For example, a basic logging plugin might log the GraphQL query string associated with each request that's sent to Apollo Server.

The anatomy of a plugin

Plugins are JavaScript objects that implement one or more functions that respond to events. Here's a basic plugin that responds to the event:

index.js

If you're using TypeScript to create a plugin, the module exports the interface for plugins to implement.

You can define a plugin in the same file where you initialize Apollo Server, or you can export it as a separate module:

myplugin.js

To create a plugin that accepts options, create a function that accepts an object and returns a properly structured plugin object, like so:

myplugin.js

Responding to events

A plugin specifies exactly which events it responds to by implementing functions that correspond to those events. The plugin in the examples above responds to the event, which fires when Apollo Server is preparing to start up. Almost all plugin events are functions (i.e., functions that return s). The only exceptions are and .

A plugin can respond to any combination of supported events.

Responding to request lifecycle events

Plugins can respond to the following events associated with the GraphQL request lifecycle:

However, the way you define these functions is slightly different from the example above. First, your plugin must define the function:

The event fires whenever Apollo Server receives a GraphQL request, before any of the lifecycle events listed above. You can respond to this event just like you respond to , but you also use this function to define responses for a request's lifecycle events, like so:

As shown, the function can optionally return an object that defines functions that respond to request lifecycle events. This structure organizes and encapsulates all of your plugin's request lifecycle logic, making it easier to reason about.

Request lifecycle event flow

The following diagram illustrates the sequence of events that fire for each request. Each of these events is documented in Apollo Server plugin events.

Important: Any event below that can result in "Success" can also result in an error. Whenever an error occurs, the event fires and the remainder of the "Success" path does not.

*The indicated events also support end hooks that are called when their associated step completes.

End hooks

Event handlers for the following events can optionally return a function that is invoked after the corresponding lifecycle phase ends:

( returns an object containing an function instead of just a function as an end hook. This is because the returned object can also contain .)

Just like the event handers themselves, these end hooks are async functions (except for the end hook for ).

End hooks are passed any errors that occurred during the execution of that lifecycle phase. For example, the following plugin logs any errors that occur during any of the above lifecycle events:

Note that the end hook receives an array of errors that contains every validation error that occurred (if any). The end hook receives the error thrown by the resolver as the first argument and the result of the resolver as the second argument. The arguments to each end hook are documented in the type definitions in Request lifecycle events.

Inspecting request and response details

As the example above shows, and request lifecycle functions accept a parameter. This parameter is of type , which includes a (of type ), along with a field (of type ) if it's available.

These types and their related subtypes are all defined in .

Installing custom plugins

Add your plugins to Apollo Server by providing a configuration option to the constructor, like so:

Sours: https://www.apollographql.com/docs/apollo-server/integrations/plugins/

New Relic Apollo Server plugin Apollo Server Plugin CI

Community Plus header

New Relic's official Apollo Server plugin for use with the Node.js agent.

This plugin expects the Node.js agent newrelic npm package has already been installed in your application.

Installation

// index.jsconstplugin=require('@newrelic/apollo-server-plugin')// imported from supported moduleconstserver=newApolloServer({ typeDefs, resolvers,plugins: [plugin]})

Getting started

The exports a function that does accept limited configuration. Since Apollo Server will invoke any function passed to plugins, invoking this yourself is not required unless you plan to override specific configuration.

To use the plugin without specific configuration, you can pass the function in directly similar to:

// index.jsconstplugin=require('@newrelic/apollo-server-plugin')// imported from supported moduleconstserver=newApolloServer({ typeDefs, resolvers,plugins: [plugin]})

Usage

The New Relic plugin is known to work with the following Apollo Server modules:

  • apollo-server
  • apollo-server-express
  • apollo-server-hapi
  • apollo-server-koa
  • apollo-server-fastify
  • apollo-server-lambda

Note: Because fastify is not fully instrumented in the Node.js Agent, transactions will be prefixed with .

Other plugins may work, depending on their underlying implementation, but have not been verified.

Interaction with other Apollo Plugins

Transaction and segment/span timings may be affected by other plugins used in the Apollo Server setup. In order to get more accurate resolver timings, it is recommended to add the New Relic plugin last.

constserver=newApolloServer({ typeDefs, resolvers,plugins: [other_plugin,newrelic_plugin]})

Configuration

Configuration may be passed into the function to override specific values. To override configuration, invoke the function prior to passing to Apollo Server. The configuration object and all properties are optional.

constplugin=createPlugin({captureScalars: true,captureIntrospectionQueries: true,captureServiceDefinitionQueries: true,captureHealthCheckQueries: true})
  • Enable capture of timing of fields resolved with the return type. This may be desired when performing time intensive calculations to return a scalar value. This is not recommended for queries that return a large number of pre-calculated scalar fields.

    NOTE: query/mutation resolvers will always be captured even if returning a scalar type.

  • Enable capture of timings for an IntrospectionQuery.

  • Enable capture of timings for a Service Definition query received from an Apollo Federated Gateway Server.

  • Enable capture of timings for a Health Check query received from an Apollo Federated Gateway Server.

Apollo Federation Support

The New Relic plugin will work with an Apollo Federated Server out of the box. Just pass the plugin to the Federated Gateway Apollo Server. With the federated server you will get:

  • Distributed Tracing support
  • Transaction naming
  • Operation naming
  • Metrics

Resolver spans are not supported for the Federated Gateway Server. We strongly recommend adding the plugin to your sub-graph servers which will generate all the data you get with the Federated Server as well as resolver spans.

// Federated Gateway Server index.jsconstplugin=require('@newrelic/apollo-server-plugin')constgateway=newApolloGateway({serviceList: [{name: 'server1',url: SERVER_1_URL},{name: 'server2',url: SERVER_2_URL}]});constserver=newApolloServer({ gateway,plugins: [plugin]});
// Sub-Graph server index.jsconst{ buildFederatedSchema }=require('@apollo/federation');constplugin=require('@newrelic/apollo-server-plugin')constserver=newApolloServer({schema: buildFederatedSchema([{ typeDefs, resolvers }]),plugins: [plugin]});

NOTE: and are currently 0.x versions and may break with future versions prior to 1.x release from Apollo.

Transactions

Transaction Documentation

Transactions are captured as web transactions, associated with the underlying framework (Express, Koa, etc.), and named based on the GraphQL operations executed.

Here's an example query and how that may be represented in NR One.

For more information on how transactions are named, including how query errors may impact naming, please see the transaction documentation.

Metrics

Metrics Documentation

Two new metrics have been introduced to understand the behavior of your GraphQL operations within and across transactions.

Operation Metrics

Operation metrics are very similar to how transaction names are constructed including the operation type, operation name and deepest unique path. These metrics represent the durations of the individual queries or mutations and can be used to compare outside of the context of individual transactions which may have multiple queries.

If you would like to have a list of the top 10 slowest operations, the following query can be used to pull the data on demand or as a part of a dashboard. The 'Bar' chart type is a recommended visualization for this query.

Field Resolve Metrics

Resolve metrics capture the duration spent resolving a particular piece of requested GraphQL data. These can be useful to find specific resolvers that may contribute to slowing down incoming queries.

If you would like to have a list of the top 10 slowest resolves, the following query can be used to pull the data on demand or as a part of a dashboard. The 'Bar' chart type is a recommended visualization for this query.

For more information on metrics and some recommended visualizations, please see the metrics documentation.

Segments and Spans

Segments and Spans

Segments and spans (when Distributed Tracing enabled) are captured for GraphQL operations, field resolution and additional work (when instrumented) that occurs as a part of field resolution such as making a query to a database.

Operation Segments/Spans

Operation segments/spans include the operation type, operation name and deepest unique path. These represent the individual duration and attributes of a specific invocation within a transaction or trace.

The operation type and operation name are captured as attributes on a segment or span as well as the query with obfuscated arguments.

For more information on collected attributes, see the segments and spans documentation

Field Resolve Segments/Spans

Resolve segments/spans leverage the resolution path of the individual field to best differentiate within a given trace or transaction. For example, might be used instead of just . These represent the individual duration and attributes of a specific field being resolved as a part of the GraphQL operation.

The field name, return type, parent type, path and arguments (disabled by default) are all captured as attributes.

For more information on collected attributes, including enabling args capture, see the segments and spans documentation

Errors

The agent will notice GraphQL errors that get sent back to the client.

Depend on where the error was thrown, these will be associated with either the operation span or the specific field resolve span (Distribute Tracing enabled) to enable further debugging of issues.

Testing

The module includes a suite of unit and functional tests which should be used to verify that your changes don't break existing functionality.

All tests are stored in and are written using Tap with the extension .

To run the full suite, run: .

Individual test scripts include:

Support

Should you need assistance with New Relic products, you are in good hands with several support diagnostic tools and support channels.

This troubleshooting framework steps you through common troubleshooting questions.

New Relic offers NRDiag, a client-side diagnostic utility that automatically detects common problems with New Relic agents. If NRDiag detects a problem, it suggests troubleshooting steps. NRDiag can also automatically attach troubleshooting data to a New Relic Support ticket. Remove this section if it doesn't apply.

If the issue has been confirmed as a bug or is a feature request, file a GitHub issue.

Support Channels

Privacy

At New Relic we take your privacy and the security of your information seriously, and are committed to protecting your information. We must emphasize the importance of not sharing personal data in public forums, and ask all users to scrub logs and diagnostic information for sensitive information, whether personal, proprietary, or otherwise.

We define “Personal Data” as any information relating to an identified or identifiable individual, including, for example, your name, phone number, post code or zip code, Device ID, IP address, and email address.

For more information, review New Relic’s General Data Privacy Notice.

Contribute

We encourage your contributions to improve the New Relic Apollo Server plugin! Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.

If you have any questions, or to execute our corporate CLA (which is required if your contribution is on behalf of a company), drop us an email at [email protected]

If you would like to contribute to this project, review these guidelines.

To all contributors, we thank you! Without your contribution, this project would not be what it is today. We also host a community project page dedicated to the New Relic Apollo Server plugin.

A note about vulnerabilities

As noted in our security policy, New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.

If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through HackerOne.

License

The New Relic Apollo Server plugin is licensed under the Apache 2.0 License.

The New Relic Apollo Server plugin also uses source code from third-party libraries. You can find full details on which libraries are used and the terms under which they are licensed in the third-party notices document.

Sours: https://github.com/newrelic/newrelic-node-apollo-server-plugin
  1. Wall shelves oak
  2. Scratch tmnt figure
  3. Drawing poses male
  4. Killing stalking chapter 14

This API reference documents built-in plugins that add a landing page to Apollo Server's base URL, enabling visitors to interact with the server from their browser.

This includes plugins for:

These plugins work by implementing the plugin event, which serves an HTML page whenever a browser includes an header. Aside from these, you can also create a custom plugin that renders a custom landing page.

Default behavior

If you don't manually install any plugin that implements , Apollo Server does the following by default:

  • In non-production environments ( is not ), Apollo Server installs .
  • In production environments (is), Apollo Server installs .

In either case, Apollo Server provides no configuration options to the plugin. You only need to install one of these plugins manually if you want to override its default configuration.

Configuring default landing pages

To configure these default plugins while still using same -based logic, import them from the package and pass them to the constructor in the array:

Available configuration options are listed in each plugin's reference below.

Default non-production landing page

The plugin shows a landing page welcoming you to Apollo Server:

Apollo Server default landing page

This landing page is designed for use in local development, where is not set to . It provides a copyable command-line snippet showing how to run operations via , and it also links to Apollo Sandbox (a hosted GraphQL IDE that runs entirely inside your browser and doesn't require an account).

Options

Name /
Type
Description

By default, this plugin uses the latest version of the landing page published to Apollo's CDN. If you'd like to pin the current version, you can specify it here.

The current latest version is available at this link.

By default, the landing page displays a footer that links to the documentation telling you how to configure it. To remove this footer, pass .

Default production landing page

The shows a minimalist landing page:

Apollo Server default landing page

This landing page is designed for use in production. It provides a copyable command-line snippet showing how to run operations with your server. By default, the only visible reference to Apollo is a footer explaining how to customize the page. You can also configure it to add a link to query your graph with the Apollo Studio Explorer.

Options

Name /
Type
Description

By default, this plugin uses the latest version of the landing page published to Apollo's CDN. If you'd like to pin the current version, you can specify it here.

The current latest version is available at this link.

By default, the landing page displays a footer that links to the documentation telling you how to configure it. To remove this footer, pass .

If provided, the landing page includes a link (with opt-in auto-redirect) to the Apollo Studio page for the graph with the corresponding graph ref. An example graph ref is .

To enable this link, you need to provide here even if you already provide it elsewhere for usage reporting and other purposes. This is because if your server is publicly accessible, you might not want to display the graph ref publicly.

GraphQL Playground landing page

The plugin serves the GraphQL Playground IDE as a landing page.

Note: The GraphQL Playground project is retired in favor of GraphiQL. This functionality is provided to help developers migrating from Apollo Server 2.

The GraphQL Playground plugin is not installed by default. To install it, import it from and provide it to the constructor:

This plugin takes the same arguments as the function from the package (or specifically, the fork).

The table below mentions a few of the more common options and is not exhaustive.

Options

Name /
Type
Description

By default, this plugin loads a specific npm version of from a CDN. The version is hard-coded in and is typically incremented when new versions of the Playground fork are released (this is rare because the project is retired).

You can specify a different version here.

By default, GraphQL Playground connects to a GraphQL server hosted at the same URL as Playground itself. To specify a different GraphQL endpoint, use this option.

If specified, allows you to override the default values of GraphQL Playground's settings. Documentation of supported settings is available in GraphQL Playground's README.

Disabling the landing page

The plugin serves no landing page from Apollo Server's base URL. Install it to disable the default landing page in some or all environments:

This plugin takes no arguments.

Sours: https://www.apollographql.com/docs/apollo-server/api/plugin/landing-pages/
Apollo Server Express - Part 1 - Server Setup

Privacy Preference Center

When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information

Manage Consent Preferences

These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.

These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.

These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.

These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising.

Sours: https://www.apollographql.com/docs/apollo-server/builtin-plugins/

Plugins apollo server

New in Apollo Server 3: All plugin lifecycle methods are , except for and .

This reference describes the lifecycle events that your custom Apollo Server plugin can respond to.

Apollo Server fires two types of events that plugins can hook into: server lifecycle events and request lifecycle events.

  • Server lifecycle events are high-level events related to the lifecycle of Apollo Server itself (e.g., ).
  • Request lifecycle events are associated with the lifecycle of a specific request.

With two exceptions, all plugin methods in Apollo Server 3 are . The first exception is , which is called much more frequently than other plugin methods. The second exception is , where making the method would introduce unclear ordering semantics around method executions.

Server lifecycle events

The event fires when Apollo Server is preparing to start serving GraphQL requests. The server doesn't start until this asynchronous method completes. If it throws (i.e., if the it returns is rejected), startup fails and your server does not serve GraphQL operations. This helps you make sure all of your server's dependencies are available before attempting to begin serving requests.

This event is fired at different times depending on which Apollo Server middleware you're using:

  • In , it's fired from the method.
  • In non-serverless middleware libraries like , it's fired from the method.
  • In serverless middleware libraries like , it's fired in response to the first incoming request.

Example

The event fires when Apollo Server is starting to shut down because has been invoked (either explicitly by your code, or by one of the termination signal handlers). While handlers run, GraphQL operations can still execute successfully. This hook is designed to allow you to stop accepting new connections and close existing connections. Apollo Server has a built-in plugin which uses this event to drain a Node .

You define your handler in the object returned by your handler, because the two handlers usually interact with the same data. Currently, handlers do not take arguments (this might change in the future).

Example

The event fires when Apollo Server is starting to shut down because has been invoked (either explicitly by your code, or by one of the termination signal handlers). If your plugin is running any background tasks, this is a good place to shut them down.

You define your handler in the object returned by your handler, because the two handlers usually interact with the same data. Currently, handlers do not take arguments (this might change in the future).

When your handler is called, Apollo Server is in a state where it will no longer start to execute new GraphQL operations, so it's a good place to flush observability data. If you are looking for a hook that runs while operations can still execute, try .

Example

This event enables you to serve a custom landing page from Apollo Server's base URL. The event is fired once by Apollo Server after all events run. At most one installed plugin can define a handler. Otherwise, Apollo Server throws an error on startup.

You define your plugin's handler in the object returned by your handler, which enables it to read values passed to :

index.js

The handler should return an object with a string field. The value of that field is served as HTML for any requests with headers.

For more landing page options, see Changing the landing page.

Example

The event fires whenever Apollo Server begins fulfilling a GraphQL request.

This function can optionally return an object that includes functions for responding to request lifecycle events that might follow .

If your plugin doesn't need to respond to any request lifecycle events, should not return a value.

The event fires whenever Apollo Server initially loads the schema or updates the schema. A handler is given the new API schema and optionally the new core schema (if using a gateway). If you provide a gateway and it is older than , attempting to register a handler will fail.

is a synchronous plugin API (i.e., it does not return a ).

Example

Request lifecycle events

If you're using TypeScript to create your plugin, implement the interface from the module to define functions for request lifecycle events.

When Apollo Server processes a request, these events fire in the order listed (with the exception of , which might fire in one of a few places depending on when errors occur). See the flow diagram

Note that not every event fires for every request (for example, doesn't fire for an operation that Apollo Server has cached and doesn't need to parse again).

The event is invoked after Apollo Server has determined the -representation of the incoming operation that it will act upon. In the event that this was not directly passed in from the client, this may be retrieved from a cache store (e.g., Automated Persisted Queries).

At this stage, there is not a guarantee that the operation is not malformed.

The event fires whenever Apollo Server will parse a GraphQL request to create its associated AST.

If Apollo Server receives a request with a query string that matches a previous request, the associated might already be available in Apollo Server's cache. In this case, is not called for the request, because parsing does not occur.

The event fires whenever Apollo Server will validate a request's AST against your GraphQL schema.

Like , this event does not fire if a request's is already available in Apollo Server's cache (only successfully validated s are cached by Apollo Server).

The AST is guaranteed to be available at this stage, because parsing must succeed for validation to occur.

The event fires after the library successfully determines the operation to execute from a request's AST. At this stage, both the string and AST are available.

This event is not associated with your GraphQL server's resolvers. When this event fires, your resolvers have not yet executed (they execute after ).

If the operation is anonymous (i.e., the operation is instead of ), then is .

The event is fired immediately before GraphQL execution would take place. If its return value resolves to a non-null , that result is used instead of executing the query. Hooks from different plugins are invoked in series, and the first non-null response is used.

The event fires whenever Apollo Server begins executing the GraphQL operation specified by a request's AST.

may return an object with one or both of the methods and . is treated like an end hook: it is called after execution with any errors that occurred. is documented in the next section. (In Apollo Server 2, could return also return an end hook directly.)

The event fires whenever Apollo Server is about to resolve a single field during the execution of an operation. The handler is passed an object with four fields (, , , and ) that correspond to the four positional arguments passed to resolvers. (Note that corresponds to the argument often called in these docs.)

You provide your handler in the object returned by your handler.

Your handler can optionally return an "end hook" function that's invoked with the resolver's result (or the error that it throws). The end hook is called when your resolver has fully resolved (e.g., if the resolver returns a Promise, the hook is called with the Promise's eventual resolved result).

and its end hook are synchronous plugin APIs (i.e., they do not return s).

Example

The event fires when Apollo Server encounters errors while parsing, validating, or executing a GraphQL operation.

The event fires whenever Apollo Server is about to send a response for a GraphQL operation. This event fires (and Apollo Server sends a response) even if the GraphQL operation encounters one or more errors.

Sours: https://www.apollographql.com/docs/apollo-server/integrations/plugins-event-reference/
GraphQL Tutorial #3: Apollo Server and Resolvers

Configuring which data is sent to Apollo Studio

Provide this object to configure which GraphQL variable values are included in trace data that's sent to Apollo Studio. Valid options are described in Valid object signatures.

The default value is , which means no variable values are sent to Studio. This is a security measure to prevent sensitive data from potentially reaching Apollo servers.

Provide this object to configure which request header names and values are included in trace data that's sent to Apollo Studio. Valid options are described in Valid object signatures.

The default value is , which means no header names or values are sent to Studio. This is a security measure to prevent sensitive data from potentially reaching Apollo servers.

Specify this function to modify GraphQL operation errors before Apollo Server reports those errors to Apollo Studio. The function takes a object and must also return one (or to prevent Apollo Server from reporting a particular error entirely).

The only properties of the reported error you can modify are its and its .

Note: If this instance is acting as the gateway in an Apollo Federation architecture, this option does not modify errors that originate in subgraphs. To modify those errors, instead configure the option in the inline trace plugin, which you install in the subgraph's instance.

Specify this asynchronous function to configure which requests are included in usage reports sent to Apollo Studio. For example, you can omit requests that execute a particular operation or requests that include a particular HTTP header.

This function is called for each received request. It takes a object and must return a that indicates whether to include the request. It's called either after the operation is successfully resolved (via the event), or when sending the final error response if the operation was not successfully resolved (via the event).

By default, all requests are included in usage reports.

Specify this function to provide Apollo Studio with client details for each processed request. Apollo Studio uses this information to segment metrics by client.

This function is passed a object containing all available information about the request. It should return an object with and fields that identify the associated client.

By default, the plugin attempts to obtain these values from the incoming request's HTTP headers (specifically, and ).

If you're using the option with the schema reporting plugin (), you should provide the same value for this option. This ensures that the schema ID associated with a request in this plugin's usage reports matches the schema ID that the other plugin reports.

Statistics about operations that your server cannot execute are not reported under each document separately to Apollo Studio, but are grouped together as "parse failure", "validation failure", or "unknown operation name". By default, the usage reporting plugin does not include the full operation document in reported traces, because it is challenging to strip potential private information (like string constants) from invalid operations. If you'd like the usage reporting plugin to send the full operation document and operation name so you can view it in Apollo Studio's trace view, set this to true.

Configuring communication protocol

If , the plugin sends a usage report to Apollo Studio after every request instead of sending batched reports.

This option is useful for stateless environments like Amazon Lambda where processes terminate after handling a small number of requests.

The default value is when using an subclass for a serverless framework (Amazon Lambda, Google Cloud Functions, or Azure Functions) and otherwise.

Note that "immediately" does not mean synchronously with completing the response, but rather "very soon", such as after a call.

or or

An HTTP(S) agent to use for reporting. Can be either an or an . It behaves the same as the parameter to .

Specifies which Fetch API function implementation to use when sending usage reports.

The interval at which Apollo Server should send batched trace reports to Studio, in milliseconds.

Regardless of this value, Apollo Server sends a trace report whenever the size of a pending batch exceeds the value of (default 4MB).

Apollo Server sends a trace report whenever the size of a pending batched trace report exceeds this value (in bytes), regardless of its standard reporting interval.

Note that this is a rough limit that includes the size of serialized traces and signatures. It ignores the size of the report's header and some other top-level bytes.

The default value is 4MB ().

The maximum number of times Apollo Server should attempt to report each trace report, performing exponential backoff between attempts.

The default value is .

The minimum amount of backoff (in milliseconds) Apollo Server should perform before retrying a failed trace report.

The default value is .

If you provide this object, the plugin sends it all log messages related to Apollo Studio communication, instead of sending them to the default logger. The object must implement all methods of the interface.

If you provide this function, the plugin calls it whenever it encounters an error while reporting usage data. The details of the error are passed to the function.

By default, the plugin logs these errors to its specified . Unlike the , this function receives the actual object instead of only an error message.

Internal and non-recommended options

The URL base that the plugin sends reports to (not including the path). This option only needs to be set for testing and Apollo-internal uses.

If set, prints all reports as JSON when they are sent. (Note that for technical reasons, traces embedded in a report are printed separately when they are added to a report.)

Specify this function to create a signature for a query. This option is not recommended, because Apollo's servers make assumptions about how the signature relates to the operation you executed.

Sours: https://www.apollographql.com/docs/apollo-server/api/plugin/usage-reporting/

You will also like:

Apollo Server plugin and Node.js

The New Relic Apollo Server plugin instruments your Apollo Server applications to give visibility into your GraphQL payloads. This helps you uncover and diagnose the cause of your slow GraphQL queries.

Our plugin records overall timings for queries and uses distributed tracing to uncover the route problem. Use this instrumentation to see if the problem arises from resolving a piece of requested data or if it stems from work done on other services or databases.

Compatibility

The New Relic plugin works with the following Apollo Server modules:

    Because is not fully instrumented in the Node.js agent, transactions are prefixed with .

    Other plugins may work, depending on their underlying implementation, but they have not been verified.

    GitHub documentation

    For detailed information about installation, configuration, transaction details, metrics, segments, errors, testing, troubleshooting, and more, see New Relic's Apollo Server plugin documentation on GitHub.

    For more help

    If you need more help, check out these support and learning resources:

    Sours: https://docs.newrelic.com/docs/agents/nodejs-agent/extend-your-instrumentation/apollo-server-plugin-nodejs/


    742 743 744 745 746