question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

REST query is mistaken for GraphQL query and can't be intercepted (throws an error)

See original GitHub issue

Environment

Name Version
msw 0.28.2
browser Chrome
OS Mac OS X Catalina

Request handlers

no request handler for the following rest request

https://api.dev/artists?query=Petit+Biscuit&page=0&limit=5&workspaceId=ce54f030-2191-40b1-8b2a-cd5167e9ec5f

Actual request

const results = await Axios.get('/artists', {
    params: {
      query,
      page,
      limit,
      workspaceId,
      onlyBelieveArtists,
    },
  });

Current behavior

Browser console throws an error :

[MSW] Failed to intercept a GraphQL request to “GET https://api.dev/artists”: cannot parse query. See the error message from the parser below.

Expected behavior

no error shoud be thrown as it is not a GraphQL request

this happens in

parseGraphQLRequest method

seemingly because it relies on the presence of a query param to start and parse the query

should this method even be called? maybe it should as no rest handler is provided it also tries to find a graphQL handler

thanks for any input on this

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
thomasmerycommented, May 12, 2021

thanks,

makes sense if I turn the logging into a throwing

I’ll try and open a PR by the end of the week 😃

0reactions
kettanaitocommented, May 12, 2021

We can try to

  1. Throw an exception instead of logging an error.
  2. Wrap the parseGraphQLRequest call in the onUnhandledRequest function in something like maybe or tryCatch custom function that would silence any exceptions thrown.

Thank you for your support!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rest Api from Cubejs gets mistaken as GraphQL when using ...
Pros: Ambiguous REST requests will not throw an error. The underlying request matching logic will continue as if the request is not GraphQL...
Read more >
Error handling - Apollo GraphQL Docs
A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ. OPERATION_RESOLUTION_FAILURE. The...
Read more >
Top GraphQL Errors and How to fix them
Top GraphQL Errors and How to Fix them. Error handling in GraphQL is different on both server and client side tooling.
Read more >
Changelog - Cypress Documentation
Cypress now throws an error if any Cypress commands are invoked from inside ... The cy.request() command now uses querystringify to stringify &...
Read more >
Middlewares and guards - TypeGraphQL
Middlewares have also an ability to intercept the result of resolver execution. ... You can also throw error in the middleware if the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found