Skip to content

Commit 55c033a

Browse files
authored
Update README.md
1 parent 2ef3664 commit 55c033a

File tree

1 file changed

+35
-34
lines changed

1 file changed

+35
-34
lines changed

README.md

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -74,40 +74,6 @@ schema = strawberry.Schema(
7474
)
7575
```
7676

77-
Roots of polymorphic hierarchies are also expected to be registered via
78-
`strawberry_sqlalchemy_mapper.interface()`, and its concrete type and
79-
its descendants are expected to inherit from the interface:
80-
81-
```python
82-
class Book(Model):
83-
id = Column(UUID, primary_key=True)
84-
85-
class Novel(Book):
86-
pass
87-
88-
class ShortStory(Book):
89-
pass
90-
91-
92-
# in another file
93-
strawberry_sqlalchemy_mapper = StrawberrySQLAlchemyMapper()
94-
95-
@strawberry_sqlalchemy_mapper.interface(models.Book)
96-
class BookInterface:
97-
pass
98-
99-
@strawberry_sqlalchemy_mapper.type(models.Book)
100-
class Book:
101-
pass
102-
103-
@strawberry_sqlalchemy_mapper.type(models.Novel)
104-
class Novel:
105-
pass
106-
107-
@strawberry_sqlalchemy_mapper.type(models.ShortStory)
108-
class ShortStory:
109-
pass
110-
```
11177

11278
Examples to help you get started are provided in the `examples` directory.
11379

@@ -145,6 +111,41 @@ although support for `TypeDecorator` types is untested.
145111
Association proxies are expected to be of the form `association_proxy('relationship1', 'relationship2')`,
146112
i.e., both properties are expected to be relationships.
147113

114+
Roots of polymorphic hierarchies **are supported**, but are also expected to be registered via
115+
`strawberry_sqlalchemy_mapper.interface()`, and its concrete type and
116+
its descendants are expected to inherit from the interface:
117+
118+
```python
119+
class Book(Model):
120+
id = Column(UUID, primary_key=True)
121+
122+
class Novel(Book):
123+
pass
124+
125+
class ShortStory(Book):
126+
pass
127+
128+
129+
# in another file
130+
strawberry_sqlalchemy_mapper = StrawberrySQLAlchemyMapper()
131+
132+
@strawberry_sqlalchemy_mapper.interface(models.Book)
133+
class BookInterface:
134+
pass
135+
136+
@strawberry_sqlalchemy_mapper.type(models.Book)
137+
class Book:
138+
pass
139+
140+
@strawberry_sqlalchemy_mapper.type(models.Novel)
141+
class Novel:
142+
pass
143+
144+
@strawberry_sqlalchemy_mapper.type(models.ShortStory)
145+
class ShortStory:
146+
pass
147+
```
148+
148149
## Contributing
149150

150151
We encourage you to contribute to strawberry-sqlalchemy-mapper! Any contributions you make are greatly appreciated.

0 commit comments

Comments
 (0)