Strawberry provides a set of integrations with other libraries, such as Django,
FastAPI, Flask, and more, but you can also add your own integration. This guide
will show you how to do that.
To create a view, you need to create a class that inherits from either
SyncBaseHTTPView or AsyncBaseHTTPView and implement the get_root_value
method. Here is an example of a view that inherits from AsyncBaseHTTPView :
The methods above are the bare minimum that you need to implement to create a
view. They are all required, but you can also override other methods to change
the behaviour of the view.
On top of that we also need a request adapter, here's the base class for the
async version:
This request adapter will be used to get the request data from the request
object. You can specify the request adapter to use by setting the
request_adapter_class attribute on the view.
Finally you need to execute the operation, the base view provides a run method
that you can use to do that: