Skip to content

Commit 5234a79

Browse files
committed
updated README
1 parent 68502e2 commit 5234a79

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

README.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
11
# strawberry-sqlalchemy-mapper
22

33

4-
Supplies decorators to automatically instrument strawberry types for provided SQLAlchemy models.
4+
Strawberry-sqlalchemy-mapper is the simplest way to implement autogenerated strawberry types for columns and relationships in SQLAlchemy models.
55

66

7-
Instead of manually listing every column and relationship in a SQLAlchemy model, strawberry-sqlalchemy-mapper
7+
- Instead of manually listing every column and relationship in a SQLAlchemy model, strawberry-sqlalchemy-mapper
88
lets you decorate a class declaration and it will automatically generate the necessary strawberry fields
9-
for all columns and relationships (subject to the limitations below) in the given model.
9+
for all columns and relationships in the given model.
1010

11-
## Usage
11+
- Native support for most of SQLAlchemy's most common types.
1212

13+
- Extensible to arbitrary custom SQLAlchemy types.
14+
15+
- Support for SQLAlchemy 1.x and 2.x
1316

14-
Decorate a type with `strawberry_sqlalchemy_mapper.type()`
15-
to register it as a strawberry type for the given SQLAlchemy model.
16-
This will automatically add fields for the model's columns, relationships, association proxies,
17-
and hybrid properties. For example:
17+
18+
## Getting Started
19+
20+
First, define your sqlalchemy model:
1821

1922
```
20-
class Employee(Model):
23+
# models.py
24+
from sqlalchemy import Column, Integer, String
25+
from sqlalchemy.ext.declarative import declarative_base
26+
27+
Base = declarative_base()
28+
29+
class Employee(Base):
30+
__tablename__ = 'employee'
2131
id = Column(UUID, primary_key=True)
2232
name = Column(String, nullable=False)
33+
```
2334

35+
Next, decorate a type with `strawberry_sqlalchemy_mapper.type()`
36+
to register it as a strawberry type for the given SQLAlchemy model.
37+
This will automatically add fields for the model's columns, relationships, association proxies,
38+
and hybrid properties. For example:
2439

40+
```
2541
# in another file
2642
strawberry_sqlalchemy_mapper = StrawberrySQLAlchemyMapper()
2743
@strawberry_sqlalchemy_mapper.type(models.Employee)
@@ -60,7 +76,7 @@ Association proxies are expected to be of the form `association_proxy('relations
6076
i.e., both properties are expected to be relationships.
6177

6278

63-
## Making Changes & Contributing
79+
## Contributing
6480

6581
This project uses `pre-commit`_, please make sure to install it before making any
6682
changes::

0 commit comments

Comments
 (0)