"""graphene_example URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.9/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from django.views.decorators.csrf import csrf_exempt
from graphene.contrib.django.views import GraphQLView

from .schema import schema


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^graphql', csrf_exempt(GraphQLView.as_view(schema=schema))),
    url(r'^graphiql', include('django_graphiql.urls')),
]
Example #2
0
"""teledb URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.9/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Import the include() function: from django.conf.urls import url, include
    3. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import url, include
from django.contrib import admin
from django.views.decorators.csrf import csrf_exempt
from graphene.contrib.django.views import GraphQLView
from teledb.schema import schema

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^graphql', csrf_exempt(GraphQLView.as_view(schema=schema))),
    url(r'^graphiql', include('django_graphiql.urls')),
]
Example #3
0
    def get_node(self, id):
        pass


class Human(DjangoNode):
    raises = graphene.String()

    class Meta:
        model = Article

    def resolve_raises(self, *args):
        raise Exception("This field should raise exception")

    def get_node(self, id):
        pass


class Query(graphene.ObjectType):
    human = graphene.Field(Human)

    def resolve_human(self, args, info):
        return Human()


schema = Schema(query=Query)

urlpatterns = [
    url(r'^graphql', GraphQLView.as_view(schema=schema)),
]
Example #4
0
from django.conf.urls import url, include
from django.views.decorators.csrf import csrf_exempt
from graphene.contrib.django.views import GraphQLView

from . import views
from .schema import schema

urlpatterns = [
    url(r'^graphiql', include('django_graphiql.urls'), name="graphiql"),
    url(r'^$', csrf_exempt(GraphQLView.as_view(schema=schema)), name="graphql")
]
Example #5
0
from .models import Reporter, Article


class Character(DjangoNode):
    class Meta:
        model = Reporter

    def get_node(self, id):
        pass


class Human(DjangoNode):
    raises = graphene.StringField()

    class Meta:
        model = Article

    def resolve_raises(self, *args):
        raise Exception("This field should raise exception")

    def get_node(self, id):
        pass

schema = Schema(query=Human)


urlpatterns = [
    url(r'^graphql', GraphQLView.as_view(schema=schema)),
]
Example #6
0
    # ADMIN
    url(r'^grappelli/', include('grappelli.urls')),
    url(r'^admin/', admin.site.urls),
    # CRUDL
    url(r'^crudl-rest/',
        TemplateView.as_view(template_name="crudl-admin-rest/index.html"), {
            'crudl_js': settings.CRUDL_JS,
            'crudl_css': settings.CRUDL_CSS
        }),
    url(r'^crudl-graphql/',
        TemplateView.as_view(template_name="crudl-admin-graphql/index.html"), {
            'crudl_js': settings.CRUDL_JS,
            'crudl_css': settings.CRUDL_CSS
        }),
    # DRF
    url(r'^rest-api-auth/',
        include('rest_framework.urls', namespace='rest_framework')),
    url(r'^rest-api/login/', login_view),
    url(r"^rest-api/", include(router.urls)),
    # GRAPHQL
    url(r'^graphql-api',
        csrf_exempt(api_auth_required(GraphQLView.as_view(schema=schema)))),
    url(r'^graphiql', include('django_graphiql.urls')),
    # INDEX
    url(r'^$',
        RedirectView.as_view(url='crudl-rest/', permanent=False),
        name='index')
]
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)