Skip to content

bendemaree/falcon-graphene

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  • Registers handlers under the standard /graphql endpoint
  • Allows you to bring all of your existing middleware, request/response handling, etc.
  • Pushes the Falcon request context down as the resolve_* context argument

What is this not?

Fancy.

Testing

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

About

Helpers for registering Graphene schemas in Falcon.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages