mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Added get_query into sqlalchemy objecttype
This commit is contained in:
parent
a8feba6ab4
commit
893d6f681e
|
@ -4,6 +4,12 @@ from .types import (
|
||||||
from .fields import (
|
from .fields import (
|
||||||
SQLAlchemyConnectionField
|
SQLAlchemyConnectionField
|
||||||
)
|
)
|
||||||
|
from .utils import (
|
||||||
|
get_query,
|
||||||
|
get_session
|
||||||
|
)
|
||||||
|
|
||||||
__all__ = ['SQLAlchemyObjectType',
|
__all__ = ['SQLAlchemyObjectType',
|
||||||
'SQLAlchemyConnectionField']
|
'SQLAlchemyConnectionField',
|
||||||
|
'get_query',
|
||||||
|
'get_session']
|
||||||
|
|
|
@ -126,12 +126,15 @@ class SQLAlchemyObjectType(six.with_metaclass(SQLAlchemyObjectTypeMeta, ObjectTy
|
||||||
).format(root))
|
).format(root))
|
||||||
return type(root) == cls._meta.model
|
return type(root) == cls._meta.model
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_query(cls, context):
|
||||||
|
model = cls._meta.model
|
||||||
|
return get_query(model, context)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_node(cls, id, context, info):
|
def get_node(cls, id, context, info):
|
||||||
try:
|
try:
|
||||||
model = cls._meta.model
|
return cls.get_query(context).get(id)
|
||||||
query = get_query(model, context)
|
|
||||||
return query.get(id)
|
|
||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user