Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_node(cls, id, context, info):
try:
model = cls._meta.model
query = get_query(model, context)
return query.get(id)
except NoResultFound:
return None
def connection_resolver(resolver, connection, model, root, args, context, info):
iterable = resolver(root, args, context, info)
if iterable is None:
iterable = get_query(model, context)
if isinstance(iterable, Query):
_len = iterable.count()
else:
_len = len(iterable)
return connection_from_list_slice(
iterable,
args,
slice_start=0,
list_length=_len,
list_slice_length=_len,
connection_type=connection,
pageinfo_type=PageInfo,
edge_type=connection.Edge,
)