Skip to content

Latest commit

 

History

History
94 lines (65 loc) · 2.12 KB

README.md

File metadata and controls

94 lines (65 loc) · 2.12 KB

Graphene prisma

License:BSD-3-Clause

prisma playground

Brings prisma playground to graphene and more !

Install

To install graphene_prisma, you need to specify one of the supported frameworks

pip install graphene_prisma

or

pip install graphene_prisma[framework]

Supported frameworks :

e.g. starlette

pip install graphene_prisma[starlette]

Usage

To use graphene_prisma

from graphene_prisma.[framework] import [GraphQLHandler]
  • [framework] : name of the framework (responder, starlette,...)
  • [GraphQLHandler]: name of the graphql view in your framework (GraphQLView for responder and GraphQLApp for starlette )

Here is a list of the corresponding graphql classes to each framework :

framework GraphQL view
responder GraphQLView
starlette GraphQLApp

Starlette

from starlette.applications import Starlette
from graphene_prisma.starlette import GraphQLApp

class Query(graphene.ObjectType):
    hello = graphene.String(name=graphene.String(default_value="stranger"))

    def resolve_hello(self, info, name):
        return f"Hello {name}"

app = Starlette()
app.add_route('/', GraphQLApp(schema=graphene.Schema(query=Query)))

Responder

import responder
from graphene_prisma.responder import GraphQLView

api = responder.API()

class Query(graphene.ObjectType):
    hello = graphene.String(name=graphene.String(default_value="stranger"))

    def resolve_hello(self, info, name):
        return f"Hello {name}"

schema = graphene.Schema(query=Query)
view = GraphQLView(api=api, schema=schema)

api.add_route("/graph", view)
api.run()

TODO

  • Support other frameworks (django, flask,...)
  • Tests
  • Upload