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
e97d7914
Commit
e97d7914
authored
5 years ago
by
NyanKiyoshi
Committed by
Tomás Fox
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add a type to retrieve single nodes with optimizations made
parent
ee347e05
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
graphene_django_optimizer/types.py
+18
-0
18 additions, 0 deletions
graphene_django_optimizer/types.py
with
19 additions
and
0 deletions
.gitignore
+
1
−
0
View file @
e97d7914
...
...
@@ -10,3 +10,4 @@ dist/
build/
.coverage
htmlcov/
.*/
This diff is collapsed.
Click to expand it.
graphene_django_optimizer/types.py
0 → 100644
+
18
−
0
View file @
e97d7914
from
graphene_django.types
import
DjangoObjectType
from
.query
import
query
class
OptimizedDjangoObjectType
(
DjangoObjectType
):
class
Meta
:
abstract
=
True
@classmethod
def
optimize_node
(
cls
,
info
,
qs
,
pk
):
try
:
return
query
(
qs
,
info
).
get
(
pk
=
pk
)
except
cls
.
_meta
.
model
.
DoesNotExist
:
return
None
@classmethod
def
get_node
(
cls
,
info
,
id
):
return
cls
.
optimize_node
(
info
,
cls
.
_meta
.
model
.
objects
,
id
)
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