Git Product home page Git Product logo

graphene's Introduction

Graphene is a Python library for building GraphQL schemas/types fast and easily.

  • Easy to use: Graphene helps you use GraphQL in Python without effort.
  • Relay: Graphene has builtin support for Relay
  • Django: Automatic Django model mapping to Graphene Types. Check a fully working Django implementation

Graphene also supports SQLAlchemy!

What is supported in this Python version? Everything: Interfaces, ObjectTypes, Scalars, Unions and Relay (Nodes, Connections), in addition to queries, mutations and subscriptions.

NEW!: Try graphene online

Installation

For instaling graphene, just run this command in your shell

pip install graphene
# In case of need Django model support
pip install graphene[django]
# Or in case of need SQLAlchemy support
pip install graphene[sqlalchemy]

Examples

Here is one example for get you started:

class Query(graphene.ObjectType):
    hello = graphene.String(description='A typical hello world')
    ping = graphene.String(description='Ping someone',
                           to=graphene.String())

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

    def resolve_ping(self, args, info):
        return 'Pinging {}'.format(args.get('to'))

schema = graphene.Schema(query=Query)

Then Querying graphene.Schema is as simple as:

query = '''
    query SayHello {
      hello
      ping(to:"peter")
    }
'''
result = schema.execute(query)

If you want to learn even more, you can also check the following examples:

Contributing

After cloning this repo, ensure dependencies are installed by running:

python setup.py install

After developing, the full test suite can be evaluated by running:

python setup.py test # Use --pytest-args="-v -s" for verbose mode

graphene's People

Contributors

adamcharnock avatar adrielvelazquez avatar alecaivazis avatar amitsaha avatar bartgryszko avatar bigblind avatar billybarbaro avatar defrex avatar globegitter avatar ianlini avatar ilhan avatar inklesspen avatar iwaszko avatar jcb-k avatar jdugan1024 avatar jeffwidman avatar jfeinstein10 avatar jhgg avatar jkimbo avatar kevin-abiera avatar kyleamathews avatar lilyfoote avatar miracle2k avatar mjtamlyn avatar montemishkin avatar pyoner avatar rattrayalex avatar reisub-de avatar singingwolfboy avatar syrusakbary avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.