Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
graphene-django-optimizer-reloaded
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Libraries
graphene-django-optimizer-reloaded
Commits
514bdc7d
Commit
514bdc7d
authored
5 years ago
by
NyanKiyoshi
Committed by
Tomás Fox
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update readme with latest changes
parent
aaf6a188
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+7
-7
7 additions, 7 deletions
README.md
with
7 additions
and
7 deletions
README.md
+
7
−
7
View file @
514bdc7d
...
...
@@ -115,11 +115,10 @@ If the resolver returns a model field, we can use the `model_field` argument:
```
py
import
graphene
from
graphene_django.types
import
DjangoObjectType
import
graphene_django_optimizer
as
gql_optimizer
class
ItemType
(
DjangoObjectType
):
class
ItemType
(
gql_optimizer
.
Optimized
DjangoObjectType
):
product
=
graphene
.
Field
(
'
ProductType
'
)
@gql_optimizer.resolver_hints
(
...
...
@@ -138,11 +137,10 @@ Now, if the resolver uses related fields, you can use the `select_related` argum
```
py
import
graphene
from
graphene_django.types
import
DjangoObjectType
import
graphene_django_optimizer
as
gql_optimizer
class
ItemType
(
DjangoObjectType
):
class
ItemType
(
gql_optimizer
.
Optimized
DjangoObjectType
):
name
=
graphene
.
String
()
@gql_optimizer.resolver_hints
(
...
...
@@ -153,6 +151,9 @@ class ItemType(DjangoObjectType):
return
'
{} {}
'
.
format
(
root
.
product
.
name
,
root
.
shipping
.
name
)
```
Notice the usage of the type
`OptimizedDjangoObjectType`
, which enables
optimization of any single node queries.
Finally, if your field has an argument for filtering results,
you can use the
`prefetch_related`
argument with a function
that returns a
`Prefetch`
instance as the value.
...
...
@@ -160,11 +161,10 @@ that returns a `Prefetch` instance as the value.
```
py
from
django.db.models
import
Prefetch
import
graphene
from
graphene_django.types
import
DjangoObjectType
import
graphene_django_optimizer
as
gql_optimizer
class
CartType
(
DjangoObjectType
):
class
CartType
(
gql_optimizer
.
Optimized
DjangoObjectType
):
items
=
graphene
.
List
(
'
ItemType
'
,
product_id
=
graphene
.
ID
(),
...
...
@@ -191,7 +191,7 @@ So if we still want to optimize with the `.only()` method, we need to use `disab
```
py
class
IngredientType
(
DjangoObjectType
):
class
IngredientType
(
gql_optimizer
.
Optimized
DjangoObjectType
):
calculated_calories
=
graphene
.
String
()
class
Meta
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment