Unable to catch GraphQL error in django testing #815
Unanswered
srajawat-hub
asked this question in
Q&A
Replies: 1 comment 2 replies
-
You can't use This is because exceptions raised in API client are mangled through query executor and converted into GraphQL response. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am testing my resolver in graphQl, i am working with django and ariadne library. this is the test i wrote:
This is the function i am using to get response from graphql:
and this is my resolver:
But i am not able to catch the error, i may be using wrong approach but all i want to do is pass wrong value in query and match error messages as expected,
this is error message i am getting in terminal:
617, in resolve_field
result = resolve_fn(source, info, **args)
File "/home/welcome/agents-platform/services/api/api/auth.py", line 12, in resolve_is_authenticated
result = original_resolver(obj, info, **kwargs)
File "/home/welcome/.local/share/virtualenvs/api-_WI5du6j/lib/python3.8/site-packages/ariadne/utils.py", line 75, in wrapper
return func(*args, **convert_to_snake_case(kwargs))
File "/home/welcome/agents-platform/services/api/stoploss/resolvers.py", line 76, in resolve_trigger
raise GraphQLError(message="Trigger not found")
File "/home/welcome/agents-platform/services/api/stoploss/resolvers.py", line 69, in resolve_trigger
return Trigger.objects.get(
File "/home/welcome/.local/share/virtualenvs/api-_WI5du6j/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/welcome/.local/share/virtualenvs/api-_WI5du6j/lib/python3.8/site-packages/django/db/models/query.py", line 439, in get
raise self.model.DoesNotExist(
graphql.error.graphql_error.GraphQLError: Trigger not found
Beta Was this translation helpful? Give feedback.
All reactions