Skip to content

Commit 388127f

Browse files
committed
Add docs about context being needed
1 parent 7c0b15d commit 388127f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ Strawberry-sqlalchemy-mapper is the simplest way to implement autogenerated stra
66

77
- 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 in the given model.
9+
for all columns and relationships (subject to the limitations below) in the given model.
1010

1111
- Native support for most of SQLAlchemy's most common types.
12-
1312
- Extensible to arbitrary custom SQLAlchemy types.
14-
13+
- Automatic batching of queries, avoiding N+1 queries when getting relationships
1514
- Support for SQLAlchemy >=1.4.x
16-
1715
- Lightweight and fast.
1816

1917
## Getting Started
@@ -45,6 +43,12 @@ strawberry_sqlalchemy_mapper = StrawberrySQLAlchemyMapper()
4543
class Employee:
4644
pass
4745

46+
# context is expected to have an instance of StrawberrySQLAlchemyLoader
47+
class CustomGraphQLView(GraphQLView):
48+
def get_context(self):
49+
return {
50+
"sqlalchemy_loader": StrawberrySQLAlchemyLoader(),
51+
}
4852

4953
# call finalize() before using the schema:
5054
strawberry_sqlalchemy_mapper.finalize()
@@ -62,7 +66,7 @@ Roots of polymorphic hierarchies are also expected to be registered via
6266
`strawberry_sqlalchemy_mapper.interface()`, and its concrete type and
6367
its descendants are expected to inherit from the interface:
6468

65-
```
69+
```python
6670
class Book(Model):
6771
id = Column(UUID, primary_key=True)
6872

0 commit comments

Comments
 (0)