From eef28417428c3b4ba0c71c45bfbdd7e9182a13af Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sun, 25 Sep 2016 04:11:01 -0700 Subject: [PATCH] Updated Django docs with latest changes in graphene-python PRs. Including unmerged PR: https://github.com/graphql-python/graphene-python.org/pull/5 --- docs/authorization.rst | 7 +++---- docs/filtering.rst | 4 ++-- docs/introspection.rst | 3 +++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/authorization.rst b/docs/authorization.rst index 83157f2..b43240f 100644 --- a/docs/authorization.rst +++ b/docs/authorization.rst @@ -70,7 +70,7 @@ with the context argument. def resolve_my_posts(self, args, context, info): # context will reference to the Django request if not context.user.is_authenticated(): - return [] + return Post.objects.none() else: return Post.objects.filter(owner=context.user) @@ -105,7 +105,6 @@ method to your ``DjangoObjectType``. except cls._meta.model.DoesNotExist: return None - if post.published or context.user is post.owner: + if post.published or context.user == post.owner: return instance - else: - return None + return None diff --git a/docs/filtering.rst b/docs/filtering.rst index 138fc14..858b467 100644 --- a/docs/filtering.rst +++ b/docs/filtering.rst @@ -110,7 +110,7 @@ For example: filter_fields = ['name', 'genus', 'is_domesticated'] # Either a tuple/list of fields upon which ordering is allowed, or # True to allow filtering on all fields specified in filter_fields - order_by_fields = True + filter_order_by = True interfaces = (relay.Node, ) You can then control the ordering via the ``orderBy`` argument: @@ -134,7 +134,7 @@ Custom Filtersets By default Graphene provides easy access to the most commonly used features of ``django-filter``. This is done by transparently creating a ``django_filters.FilterSet`` class for you and passing in the values for -``filter_fields`` and ``order_by_fields``. +``filter_fields`` and ``filter_order_by``. However, you may find this to be insufficient. In these cases you can create your own ``Filterset`` as follows: diff --git a/docs/introspection.rst b/docs/introspection.rst index 7db21ca..0d30ee4 100644 --- a/docs/introspection.rst +++ b/docs/introspection.rst @@ -32,6 +32,9 @@ you're ready to use Relay with Graphene GraphQL implementation. Advanced Usage -------------- +The ``--indent`` option can be used to specify the number of indentation spaces to +be used in the output. Defaults to `None` which displays all data on a single line. + To simplify the command to ``./manage.py graphql_schema``, you can specify the parameters in your settings.py: