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

using LocalGraphQLClient with passing localQueries for test purposes is not calling the middleware functions #1196

Open
amiroous opened this issue Jun 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@amiroous
Copy link

Package

graphql-hooks

Environment

  • graphql-hooks version: 6.4.0
  • react version: 17.0.2
  • Browser: Chrome

Description

using LocalGraphQLClient with passing localQueries for test purposes is not calling the middleware functions and causing the middleware not being tested completely

How to reproduce

  1. Create a GraphQL client and pass a middleware dummy function
  2. Use LocalGraphQLClient and define some localQueries to mock
  3. Debug and observe the middleware function is not getting called

Suggested solution (optional)

@amiroous amiroous added the bug Something isn't working label Jun 12, 2024
@madshall
Copy link
Contributor

madshall commented Jul 1, 2024

Another issue is that responseReducer isn't engaged either so the mocks should return the data in the shape the response reducer would have it, which could be used as a workaround if the shape of that data is an object. Otherwise it will be converted to an object. This code does it.

Steps to reproduce:

  1. call useQuery with responseReducer that returns an array
  2. create a mock which returns the same array as we expect after responseReducer is called
  3. receive an object instead

I think it would be less painful and technically more correct if LocalGraphQLClient overrode requestViaHttp and requestViaWS instead of request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants