bendemaree / falcon-graphene

Helpers for registering Graphene schemas in Falcon.
18 stars 3 forks source link

falcon-graphene

Helpers for registering Graphene schemas in Falcon as advised by the GraphQL best practices documentation for GraphQL over HTTP.

Example

import falcon

from falcon_graphene import GrapheneRouter

import graphene

class Clock(graphene.ObjectType):
    name = graphene.String()

class RootQuery(graphene.ObjectType):
    clock = graphene.Field(Clock)

    def resolve_clock(self, args, context, info):
        return Clock(name="Charlie")

application = falcon.API()
schema = graphene.Schema(query=RootQuery)
router = GrapheneRouter.from_schema(schema).serving_on(application)

Note: You can try this out in the examples directory.

We can now execute GraphQL queries via a GET or POST to /graphql:

http POST :8000/graphql query='{ clock { name } }'

Note: This example uses HTTPie.

What is this?

This is simply a bit of glue to interact with a GraphQL API defined in Graphene with the Falcon API framework. By staying simple and using Falcon's architecture, it can do a few things for you:

What is this not?

Fancy.

Testing

Tests use toxTo get started, ensure tox installed, then just run tox.