/TornGraphQl

A Simple Python GraphQL API Built with Tornado and SQLalchemy

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

TornGraphQl

A Simple Python GraphQL API Built with Tornado and SQLalchemy for managing crud life cycle of a Post object.

setup:

1) git clone https://github.com/MedAmineFouzai/TornGraphQl
2) cd TornGraphQl
3) pip install pipenv
4) pipenv --python 3.6
5) pipenv install - r requirements.txt
6) run project with torn cli : #command: [ torn run ]

GraphQL

GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data. GraphQL isn't tied to any specific database or storage engine and is instead backed by your existing code and data.

Graphene-Python

graphene-tornado A project for running Graphene on top of Tornado for Python 3. The codebase was originally a port of graphene-django.

Graphene-Python is a library for building GraphQL APIs in Python easily, its main goal is to provide a simple but extendable API for making developers' lives easier.


Usage:

Playground: http://localhost:8000/graphql

Now you can send requests via querys and see the result " YOUR API IS A USER INTERFACE !"

Querys:

Get Posts:

     {
       posts {
           Id
           title
           body
       }
     }

Create Posts:

        mutation{
            createPost(title:"post n ",body:"this is post n"){
                posts {
                    Id
                    title
                    body
                 }
              } 
           }

Delete Posts:

      mutation{
          deletePost(Id:"xxxxx"){
              posts {
                  Id
                  title
                  body
              }
           }
        }

Update Posts:

      mutation{
          updatePost(Id:"xxxxx",title:"post n ",body:"this post n"){
              posts {
                  Id
                  title
                  body
               }
            }
          }