-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathurls.py
More file actions
46 lines (39 loc) · 1.6 KB
/
urls.py
File metadata and controls
46 lines (39 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""django_graphene URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/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. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
import re
from django.conf import settings
from django.conf.urls import include, url
from django.views.static import serve
from django.contrib import admin
from graphene_django.views import GraphQLView
from starwars.schema import schema
from graphql import GraphQLDeciderBackend, GraphQLCachedBackend, GraphQLCoreBackend
from graphql.backend.quiver_cloud import GraphQLQuiverCloudBackend
# Hack for allow static files in prod (Heroku/Dokku)
def static(prefix, view=serve, **kwargs):
return [
url(r'^%s(?P<path>.*)$' % re.escape(prefix.lstrip('/')), view, kwargs=kwargs),
]
backend = GraphQLDeciderBackend([
GraphQLCachedBackend(GraphQLQuiverCloudBackend(
'https://******@api.graphql-quiver.com'
)),
GraphQLCoreBackend()
])
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url('', include('starwars.urls')),
url(r'^graphql', GraphQLView.as_view(graphiql=True, backend=backend)),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)