-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested Objects not supported? #10
Comments
Hi, could you please give me a complete sample for reproducing? I do not know the definition of |
@ethe - I've updated my original comment with the necessary representation being passed into the command field |
I am sorry that I can not reproduce the issue following your sample. Please make sure that you have already used the newest version of Pygraphy. Here is my test file according to your discription. import asyncio
from typing import Optional, List
from pygraphy import Object, Query as BaseQuery, field, Schema as BaseSchema
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]
def response_schema() -> dict:
return {
'new_handle': {
'field_type': 'string',
'required': True,
'description': 'The handle just created, without @<domain>'
},
'send_to': {
'field_type': 'string',
'required': True,
'description': 'The actual email address to which this handle '
'will forward accepted emails.'
},
'accept_email': {
'field_type': 'string',
'required': False,
'description': 'The only email address from which emails will '
'be accepted by this handle. If `None`, the '
'handle\'s other incoming rules apply.'
},
'accept_domain': {
'field_type': 'string',
'required': False,
'description': 'The only email domain from which emails will '
'be accepted by this handle. If `None`, the '
'handle\'s other incoming rules apply.'
},
'lock_email': {
'field_type': 'boolean',
'required': True,
'description': 'Will this handle be locked to the email '
'of the sender of the first email received by '
'this handle?'
},
'lock_domain': {
'field_type': 'boolean',
'required': True,
'description': 'Will this handle be locked to the domain '
'of the sender of the first email received by '
'this handle?'
},
'source_domain': {
'field_type': 'string',
'required': False,
'description': 'The domain of the website for which this '
'handle was created, if available.'
}
}
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': 'test',
'description': None,
'response_schema': schema
}
# noinspection PyArgumentList
return CommandObject(**data)
class Schema(BaseSchema):
query: Optional[Query]
print(asyncio.run(Schema.execute('''
{
command(commandName: "test") {
responseSchema {
fieldName
attributes {
description
required
fieldType
}
}
}
}
'''))) |
Thanks @ethe - I see my problem was with the query I was submitting. The simplified version of the query I was using is:
If you run this query, you should get the same exception messages as I did above. While the error is in the query, I think The issue seems to be specifically the omission of sub-selections in the query. |
I think maybe |
Yes, you're absolutely correct: my suggestion is that If I'm not mistaken, in the same situation |
You are right, the Pygraphy should return more helpful messages after an error query. I will fix it recently, than you! |
Thank you! It's great to be finally working with a pythonic GraphQL library! |
Thank you! |
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:
The text was updated successfully, but these errors were encountered: