I'm trying to add support for nested objects in my graph per the example below. But it seems that the nested objects are not parsed/read correctly?
class CommandResponseAttributes(Object):
field_type: str
required: bool
description: Optional[str]
class CommandResponseObject(Object):
field_name: str
attributes: CommandResponseAttributes
class CommandObject(Object):
command_name: str
description: Optional[str]
response_schema: List[CommandResponseObject]
With the following Query:
def response_schema() -> dict:
return {
'new_handle': {
'field_type': 'string',
'required': True,
'description': 'some description'
},
'send_to': {
'field_type': 'string',
'required': True,
'description': 'some description'
},
'accept_email': {
'field_type': 'string',
'required': False,
'description': 'some description'
},
'accept_domain': {
'field_type': 'string',
'required': False,
'description': 'some description'
},
'lock_email': {
'field_type': 'boolean',
'required': True,
'description': 'some description'
},
'lock_domain': {
'field_type': 'boolean',
'required': True,
'description': 'some description'
},
'source_domain': {
'field_type': 'string',
'required': False,
'description': 'some description'
}
}
class Query(BaseQuery):
@field
def command(self, command_name: str) -> CommandObject:
schema = list()
for field_name, attributes in response_schema().items():
# noinspection PyArgumentList
schema.append(
CommandResponseObject(
field_name=field_name,
attributes=CommandResponseAttributes(**attributes)
)
)
data = {
'command_name': command_obj.name,
'description': None,
'response_schema': schema
}
# noinspection PyArgumentList
return CommandObject(**data)
But sending a query for these objects results in the following exception:
ERROR:root:'NoneType' object has no attribute 'selections'
Traceback (most recent call last):
File "lib/python3.7/site-packages/pygraphy/types/schema.py", line 185, in _execute_operation
error_collector
File "lib/python3.7/site-packages/pygraphy/types/object.py", line 158, in __task_receiver
yield await self.__check_and_circular_resolve(tasks, error_collector)
File "lib/python3.7/site-packages/pygraphy/types/object.py", line 174, in __check_and_circular_resolve
result, node, error_collector, path
File "lib/python3.7/site-packages/pygraphy/types/object.py", line 192, in __circular_resolve
node.selection_set.selections, error_collector, path
File "lib/python3.7/site-packages/pygraphy/types/object.py", line 158, in __task_receiver
yield await self.__check_and_circular_resolve(tasks, error_collector)
File "lib/python3.7/site-packages/pygraphy/types/object.py", line 174, in __check_and_circular_resolve
result, node, error_collector, path
File "lib/python3.7/site-packages/pygraphy/types/object.py", line 200, in __circular_resolve
node.selection_set.selections,
AttributeError: 'NoneType' object has no attribute 'selections'
Traceback (most recent call last):
File "lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/lib/python3.7/site-packages/pygraphy/types/schema.py", line 159, in execute
request
File "lib/python3.7/site-packages/pygraphy/types/schema.py", line 199, in _execute_operation
'data': dict(obj) if obj else None
File "lib/python3.7/site-packages/pygraphy/types/object.py", line 75, in __iter__
value = dict(value)
File "lib/python3.7/site-packages/pygraphy/types/object.py", line 80, in __iter__
serialized_value.append(dict(i))
File "lib/python3.7/site-packages/pygraphy/types/object.py", line 73, in __iter__
for name, value in self.resolve_results.items():
AttributeError: 'CommandResponseObject' object has no attribute 'resolve_results'
I'm trying to add support for nested objects in my graph per the example below. But it seems that the nested objects are not parsed/read correctly?
With the following Query:
But sending a query for these objects results in the following exception: