Skip to content

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

Open
@SimenB

Description

@SimenB

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 debuggingFeature requests that help users more easily debug issuesproject-apollo-client (legacy)LEGACY TAG DO NOT USE🧪 testingFeature requests related to testing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions