Skip to main content

This is a project to auto generate a graphql crud using graphene django

Project description

Graphene CRUD Maker

This is a project to auto generate a graphql crud using graphene django

Requirements

  • Python >= 3.6
  • Django >= 2.2
  • Graphene Django >= 2.0

Quick start


Installation

pip install graphene-crud-maker

Create a Django project

django-admin startproject core .

Add "graphene_crud_maker" to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'myapp',
        'graphene_crud_maker',
        'graphene_django',
    ]

Note: "myapp" is the name of the app

Add GRAPHENE to your settings.py

define the schema location for Graphene in the settings.py file of your Django project:

link: https://docs.graphene-python.org/projects/django/en/latest/

    GRAPHENE = {
        "ATOMIC_MUTATIONS": True,
        'SCHEMA': 'core.schema.schema.schema',
        "SCHEMA_INDENT": 4,
        "MIDDLEWARE": [
            "graphene_django.debug.DjangoDebugMiddleware",
            'graphql_jwt.middleware.JSONWebTokenMiddleware',
        ]
    }

Note name "core" is the name of the project

Add URLS to your urls.py

    from django.conf.urls import url
    from django.views.decorators.csrf import csrf_exempt
    from graphql_jwt.decorators import jwt_cookie
    from graphene_django.views import GraphQLView

    urlpatterns = [
        # ...
        url(r"graphql", csrf_exempt(jwt_cookie(GraphQLView.as_view(graphiql=True)))),
    ]

Create the app

python3 manage.py startapp myapp

Note: create models

Usage

Python

python3 manage.py maker --help

Output

Create Graphene CRUD

optional arguments:
  -h, --help            show this help message and exit
  -n NAME, --name NAME  App name to create the CRUD graphQL
  -e [EXCLUDE ...], --exclude [EXCLUDE ...]
                        Fields to exclude in the CRUD (id, createdAt, updatedAt)

                        ...

Command to create GraphQL

python3 manage.py maker -n myapp

Run the server

python3 manage.py runserver

GraphiQL

http://localhost:8000/graphql

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graphene-crud-maker-1.2.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graphene_crud_maker-1.2.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file graphene-crud-maker-1.2.0.tar.gz.

File metadata

  • Download URL: graphene-crud-maker-1.2.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for graphene-crud-maker-1.2.0.tar.gz
Algorithm Hash digest
SHA256 b5d7da61b162aebc8357ec055aa6e4e56cfc7eb7974172b69f4511d35911a3ba
MD5 3d1b173a2a7994c41a06aadfd9b05cb2
BLAKE2b-256 7d1c2182fb4a16f39ce2a0a17cabfa79d788552e297495ef77c4455cf23edd4e

See more details on using hashes here.

File details

Details for the file graphene_crud_maker-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for graphene_crud_maker-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2715bc63c2893c049f4d90b589f568ac8c64d0c14a9c04cb53f6a18dac7650d1
MD5 a8de3bd4ae3d6670325ee7e6e62f6e3e
BLAKE2b-256 e29d52e52f66e5b2545da2d72e4b8cf9dd2ec6fa7cf8a4e0314ae10a81d931d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page