From faadf03a1f664276ef940af505e3969a5f64de7a Mon Sep 17 00:00:00 2001 From: Florian Briand Date: Sat, 30 Mar 2019 23:12:35 +0100 Subject: [PATCH] Fix flask example, not working due to duplicated Connection --- examples/flask_sqlalchemy/schema.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/examples/flask_sqlalchemy/schema.py b/examples/flask_sqlalchemy/schema.py index bca71d19..434a9db2 100644 --- a/examples/flask_sqlalchemy/schema.py +++ b/examples/flask_sqlalchemy/schema.py @@ -12,33 +12,18 @@ class Meta: interfaces = (relay.Node, ) -class DepartmentConnection(relay.Connection): - class Meta: - node = Department - - class Employee(SQLAlchemyObjectType): class Meta: model = EmployeeModel interfaces = (relay.Node, ) -class EmployeeConnection(relay.Connection): - class Meta: - node = Employee - - class Role(SQLAlchemyObjectType): class Meta: model = RoleModel interfaces = (relay.Node, ) -class RoleConnection(relay.Connection): - class Meta: - node = Role - - SortEnumEmployee = utils.sort_enum_for_model(EmployeeModel, 'SortEnumEmployee', lambda c, d: c.upper() + ('_ASC' if d else '_DESC')) @@ -47,14 +32,14 @@ class Query(graphene.ObjectType): node = relay.Node.Field() # Allow only single column sorting all_employees = SQLAlchemyConnectionField( - EmployeeConnection, + Employee, sort=graphene.Argument( SortEnumEmployee, default_value=utils.EnumValue('id_asc', EmployeeModel.id.asc()))) # Allows sorting over multiple columns, by default over the primary key - all_roles = SQLAlchemyConnectionField(RoleConnection) + all_roles = SQLAlchemyConnectionField(Role) # Disable sorting over this field - all_departments = SQLAlchemyConnectionField(DepartmentConnection, sort=None) + all_departments = SQLAlchemyConnectionField(Department, sort=None) schema = graphene.Schema(query=Query, types=[Department, Employee, Role])