Catching GraphQLLocatedError for tests
See original GitHub issueIs your feature request related to a problem? Please describe. No, question about doing a particular thing
Describe the solution you’d like
I’d like to know the way to catch GraphQLLocatedError, or a way to assertRaises
them.
I’ve tried :
- try…except way :
try:
response = self.client.execute(query, variables)
except GraphQLLocatedError:
self.fail(...)
- with self.assertRaises(…) way :
with self.assertRaises(GraphQLLocatedError):
response = self.client.execute(query, variables)
But none of these work. How can I do this ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to test GraphQLError exception in graphene_django or ...
Here are my two files: the code and the corresponding tests located in ... from graphql.error.located_error import GraphQLLocatedError from ...
Read more >Full Stack Error Handling with GraphQL and Apollo
Different types of GraphQL errors · Best practices to deal with those errors · Practical use-cases and examples using Apollo Server 2.0 ...
Read more >Error Handling - graphql-python
All applications fail, and GraphQL is no different. Some clients may ask for information that's not available or execute a forbidden action.
Read more >Testing GraphQL API in python - DataDrivenInvestor
A complete guide to test graphql api in python. ... this library helps us in capturing endpoints response and check it again when...
Read more >Release 0.6.1 - Read the Docs
GraphQLLocatedError (message, nodes=None, path=None) ... This is mostly useful for testing and when you need to convert nodes to JSON such as ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In the past I have used the following class to get stack traces of exceptions:
Then when I setup my view in the urls.py I pass it as an option:
Kind of lame that this method still requires patching the urlconf for use in tests: https://pytest-django.readthedocs.io/en/latest/helpers.html#pytest-mark-urls-override-the-urlconf
The above error is caused by
hasattr
check in.as_view
, as it is not aware that theGraphQLView
has that attribute. The below PR fixes that.