-
Notifications
You must be signed in to change notification settings - Fork 829
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: default value for argument should be Undefined (Issue #1394) and…
… update function from_global_id exception handling (graphql-python/graphql-relay-py@b217aef)
- Loading branch information
Thomas Leonard
committed
Mar 20, 2022
1 parent
61f0d8a
commit 19ebf08
Showing
7 changed files
with
52 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from ...types import ObjectType, Schema, String, NonNull | ||
|
||
|
||
class Query(ObjectType): | ||
hello = String(input=NonNull(String)) | ||
|
||
def resolve_hello(self, info, input): | ||
if input == "nothing": | ||
return None | ||
return f"Hello {input}!" | ||
|
||
|
||
schema = Schema(query=Query) | ||
|
||
|
||
def test_required_input_provided(): | ||
""" | ||
Test that a required argument works when provided. | ||
""" | ||
input_value = "Potato" | ||
result = schema.execute('{ hello(input: "%s") }' % input_value) | ||
assert not result.errors | ||
assert result.data == {"hello": "Hello Potato!"} | ||
|
||
|
||
def test_required_input_missing(): | ||
""" | ||
Test that a required argument raised an error if not provided. | ||
""" | ||
result = schema.execute("{ hello }") | ||
assert result.errors | ||
assert len(result.errors) == 1 | ||
assert ( | ||
result.errors[0].message | ||
== "Field 'hello' argument 'input' of type 'String!' is required, but it was not provided." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters