-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
195 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'backend': minor | ||
--- | ||
|
||
apollo v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { captureException } from '@sentry/node'; | ||
import { ApolloServerPlugin } from '@apollo/server'; | ||
import { ResolverContext } from '../gql/resolver-context'; | ||
|
||
export const apolloSentryPlugin: ApolloServerPlugin<ResolverContext> = { | ||
async requestDidStart({ request }) { | ||
return { | ||
// This will send any errors captured by Apollo Server to Sentry | ||
async didEncounterErrors(ctx) { | ||
for (const err of ctx.errors) { | ||
// Ignore syntax errors | ||
if ( | ||
[ | ||
'GRAPHQL_PARSE_FAILED', | ||
'GRAPHQL_VALIDATION_FAILED', | ||
'BAD_USER_INPUT', | ||
'ACCOUNT_ADDRESS_REQUIRED', | ||
'ACCESS_DENIED', | ||
'NOT_FOUND', | ||
].includes(err.extensions?.code as string) | ||
) { | ||
continue; | ||
} | ||
|
||
// Ignore specific errors | ||
if (err.message && err.message === 'SOR queryBatchSwap failed') { | ||
continue; | ||
} | ||
|
||
// Potentially set transaction name to the operation name, | ||
// add tags and fingerprint to group errors | ||
|
||
// Sentry.withScope((scope) => { | ||
// let name = request.operationName; | ||
// if (!name) { | ||
// name = request.query | ||
// ?.substring( | ||
// request.query?.indexOf('{') + 1, | ||
// request.query?.indexOf('(') || request.query?.length, | ||
// ) | ||
// .replace(/\n/g, '') | ||
// .replace(/\s/g, ''); | ||
// } | ||
// scope.setTransactionName(`POST /graphql ${name}`); | ||
// Sentry.captureException(err); | ||
// }); | ||
|
||
captureException(err); | ||
} | ||
}, | ||
async willSendResponse({}) {}, | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.