Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

monitoring(docs,content api): send resolver errors to sentry (#36308)

Charis54f809129dbd
diff --git a/apps/docs/resources/error/errorResolver.ts b/apps/docs/resources/error/errorResolver.ts
index f645d6fee81..6cced106600 100644
--- a/apps/docs/resources/error/errorResolver.ts
+++ b/apps/docs/resources/error/errorResolver.ts
@@ -1,3 +1,4 @@
+import * as Sentry from '@sentry/nextjs'
import { GraphQLError, GraphQLNonNull, GraphQLResolveInfo, GraphQLString } from 'graphql'
import type {
ErrorCollection,
@@ -47,6 +48,9 @@ async function resolveSingleError(
(data) => data,
(error) => {
console.error(`Error resolving ${GRAPHQL_FIELD_ERROR_GLOBAL}:`, error)
+ if (!error.isUserError()) {
+ Sentry.captureException(error)
+ }
return new GraphQLError(error.isPrivate() ? 'Internal Server Error' : error.message)
}
)
@@ -97,6 +101,9 @@ async function resolveErrors(
(data) => data as ErrorCollection,
(error) => {
console.error(`Error resolving ${GRAPHQL_FIELD_ERRORS_GLOBAL}:`, error)
+ if (error instanceof ApiError && !error.isUserError()) {
+ Sentry.captureException(error)
+ }
return error instanceof GraphQLError
? error
: new GraphQLError(error.isPrivate() ? 'Internal Server Error' : error.message)
diff --git a/apps/docs/resources/globalSearch/globalSearchResolver.ts b/apps/docs/resources/globalSearch/globalSearchResolver.ts
index 6b63f3da7d7..238f567c97d 100644
--- a/apps/docs/resources/globalSearch/globalSearchResolver.ts
+++ b/apps/docs/resources/globalSearch/globalSearchResolver.ts
@@ -1,3 +1,4 @@
+import * as Sentry from '@sentry/nextjs'
import {
GraphQLError,
GraphQLInt,
@@ -36,6 +37,9 @@ async function resolveSearch(
async (data) => (await GraphQLCollectionBuilder.create({ items: data })).unwrap(),
(error) => {
console.error(`Error resolving ${GRAPHQL_FIELD_SEARCH_GLOBAL}:`, error)
+ if (!error.isUserError()) {
+ Sentry.captureException(error)
+ }
return new GraphQLError(error.isPrivate() ? 'Internal Server Error' : error.message)
}
)