From 5c827538c78222f7083b601dd588269f8b77ee6a Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Mon, 20 Feb 2017 00:21:05 -0800 Subject: [PATCH] Improved docs --- docs/registry.rst | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/registry.rst b/docs/registry.rst index af63e2b..da42b35 100644 --- a/docs/registry.rst +++ b/docs/registry.rst @@ -8,10 +8,12 @@ This way, we make the library smart enough to convert automatically the relations between models to Graphene fields automatically (when possible). -get_global_registry -------------------- +Global registry +--------------- By default, all model/objecttype relations will live in the global registry. +You retrieve using the function ``get_global_registry`` in +``graphene_django.registry``. .. code:: python @@ -26,12 +28,16 @@ By default, all model/objecttype relations will live in the global registry. global_registry.get_type_for_model(ReporterModel) # == Reporter -One Model, multiple types -------------------------- +Multiple types for one model +---------------------------- There will be some cases where we need one Django Model to have multiple graphene ``ObjectType``s associated to it. +In this case, we can either use ``skip_global_registry`` to create +a new isolated registry for that type (so it doesn't interfere with +the global registry), or we can create a custom registry for it. + .. code:: python from graphene_django.registry import Registry @@ -49,5 +55,6 @@ have multiple graphene ``ObjectType``s associated to it. # We can also specify a custom registry with # registry = Registry() + This way, the ``ReporterModel`` could have two different types living in the same schema.