File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed
examples/flask_sqlalchemy Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,16 @@ def init_db():
18
18
Base .metadata .drop_all (bind = engine )
19
19
Base .metadata .create_all (bind = engine )
20
20
21
- department = Department (name = 'Informatics' )
22
- db_session .add (department )
21
+ # Create the fixtures
22
+ engineering = Department (name = 'Engineering' )
23
+ db_session .add (engineering )
24
+ hr = Department (name = 'Human Resources' )
25
+ db_session .add (hr )
23
26
24
- db_session .add (department )
25
- employee = Employee (name = 'Peter' , department = department )
26
- db_session .add (employee )
27
+ peter = Employee (name = 'Peter' , department = engineering )
28
+ db_session .add (peter )
29
+ roy = Employee (name = 'Roy' , department = engineering )
30
+ db_session .add (roy )
31
+ tracy = Employee (name = 'Tracy' , department = hr )
32
+ db_session .add (tracy )
27
33
db_session .commit ()
Original file line number Diff line number Diff line change 1
1
graphene [sqlalchemy ]
2
- graphql_flask == 1.0 .0
2
+ graphql_flask == 1.1 .0
3
3
SQLAlchemy == 1.0.11
4
4
Flask == 0.10.1
Original file line number Diff line number Diff line change 1
1
import graphene
2
2
from graphene import relay
3
- from graphene .contrib .sqlalchemy import SQLAlchemyNode
3
+ from graphene .contrib .sqlalchemy import SQLAlchemyNode , SQLAlchemyConnectionField
4
4
from models import Department as DepartmentModel , Employee as EmployeeModel
5
5
6
6
from database import db_session
@@ -22,5 +22,6 @@ class Meta:
22
22
23
23
class Query (graphene .ObjectType ):
24
24
node = relay .NodeField (Department , Employee )
25
+ all_employees = SQLAlchemyConnectionField (Employee )
25
26
26
27
schema .query = Query
You can’t perform that action at this time.
0 commit comments