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 (
|
||||
SQLAlchemyConnectionField
|
||||
)
|
||||
from .utils import (
|
||||
get_query,
|
||||
get_session
|
||||
)
|
||||
|
||||
__all__ = ['SQLAlchemyObjectType',
|
||||
'SQLAlchemyConnectionField']
|
||||
'SQLAlchemyConnectionField',
|
||||
'get_query',
|
||||
'get_session']
|
||||
|
|
|
@ -126,12 +126,15 @@ class SQLAlchemyObjectType(six.with_metaclass(SQLAlchemyObjectTypeMeta, ObjectTy
|
|||
).format(root))
|
||||
return type(root) == cls._meta.model
|
||||
|
||||
@classmethod
|
||||
def get_query(cls, context):
|
||||
model = cls._meta.model
|
||||
return get_query(model, context)
|
||||
|
||||
@classmethod
|
||||
def get_node(cls, id, context, info):
|
||||
try:
|
||||
model = cls._meta.model
|
||||
query = get_query(model, context)
|
||||
return query.get(id)
|
||||
return cls.get_query(context).get(id)
|
||||
except NoResultFound:
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user