-
-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Environment
- Operating System: Darwin
- Node Version: v22.14.0
- Nuxt Version: 3.17.2
- CLI Version: 3.25.0
- Nitro Version: 2.11.11
- Package Manager: pnpm@9.15.2
- Builder: -
- User Config: compatibilityDate, devtools, modules, app, shadcn, runtimeConfig, graphql-client
- Runtime Modules: @nuxtjs/tailwindcss@6.14.0, @nuxt/icon@1.12.0, shadcn-nuxt@0.10.4, @pinia/nuxt@0.5.5, nuxt-graphql-client@0.2.46, @nuxt/image@1.10.0, pinia-plugin-persistedstate@4.2.0
- Build Modules: -
Describe the bug
Bug Report: err.gqlErrors
is empty despite server response containing errors
Description
I'm encountering an issue where the err.gqlErrors
array is always empty, even though the server's response includes a properly formatted errors
array.
Steps to Reproduce
- Make a GraphQL request that triggers an error.
- Observe the response from the server. Example response:
{ "errors": [ { "message": "login-error: Please retry after several minute", "locations": [ { "line": 3, "column": 3 } ], "path": [ "token" ], "extensions": { "code": "INTERNAL_SERVER_ERROR", "stacktrace": [ "Error: login-error: Please retry after several minute", " at AuthService.login (/path/to/auth.service.ts:76:13)", " at processTicksAndRejections (node:internal/process/task_queues:105:5)" ] } } ], "metadata": { "request_id": "763229af-ff11-4fc6-bbba-bdb0ff77b2b0" } }
- Handle errors using the
useGqlError
composable, and logerr.gqlErrors
. The array is empty.
Expected Behavior
The err.gqlErrors
array should contain the errors
field from the server response.
Actual Behavior
The err.gqlErrors
array is empty.
Investigation
I have followed the recommendations provided in the documentation and ensured that:
- The server response includes a valid
errors
field. - The client-side error handler is configured correctly.
- Network and parsing issues have been ruled out.
I suspect this issue might be related to how graphql-request
(the parent library) processes or parses errors. It seems that the error response is not being properly passed to nuxt-graphql-client
.
Is there any additional configuration or workaround I can implement to fix this issue? If the issue is indeed related to graphql-request
, could you guide me on how to proceed?
Thank you for your help!
Expected behaviour
I expect the gqlErrors array is not empty
Reproduction
No response
Additional context
Below is the error handling configuration used:
export default defineNuxtPlugin(() => {
useGqlError((err) => {
console.error('GraphQL Error:', err);
console.error('GqlErrors:', err.gqlErrors); // This is empty
});
});