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

MockEnvironment not working as expected with default value in GraphQL query. #4919

Open
william57m opened this issue Feb 25, 2025 · 1 comment

Comments

@william57m
Copy link

william57m commented Feb 25, 2025

Hello,

I've recently found an issue while testing one of my component using useQueryLoader.

My query contains an optional countEach param that has a default value = 10.

In my code, I'm calling the searchCallback without passing countEach, so in the MockEnvironment, my variables query doesn't have the variable countEach. However, the variables from the operationDescriptor query contains that countEach param, so the comparison on that line returns false, so the query is not retrieved and the mock fails.

The quick solution is to pass the variable to my searchCallback variables, but then I no longer benefit of the default value set on the param. Is there any other solution I am missing? Maybe at the resolver level. Otherwise I believe it may be an issue in the MockEnvironment.

Image

Thanks in advance for any help.

@monicatang
Copy link
Contributor

monicatang commented Feb 26, 2025

Hi there,

Thanks for the question.
Could you share the code snippet in your test? (It would be helpful to see how you are using MockEnvironment.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants