Skip to content

Commit

Permalink
Fix flask example, not working due to duplicated Connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabellaleen committed Mar 30, 2019
1 parent f0b5e1a commit faadf03
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions examples/flask_sqlalchemy/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

Expand All @@ -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])

0 comments on commit faadf03

Please sign in to comment.