edgedb-python icon indicating copy to clipboard operation
edgedb-python copied to clipboard

Support dataclasses for queries

Open i0bs opened this issue 3 years ago • 0 comments

Seeing as this client library does not yet support a query builder, I would love to be able to pass in dataclasses when I'm making queries with EdgeQL. It would be something like this:

@dataclass
class QueryStruct:
    foo: str = "bar"
    ... # Ellipsis intended

Additionally, if possible, I'd like to see if we could get support for other dependencies such as attrs or pydantic. Especially with attrs, we could support converters and validators to help ensure with the query building process that data is properly being sent.

import edgedb

@attrs.define()
class QueryStruct:
    foo: QueryStruct = attrs.field(converter=QueryStruct, validator=edgedb.validate_query_struct)
    ...

i0bs avatar Aug 07 '22 04:08 i0bs