Third Party Packages & Integrations¶
Esmerald being an ASGI framework that also support WSGI through WSGIMiddleware also allows the integrations with third parties and their packages and frameworks.
GraphQL¶
Natively Esmerald does not integrate GraphQL, at least not for now. Instead there already available awesome working solutions built by great minds.
Ariadne¶
Great framework with great documentation and great examples how to use it. Currently they also have an integration with Starlette and that also means Esmerald. Their example is with Starlette but here we also provide an example for Esmerald.
from ariadne import QueryType, make_executable_schema
from ariadne.asgi import GraphQL
from esmerald import Esmerald, Include
type_defs = """
type Query {
hello: String!
}
"""
query = QueryType()
@query.field("hello")
def resolve_hello(*_):
return "Hello world!"
# Create executable schema instance
schema = make_executable_schema(type_defs, query)
app = Esmerald(debug=True, routes=[Include("/graphql", GraphQL(schema, debug=True))])
The documentation can be found here.
Ariadne version 0.16.1¶
Warning
By the time of this writing, Starlette
was in the version 0.21.0
.
Due to the nature of Esmerald
, when installing Ariadne
it will install a lower version and this will
conflict with Esmerald. After you install ariadne
make sure you reinstall Starlette>=0.21.0
.
Until a new version of the package comes out supporting the latest from Starlette, this is the workaround.
Esmerald Sessions¶
Manages sessions for Esmerald using Redis, Memcache or any custom backend.