mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-13 17:52:19 +03:00
Improved docs
This commit is contained in:
parent
19f7769861
commit
5c827538c7
|
@ -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).
|
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.
|
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
|
.. 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
|
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
|
There will be some cases where we need one Django Model to
|
||||||
have multiple graphene ``ObjectType``s associated to it.
|
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
|
.. code:: python
|
||||||
|
|
||||||
from graphene_django.registry import Registry
|
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
|
# We can also specify a custom registry with
|
||||||
# registry = Registry()
|
# registry = Registry()
|
||||||
|
|
||||||
|
|
||||||
This way, the ``ReporterModel`` could have two different types living in the same
|
This way, the ``ReporterModel`` could have two different types living in the same
|
||||||
schema.
|
schema.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user