Repository: graphql-python/graphene-django

Issue:
Problem with creating CustomGraphQlView
Looks like it is impossible to create custom CBV inherited from GraphQLView 

_(Schema in example below is correct GraphQLSchema)_
**This example will not work**
```python 
# views.py
class CustomGraphQLView(GraphQLView):
    schema = Schema
    graphiql = True if settings.DEBUG else False

# urls.py
...CustomGraphQLView.as_view()...
```
For now the only way  to pass schema and graphiql attributes is using .as_view() method, that is definitely not how CBV should behave

**This one will work**
```python
# urls.py
...CustomGraphQLView.as_view(schema = Schema, graphiql = True if settings.DEBUG else False)...
```

After short investigation i problem was localized to this part of code:
https://github.com/graphql-python/graphene-django/blob/master/graphene_django/views.py#L67-L75

When using 1st example, in \_\__init\__\_ self.schema is defined (equals to Schema object) but local schema variable (attribute of \_\__init_\_\_ method) is None, so check on L69 is always is True and on L75  self.schema is being rewritten. In my case, graphene_settings.SCHEMA is not defined so self.schema after L75 is always None and check on [L84](https://github.com/graphql-python/graphene-django/blob/master/graphene_django/views.py#L84) always raises AssertionError

There is the same problem with attributes like ```graphiql``` that are being overwritten by \_\__init_\_\_.

**Possible fix:**
```self.schema = self.schema or schema  # L75```
```self.graphiql = self.graphiql or graphiql  # L81```
etc



python 3.6
graphene-django==1.3


Discussion:

Resolving patch:
diff --git a/graphene_django/views.py b/graphene_django/views.py
--- a/graphene_django/views.py
+++ b/graphene_django/views.py
@@ -72,14 +72,14 @@ def __init__(self, schema=None, executor=None, middleware=None, root_value=None,
         if middleware is None:
             middleware = graphene_settings.MIDDLEWARE
 
-        self.schema = schema
+        self.schema = self.schema or schema
         if middleware is not None:
             self.middleware = list(instantiate_middleware(middleware))
         self.executor = executor
         self.root_value = root_value
-        self.pretty = pretty
-        self.graphiql = graphiql
-        self.batch = batch
+        self.pretty = self.pretty or pretty
+        self.graphiql = self.graphiql or graphiql
+        self.batch = self.batch or batch
 
         assert isinstance(
             self.schema, GraphQLSchema), 'A Schema is required to be provided to GraphQLView.'


Test patch:
diff --git a/graphene_django/tests/test_views.py b/graphene_django/tests/test_views.py
--- a/graphene_django/tests/test_views.py
+++ b/graphene_django/tests/test_views.py
@@ -386,6 +386,24 @@ def test_allows_post_with_get_operation_name(client):
     }
 
 
+@pytest.mark.urls('graphene_django.tests.urls_inherited')
+def test_inherited_class_with_attributes_works(client):
+    inherited_url = '/graphql/inherited/'
+    # Check schema and pretty attributes work
+    response = client.post(url_string(inherited_url, query='{test}'))
+    assert response.content.decode() == (
+        '{\n'
+        '  "data": {\n'
+        '    "test": "Hello World"\n'
+        '  }\n'
+        '}'
+    )
+
+    # Check graphiql works
+    response = client.get(url_string(inherited_url), HTTP_ACCEPT='text/html')
+    assert response.status_code == 200
+
+
 @pytest.mark.urls('graphene_django.tests.urls_pretty')
 def test_supports_pretty_printing(client):
     response = client.get(url_string(query='{test}'))
diff --git a/graphene_django/tests/urls_inherited.py b/graphene_django/tests/urls_inherited.py
new file mode 100644
--- /dev/null
+++ b/graphene_django/tests/urls_inherited.py
@@ -0,0 +1,14 @@
+from django.conf.urls import url
+
+from ..views import GraphQLView
+from .schema_view import schema
+
+class CustomGraphQLView(GraphQLView):
+    schema = schema
+    graphiql = True
+    pretty = True
+
+
+urlpatterns = [
+    url(r'^graphql/inherited/$', CustomGraphQLView.as_view()),
+]