Skip to content

Commit 3875d2f

Browse files
author
Michael Brewer
committed
test(data-classes): Verify we can support multiple mappings
1 parent fc03fdd commit 3875d2f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/functional/appsync/test_appsync_resolver_utils.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,30 @@ def func_yield():
146146
assert next(result) == "value"
147147

148148

149+
def test_resolver_multiple_mappings():
150+
# GIVEN
151+
app = AppSyncResolver()
152+
153+
@app.resolver(field_name="listLocations")
154+
@app.resolver(field_name="locations")
155+
def get_locations(name: str, description: str = ""):
156+
return name + description
157+
158+
# WHEN
159+
mock_event1 = {"typeName": "Query", "fieldName": "listLocations", "arguments": {"name": "value"}}
160+
mock_event2 = {
161+
"typeName": "Merchant",
162+
"fieldName": "locations",
163+
"arguments": {"name": "value2", "description": "description"},
164+
}
165+
result1 = app.resolve(mock_event1, LambdaContext())
166+
result2 = app.resolve(mock_event2, LambdaContext())
167+
168+
# THEN
169+
assert result1 == "value"
170+
assert result2 == "value2description"
171+
172+
149173
@pytest.mark.skipif(sys.version_info < (3, 8), reason="only for python versions that support asyncio.run")
150174
def test_resolver_async():
151175
# GIVEN

0 commit comments

Comments
 (0)