Skip to content

Fix #190 - update flask example version #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/flask_sqlalchemy/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
graphene[sqlalchemy]
SQLAlchemy==1.0.11
Flask==0.10.1
Flask==0.12.4
Flask-GraphQL==1.3.0
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])