Log operation name for GraphQL query/mutation #949
johannesbraeunig
started this conversation in
Ideas
Replies: 1 comment
-
Hey, @johannesbraeunig. The error message you see is coming from the request client (i.e. I highly recommend configuring the onUnhandledRequest option to warn or error on requests that have no mocks. The message produces by the library in that case will contain the details like operation type and name so you could debug the issue. const server = setupServer(...yourHandlers)
server.listen({
onUnhandledRequest: 'warn' // you may also set "error"
}) Note that this option is set to "warn" by default. If you don't see any warnings, I suspect you're using an older version of |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is your feature request related to a problem? Please describe.
If I have a query/mutation which has no mock, I only see a
Failed to load resource: the server responded with a status of 404 (Not Found)
in the console or in CI.Describe the solution you'd like
I would like to know which query/mutation is the initiator of this request. Therefore my idea is to add the operation name to the error message.
For example, it could look like
Failed to load resource: the server responded with a status of 404 (Not Found), initiator: GetCurrentUsers
GetCurrentUsers
is the query operation name.This would make it easier to debug/find if I have lots of queries and mutations running and a handful is not mocked, for reasons. But sometimes I need to know which queries have no mocks because this could also be an issue.
Maybe this could be turned on/off via a configuration because some users of MSW might don't want to expose this kind of information to services they might use.
Beta Was this translation helpful? Give feedback.
All reactions