Commit 984d8de0 authored by Nicolas Joyard's avatar Nicolas Joyard

Graphene API experiment

parent 407f1795
......@@ -52,13 +52,16 @@ INSTALLED_APPS = (
'bootstrap3',
'datetimewidget',
'django_filters',
'django_graphiql',
'fontawesome',
'graphene.contrib.django',
'rest_framework',
'taggit',
# memopol apps
'core',
'memopol',
'memopol_graphene_api',
'memopol_scores',
'memopol_settings',
'memopol_themes',
......
......@@ -2,6 +2,11 @@
from django.conf.urls import include, url
from django.contrib import admin
from django.views.decorators.csrf import csrf_exempt
from graphene.contrib.django.views import GraphQLView
from memopol_graphene_api.schema import schema
from views.home import HomeView
......@@ -47,6 +52,9 @@ urlpatterns = [
url(r'^api/', include(api.router.urls)),
url(r'^graphql', csrf_exempt(GraphQLView.as_view(schema=schema))),
url(r'^graphiql', include('django_graphiql.urls')),
# Homepage
url(r'^$', HomeView.as_view(), name='home'),
......
import graphene
from .schemas.representative import RepresentativeQuery
class Query(RepresentativeQuery):
pass
schema = graphene.Schema(name='Memopol Schema')
schema.query = Query
from graphene import relay, ObjectType
from graphene.contrib.django.filter import DjangoFilterConnectionField
from graphene.contrib.django.types import DjangoNode
from representatives.models import Representative
class RepresentativeNode(DjangoNode):
class Meta:
model = Representative
filter_fields = ['full_name']
class RepresentativeQuery(ObjectType):
representative = relay.NodeField(RepresentativeNode)
all_representatives = DjangoFilterConnectionField(RepresentativeNode)
class Meta:
abstract = True
......@@ -17,12 +17,14 @@ setup(name='political-memory',
'django-datetime-widget>=0.9,<1.0',
'django-filter>=0.13,<0.14',
'django-fontawesome>=0.2,<0.3',
'django-graphiql>=0.4,<0.5',
'django-representatives-votes==0.0.24',
'django-representatives==0.0.35',
'django-rql-filter>=0.1.3,<0.2',
'django-taggit>=0.17,<0.18',
'django>=1.8,<1.9',
'djangorestframework>=3,<4',
'graphene[django]>=0.10,<1',
'hamlpy>=0.82,<0.83',
'ijson>=2.2,<2.3',
'python-dateutil>=2.4,<2.5',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment