Skip to content

Commit

Permalink
Add test for runtime exception
Browse files Browse the repository at this point in the history
  • Loading branch information
jkimbo committed Oct 31, 2021
1 parent 38a1039 commit 505b13a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/types/test_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,17 @@ def on_request_start(self):

with pytest.raises(RuntimeError):
schema.execute_sync("mutation { myMutation }")


def test_error_when_accessing_operation_type_with_invalid_operation_name():
class MyExtension(Extension):
def on_parsing_end(self):
execution_context = self.execution_context

# This should raise a RuntimeError
execution_context.operation_type

schema = strawberry.Schema(Query, extensions=[MyExtension])

with pytest.raises(RuntimeError):
schema.execute_sync("query { ping }", operation_name="MyQuery")

0 comments on commit 505b13a

Please sign in to comment.