Version 0.9.2

This commit is contained in:
Tom Christie 2018-12-04 16:45:44 +00:00
parent e4ef8bdfaf
commit 5379b125d3
4 changed files with 32 additions and 1 deletions

View File

@ -1,6 +1,15 @@
Starlette includes optional database support. There is currently only a driver
for Postgres databases, but MySQL and SQLite support is planned.
Enabling the built-in database support requires `sqlalchemy`, and an appropriate database driver. Currently this means `asyncpg` is a requirement.
The database support is completely optional - you can either include the middleware or not, or you can build alternative kinds of backends instead. It does not
include support for an ORM, but it does support using queries built using
[SQLAlchemy Core][sqlalchemy-core].
Here's a complete example, that includes table definitions, installing the
`DatabaseMiddleware`, and a couple of endpoints that interact with the database.
```python
import os
import sqlalchemy

View File

@ -25,6 +25,22 @@ which you can use to interact with your GraphQL API.
![GraphiQL](img/graphiql.png)
## Accessing request information
The current request is available in the context.
```python
class Query(graphene.ObjectType):
user_agent = graphene.String()
def resolve_user_agent(self, info):
"""
Return the User-Agent of the incoming request.
"""
request = info.context["request"]
return request.headers.get("User-Agent", "<unknown>")
```
## Sync or Async executors
If you're working with a standard ORM, then just use regular function calls for

View File

@ -1,3 +1,9 @@
## 0.9.2
* Add optional database support.
* Add `request` to GraphQL context.
* Hide any password component in `URL.__repr__`.
## 0.9.1
* Handle startup/shutdown errors properly.

View File

@ -1 +1 @@
__version__ = "0.9.1"
__version__ = "0.9.2"