Star us on GitHub
Star
Menu
Docs / Getting Started / For your Backend / Apollo Server

Apollo Server

Highlight ships @highlight-run/node with a plugin ApolloServerHighlightPlugin specifically for the apollo server. The plugin will trace graphql resolver errors and report them to Highlight.

Usage

The usage of the Apollo plugin requires the Node.js integration to be configured. Ensure that @highlight-run/node updated to version 2.2.0 or greater. Then, add ApolloServerHighlightPlugin to your ApolloServer plugins definition.

import { ApolloServer } from '@apollo/server' import { ApolloServerHighlightPlugin } from '@highlight-run/node' // ... const server = new ApolloServer({ typeDefs, resolvers, plugins: [ApolloServerHighlightPlugin({ projectID: 'YOUR_PROJECT_ID' })], })
Copy
Usage on Apollo Server v3 (deprecated)

The following example is for the deprecated ApolloServer v3 (importing from apollo-server-express).

import { ApolloServer } from 'apollo-server-express' import { ApolloServerV3HighlightPlugin } from '@highlight-run/node' // ... const server = new ApolloServer({ typeDefs, resolvers, plugins: [ApolloServerV3HighlightPlugin({ projectID: 'YOUR_PROJECT_ID' })], })
Copy
Verify

To validate your Highlight backend setup, you can have a graphql resolver throw an error and check that the error is visible on app.highlight.io.