Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better error on @client annotation in MockLink and missing local resolvers #164

Open
SimenB opened this issue Aug 9, 2019 · 1 comment
Labels
🐛 debugging Feature requests that help users more easily debug issues project-apollo-client (legacy) LEGACY TAG DO NOT USE 🧪 testing Feature requests related to testing

Comments

@SimenB
Copy link

SimenB commented Aug 9, 2019

See discussion in apollographql/react-apollo#3316.

The current error provided by MockLink is just No more mocked responses for the query: followed by a dump of the query and arguments provided.

While providing mockResponses automatically strips out @client fields (apollographql/react-apollo#2776), there's no such happening for requests. This leads to a situation that is hard to debug, since the seamlessly removed part from one place is the thing that leads to an obfuscated error in another place.

I don't know what the ideal solution is, but a few suggestions of varying quality/usefulness:

  1. Try to diff all provided responses with the query, instead of requiring the stringified value to be identical, and print a nice diff which will at least highlight why there's "no more mocked responses". Landing Improve mismatched query error message react-apollo#2883 might be enough here? Not sure
  2. Throw an explicit error if a query contains a @client field which has no associated local resolver provided
  3. A simpler version of the above is to throw if there are @client fields without any resolvers being passed without trying to match them up
  4. provide a way strip out @client fields from the query (similar to what happens automatically for responses)
  5. Instead of automatically stripping out @client fields from responses, throw an error and require the user to explicitly opt in to it
@jeremy93-2008
Copy link

When it-s will be available, actually I just mostly spending the whole day figuring what-s going on, when it-s just some black box stuff problem.... the feature was open in 2019, come on, I-m sure that we can add a little warning :)

@jerelmiller jerelmiller added project-apollo-client (legacy) LEGACY TAG DO NOT USE 🧪 testing Feature requests related to testing 🐛 debugging Feature requests that help users more easily debug issues labels Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 debugging Feature requests that help users more easily debug issues project-apollo-client (legacy) LEGACY TAG DO NOT USE 🧪 testing Feature requests related to testing
Projects
None yet
Development

No branches or pull requests

3 participants