mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-19 06:28:39 +03:00
don't drop nested typed null fields in actions (fix #8237)
GITHUB_PR_NUMBER: 8238 GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/8238 PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4272 Co-authored-by: Jesse Jaara <294363+Huulivoide@users.noreply.github.com> Co-authored-by: Lyndon Maydwell <92299+sordina@users.noreply.github.com> GitOrigin-RevId: 810ec935a1e1c75a06a1ad1427dedb179eb60d5e
This commit is contained in:
parent
b21e05ae5f
commit
22120a026c
@ -3,8 +3,10 @@
|
||||
## Next release
|
||||
|
||||
### Bug fixes and improvements
|
||||
- server: fix parsing remote relationship json definition from 1.x server catalog on migration (fix #7906)
|
||||
|
||||
- server: update pg_dump to be compatible with postgres 14 (#7676)
|
||||
- server: fix parsing remote relationship json definition from 1.x server catalog on migration (fix #7906)
|
||||
- server: Don't drop nested typed null fields in actions (fix #8237)
|
||||
|
||||
## v2.6.0-beta.1
|
||||
|
||||
|
@ -157,6 +157,7 @@ makeActionResponseNoRelations annFields webhookResponse =
|
||||
mkValue = \case
|
||||
J.Object o -> Just $ mkResponseObject nestedFields o
|
||||
J.Array a -> Just $ AO.array $ mapMaybe mkValue $ toList a
|
||||
J.Null -> Just AO.Null
|
||||
_ -> Nothing
|
||||
Map.lookup fieldText obj >>= mkValue
|
||||
in -- NOTE (Sam): This case would still not allow for aliased fields to be
|
||||
|
@ -381,6 +381,18 @@ class ActionsWebhookHandler(http.server.BaseHTTPRequestHandler):
|
||||
resp, status = self.get_results()
|
||||
self._send_response(status, resp)
|
||||
|
||||
elif req_path == "/typed-nested-null":
|
||||
self._send_response(
|
||||
HTTPStatus.OK,
|
||||
self.get_typed_nested_null()
|
||||
)
|
||||
|
||||
elif req_path == "/typed-nested-null-wrong-field":
|
||||
self._send_response(
|
||||
HTTPStatus.OK,
|
||||
self.get_typed_nested_null_wrong_field()
|
||||
)
|
||||
|
||||
else:
|
||||
self.send_response(HTTPStatus.NO_CONTENT)
|
||||
self.end_headers()
|
||||
@ -561,6 +573,18 @@ class ActionsWebhookHandler(http.server.BaseHTTPRequestHandler):
|
||||
else:
|
||||
return map(make_nested_out_object, resp), status
|
||||
|
||||
def get_typed_nested_null(self):
|
||||
return {
|
||||
'id': 1,
|
||||
'child': None
|
||||
}
|
||||
|
||||
def get_typed_nested_null_wrong_field(self):
|
||||
return {
|
||||
'id': None,
|
||||
'child': None
|
||||
}
|
||||
|
||||
def null_response(self):
|
||||
response = None
|
||||
return response, HTTPStatus.OK
|
||||
|
@ -0,0 +1,18 @@
|
||||
description: Typed nested nullable object should passtrough null values
|
||||
url: /v1/graphql
|
||||
status: 200
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
typed_nested_null {
|
||||
id
|
||||
child {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
response:
|
||||
data:
|
||||
typed_nested_null:
|
||||
id: 1
|
||||
child: null
|
@ -214,5 +214,6 @@
|
||||
city0: Bangalore
|
||||
country0: India
|
||||
other_addresses:
|
||||
- ~
|
||||
- city: Melbourne
|
||||
country: Australia
|
||||
|
@ -206,6 +206,13 @@ args:
|
||||
- name: id
|
||||
type: Int!
|
||||
|
||||
- name: TypedNestedNull
|
||||
fields:
|
||||
- name: id
|
||||
type: ID!
|
||||
- name: child
|
||||
type: TypedNestedNull
|
||||
|
||||
- type: create_action
|
||||
args:
|
||||
name: create_user
|
||||
@ -486,3 +493,19 @@ args:
|
||||
"id": {{ x }}
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
- type: create_action
|
||||
args:
|
||||
name: typed_nested_null
|
||||
definition:
|
||||
type: query
|
||||
output_type: TypedNestedNull!
|
||||
handler: http://127.0.0.1:5593/typed-nested-null
|
||||
|
||||
- type: create_action
|
||||
args:
|
||||
name: typed_nested_null_wrong_field
|
||||
definition:
|
||||
type: query
|
||||
output_type: TypedNestedNull!
|
||||
handler: http://127.0.0.1:5593/typed-nested-null-wrong-field
|
||||
|
@ -72,6 +72,14 @@ args:
|
||||
args:
|
||||
name: results
|
||||
clear_data: true
|
||||
- type: drop_action
|
||||
args:
|
||||
name: typed_nested_null
|
||||
clear_data: true
|
||||
- type: drop_action
|
||||
args:
|
||||
name: typed_nested_null_wrong_field
|
||||
clear_data: true
|
||||
# clear custom types
|
||||
- type: set_custom_types
|
||||
args: {}
|
||||
|
@ -90,6 +90,32 @@ class TestActionsSync:
|
||||
def test_object_response_action_transformed_output(self, hge_ctx):
|
||||
check_query_f(hge_ctx, self.dir() + '/object_response_action_transformed_output.yaml')
|
||||
|
||||
def test_expecting_object_response_with_nested_null(self, hge_ctx):
|
||||
check_query_f(hge_ctx, self.dir() + '/expecting_object_response_with_nested_null.yaml')
|
||||
|
||||
def test_expecting_object_response_with_nested_null_wrong_field(self, hge_ctx):
|
||||
query_obj = {
|
||||
"query": """
|
||||
query {
|
||||
typed_nested_null_wrong_field {
|
||||
id
|
||||
child {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
headers = {}
|
||||
admin_secret = hge_ctx.hge_key
|
||||
if admin_secret is not None:
|
||||
headers['X-Hasura-Admin-Secret'] = admin_secret
|
||||
code, resp, _ = hge_ctx.anyq('/v1/graphql', query_obj, headers)
|
||||
assert code == 200, resp
|
||||
|
||||
error_message = resp['errors'][0]['message']
|
||||
|
||||
assert error_message == 'expecting not null value for field "id"', error_message
|
||||
|
||||
# Webhook response validation tests. See https://github.com/hasura/graphql-engine/issues/3977
|
||||
def test_mirror_action_not_null(self, hge_ctx):
|
||||
|
Loading…
Reference in New Issue
Block a user