1.2.2.1.1. database

1.2.2.1.1.1. Functions

sa_get_relationship(session, model, name)[source]

Resolve the relationship on a SQLAlchemy model to either an object (in the case of one-to-one relationships) or a query to all of the objects (in the case of one-to-many relationships).

Parameters:
  • session – The SQLAlchemy session to associate the query with.
  • model – The SQLAlchemy model of the object associated with the relationship.
  • name – The name of the relationship as it exists in the model.
Returns:

Either the object or a SQLAlchemy query for the objects.

sa_object_resolver(attname, default_value, model, info, **kwargs)[source]

Resolve the attribute for the given SQLAlchemy model object. If the attribute is a relationship, use sa_get_relationship() to resolve it.

Parameters:
  • attname (str) – The name of the attribute to resolve on the object.
  • default_value – The default value to return if the attribute is unavailable.
  • model (sqlalchemy.ext.declarative.api.Base) – The SQLAlchemy model to resolve the attribute for.
  • info (graphql.execution.base.ResolveInfo) – The resolve information for this execution.