From f0ffcf3a3fd51119429e62bfafa2a32d4eb93753 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 17:54:59 +0300 Subject: [PATCH] feat(globals): console debug message (#187) * style(github): format * feat(blog): log on query * style(ui): format * fix(blog): prepack script * feat(blog): logs on queries * refactor(blog): back server queries to stock * feat(globals): add error-link * refactor(globals): console.log to console.debug * fix(globals): apollo log * feat(globals): console debug message * feat(site): trigger build --- .../src/getters/apollo-error-link.getter.ts | 19 +++++++++++-------- site/app/next.config.js | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/globals/data/src/getters/apollo-error-link.getter.ts b/globals/data/src/getters/apollo-error-link.getter.ts index 27dd85ac..4d71d7d3 100644 --- a/globals/data/src/getters/apollo-error-link.getter.ts +++ b/globals/data/src/getters/apollo-error-link.getter.ts @@ -1,26 +1,29 @@ -import type { ApolloLink } from '@apollo/client' -import type { ErrorResponse } from '@apollo/client/link/error' +import type { ApolloLink } from '@apollo/client' +import type { GraphQLFormattedError } from 'graphql' -import { onError } from '@apollo/client/link/error' +import { onError } from '@apollo/client/link/error' export const getApolloErrorLink = (): ApolloLink => { const errorLink = onError((errorResponse) => { - const extendedErrorResponse = errorResponse as unknown as ErrorResponse & { + const extendedErrorResponse = errorResponse as unknown as { + graphQLErrors: Array cause?: Record } const { graphQLErrors, cause } = extendedErrorResponse if (graphQLErrors) { - graphQLErrors.forEach(({ message, locations, path, extensions }) => { - console.debug(`[GraphQL error]: Message: ${message}`) + graphQLErrors.forEach(({ debugMessage, message, locations, path, extensions }) => { + console.debug(`DebugMessage: ${debugMessage}`) + console.debug(`Message: ${message}`) console.debug(`Location:`, locations) console.debug(`Path:`, path) console.debug(`Extenstions:`, extensions) }) } if (cause) { - const { message, extensions, locations, path } = cause - console.debug(`Cause: ${message}`) + const { debugMessage, message, extensions, locations, path } = cause + console.debug(`DebugMessage: ${debugMessage}`) + console.debug(`Message: ${message}`) console.debug(`Location:`, locations) console.debug(`Path:`, path) console.debug(`Extenstions:`, extensions) diff --git a/site/app/next.config.js b/site/app/next.config.js index f641f53e..8a390c23 100644 --- a/site/app/next.config.js +++ b/site/app/next.config.js @@ -24,6 +24,7 @@ const nextConfig = { }, ], }, + experimental: { instrumentationHook: true, externalDir: true,