Graphene

3.4.3 · active · verified Sun Mar 29

Graphene is an opinionated Python library for building GraphQL APIs easily. It provides a simple yet extendable API, with built-in support for Relay and integrations for popular web frameworks like Django and SQLAlchemy. The current stable version is 3.4.3, with active development and frequent releases.

Warnings

Install

Imports

Quickstart

This quickstart defines a simple GraphQL schema with a single 'hello' field that returns 'World'. It demonstrates basic schema definition and execution.

import graphene

class Query(graphene.ObjectType):
    hello = graphene.String(description='A typical hello world')

    def resolve_hello(self, info):
        return 'World'

schema = graphene.Schema(query=Query)

# Example usage:
query = '''
    query SayHello {
        hello
    }
'''
result = schema.execute(query)
print(result.data['hello'])
# Expected output: World

view raw JSON →