Skip to content

Commit 86a9838

Browse files
authored
Merge branch 'master' into map-uuid
2 parents 64839d3 + 869a55b commit 86a9838

34 files changed

+1604
-293
lines changed

Diff for: .github/workflows/deploy.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 🚀 Deploy to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Set up Python 3.9
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.9
18+
- name: Build wheel and source tarball
19+
run: |
20+
pip install wheel
21+
python setup.py sdist bdist_wheel
22+
- name: Publish a Python distribution to PyPI
23+
uses: pypa/[email protected]
24+
with:
25+
user: __token__
26+
password: ${{ secrets.PYPI_API_TOKEN }}

Diff for: .github/workflows/lint.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up Python 3.9
12+
uses: actions/setup-python@v2
13+
with:
14+
python-version: 3.9
15+
- name: Install dependencies
16+
run: |
17+
python -m pip install --upgrade pip
18+
pip install tox
19+
- name: Run lint 💅
20+
run: tox
21+
env:
22+
TOXENV: flake8

Diff for: .github/workflows/tests.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
max-parallel: 10
10+
matrix:
11+
sql-alchemy: ["1.2", "1.3", "1.4"]
12+
python-version: ["3.6", "3.7", "3.8", "3.9"]
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install tox tox-gh-actions
24+
- name: Test with tox
25+
run: tox
26+
env:
27+
SQLALCHEMY: ${{ matrix.sql-alchemy }}
28+
TOXENV: ${{ matrix.toxenv }}
29+
- name: Upload coverage.xml
30+
if: ${{ matrix.sql-alchemy == '1.4' && matrix.python-version == '3.9' }}
31+
uses: actions/upload-artifact@v2
32+
with:
33+
name: graphene-sqlalchemy-coverage
34+
path: coverage.xml
35+
if-no-files-found: error
36+
- name: Upload coverage.xml to codecov
37+
if: ${{ matrix.sql-alchemy == '1.4' && matrix.python-version == '3.9' }}
38+
uses: codecov/codecov-action@v1

Diff for: .gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var/
2626
*.egg-info/
2727
.installed.cfg
2828
*.egg
29+
.python-version
2930

3031
# PyInstaller
3132
# Usually these files are written by a python script from a template
@@ -47,6 +48,7 @@ nosetests.xml
4748
coverage.xml
4849
*,cover
4950
.pytest_cache/
51+
.benchmarks/
5052

5153
# Translations
5254
*.mo
@@ -67,3 +69,6 @@ target/
6769
# Databases
6870
*.sqlite3
6971
.vscode
72+
73+
# mypy cache
74+
.mypy_cache/

Diff for: .travis.yml

-50
This file was deleted.

Diff for: README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A [SQLAlchemy](http://www.sqlalchemy.org/) integration for [Graphene](http://gra
1010

1111
## Installation
1212

13-
For instaling graphene, just run this command in your shell
13+
For installing Graphene, just run this command in your shell.
1414

1515
```bash
1616
pip install "graphene-sqlalchemy>=2.0"
@@ -34,7 +34,7 @@ class UserModel(Base):
3434
last_name = Column(String)
3535
```
3636

37-
To create a GraphQL schema for it you simply have to write the following:
37+
To create a GraphQL schema for it, you simply have to write the following:
3838

3939
```python
4040
import graphene
@@ -43,10 +43,10 @@ from graphene_sqlalchemy import SQLAlchemyObjectType
4343
class User(SQLAlchemyObjectType):
4444
class Meta:
4545
model = UserModel
46-
# only return specified fields
47-
only_fields = ("name",)
48-
# exclude specified fields
49-
exclude_fields = ("last_name",)
46+
# use `only_fields` to only expose specific fields ie "name"
47+
# only_fields = ("name",)
48+
# use `exclude_fields` to exclude specific fields ie "last_name"
49+
# exclude_fields = ("last_name",)
5050

5151
class Query(graphene.ObjectType):
5252
users = graphene.List(User)

Diff for: docs/examples.rst

+2-12
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

Diff for: docs/tips.rst

+1-6
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

Diff for: docs/tutorial.rst

+2-12
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

Diff for: examples/flask_sqlalchemy/schema.py

+4-4
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)

Diff for: examples/nameko_sqlalchemy/README.md

-1
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:

Diff for: examples/nameko_sqlalchemy/database.py

+1-1
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

Diff for: examples/nameko_sqlalchemy/schema.py

+6-9
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)

Diff for: graphene_sqlalchemy/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .fields import SQLAlchemyConnectionField
33
from .utils import get_query, get_session
44

5-
__version__ = "2.2.1"
5+
__version__ = "3.0.0b1"
66

77
__all__ = [
88
"__version__",

0 commit comments

Comments
 (0)