from django.conf import settings
from django.conf.urls import url
from django.urls import include
from django.views.decorators.csrf import csrf_exempt
from graphene_django.views import GraphQLView

from api.schema_public import schema

from core.views import PrivateGraphQLView

app_name = 'api'
urlpatterns = [
    url(r'^graphql-public', csrf_exempt(GraphQLView.as_view(schema=schema))),
    url(r'^graphql', csrf_exempt(PrivateGraphQLView.as_view())),

    # oauth
    url(r'^oauth/', include('oauth.urls', namespace="oauth")),
]

if settings.DEBUG:
    urlpatterns += [url(r'^graphiql-public', csrf_exempt(GraphQLView.as_view(schema=schema, graphiql=True,
                                                                             pretty=True)))]
    urlpatterns += [url(r'^graphiql', csrf_exempt(PrivateGraphQLView.as_view(graphiql=True, pretty=True)))]


