Skip to content

Commit d4bf019

Browse files
committed
update documentation
1 parent 6dca279 commit d4bf019

File tree

7 files changed

+16
-45
lines changed

7 files changed

+16
-45
lines changed

docs/examples.rst

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,12 @@ Search all Models with Union
1313
interfaces = (relay.Node,)
1414
1515
16-
class BookConnection(relay.Connection):
17-
class Meta:
18-
node = Book
19-
20-
2116
class Author(SQLAlchemyObjectType):
2217
class Meta:
2318
model = AuthorModel
2419
interfaces = (relay.Node,)
2520
2621
27-
class AuthorConnection(relay.Connection):
28-
class Meta:
29-
node = Author
30-
31-
3222
class SearchResult(graphene.Union):
3323
class Meta:
3424
types = (Book, Author)
@@ -39,8 +29,8 @@ Search all Models with Union
3929
search = graphene.List(SearchResult, q=graphene.String()) # List field for search results
4030
4131
# Normal Fields
42-
all_books = SQLAlchemyConnectionField(BookConnection)
43-
all_authors = SQLAlchemyConnectionField(AuthorConnection)
32+
all_books = SQLAlchemyConnectionField(Book.connection)
33+
all_authors = SQLAlchemyConnectionField(Author.connection)
4434
4535
def resolve_search(self, info, **args):
4636
q = args.get("q") # Search query

docs/tips.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,8 @@ Given the model
5050
model = Pet
5151
5252
53-
class PetConnection(Connection):
54-
class Meta:
55-
node = PetNode
56-
57-
5853
class Query(ObjectType):
59-
allPets = SQLAlchemyConnectionField(PetConnection)
54+
allPets = SQLAlchemyConnectionField(PetNode.connection)
6055
6156
some of the allowed queries are
6257

docs/tutorial.rst

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,18 @@ Create ``flask_sqlalchemy/schema.py`` and type the following:
102102
interfaces = (relay.Node, )
103103
104104
105-
class DepartmentConnection(relay.Connection):
106-
class Meta:
107-
node = Department
108-
109-
110105
class Employee(SQLAlchemyObjectType):
111106
class Meta:
112107
model = EmployeeModel
113108
interfaces = (relay.Node, )
114109
115110
116-
class EmployeeConnection(relay.Connection):
117-
class Meta:
118-
node = Employee
119-
120-
121111
class Query(graphene.ObjectType):
122112
node = relay.Node.Field()
123113
# Allows sorting over multiple columns, by default over the primary key
124-
all_employees = SQLAlchemyConnectionField(EmployeeConnection)
114+
all_employees = SQLAlchemyConnectionField(Employee.connection)
125115
# Disable sorting over this field
126-
all_departments = SQLAlchemyConnectionField(DepartmentConnection, sort=None)
116+
all_departments = SQLAlchemyConnectionField(Department.connection, sort=None)
127117
128118
schema = graphene.Schema(query=Query)
129119

examples/flask_sqlalchemy/schema.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ class Query(graphene.ObjectType):
2929
node = relay.Node.Field()
3030
# Allow only single column sorting
3131
all_employees = SQLAlchemyConnectionField(
32-
Employee, sort=Employee.sort_argument())
32+
Employee.connection, sort=Employee.sort_argument())
3333
# Allows sorting over multiple columns, by default over the primary key
34-
all_roles = SQLAlchemyConnectionField(Role)
34+
all_roles = SQLAlchemyConnectionField(Role.connection)
3535
# Disable sorting over this field
36-
all_departments = SQLAlchemyConnectionField(Department, sort=None)
36+
all_departments = SQLAlchemyConnectionField(Department.connection, sort=None)
3737

3838

39-
schema = graphene.Schema(query=Query, types=[Department, Employee, Role])
39+
schema = graphene.Schema(query=Query)

examples/nameko_sqlalchemy/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ Now the following command will setup the database, and start the server:
4646

4747
```bash
4848
./run.sh
49-
5049
```
5150

5251
Now head on over to postman and send POST request to:

examples/nameko_sqlalchemy/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def init_db():
1414
# import all modules here that might define models so that
1515
# they will be registered properly on the metadata. Otherwise
1616
# you will have to import them first before calling init_db()
17-
from .models import Department, Employee, Role
17+
from models import Department, Employee, Role
1818
Base.metadata.drop_all(bind=engine)
1919
Base.metadata.create_all(bind=engine)
2020

examples/nameko_sqlalchemy/schema.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,28 @@
88

99

1010
class Department(SQLAlchemyObjectType):
11-
1211
class Meta:
1312
model = DepartmentModel
14-
interfaces = (relay.Node, )
13+
interfaces = (relay.Node,)
1514

1615

1716
class Employee(SQLAlchemyObjectType):
18-
1917
class Meta:
2018
model = EmployeeModel
21-
interfaces = (relay.Node, )
19+
interfaces = (relay.Node,)
2220

2321

2422
class Role(SQLAlchemyObjectType):
25-
2623
class Meta:
2724
model = RoleModel
28-
interfaces = (relay.Node, )
25+
interfaces = (relay.Node,)
2926

3027

3128
class Query(graphene.ObjectType):
3229
node = relay.Node.Field()
33-
all_employees = SQLAlchemyConnectionField(Employee)
34-
all_roles = SQLAlchemyConnectionField(Role)
30+
all_employees = SQLAlchemyConnectionField(Employee.connection)
31+
all_roles = SQLAlchemyConnectionField(Role.connection)
3532
role = graphene.Field(Role)
3633

3734

38-
schema = graphene.Schema(query=Query, types=[Department, Employee, Role])
35+
schema = graphene.Schema(query=Query)

0 commit comments

Comments
 (0)