Skip to content
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

graphene-sqlalchemy > abc-sqlalchemy/next #2

Open
wants to merge 70 commits into
base: next/abc-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
9a0f740
Implement Mechanism to Selectively Override Automatic Field Creations…
jnak Jun 7, 2019
c89cf80
Fix `createConnectionField` deprecation warnings (#229)
jnak Jun 18, 2019
a361c52
[Regression Fix] Call custom resolve functions if provided (#241)
jnak Aug 14, 2019
5eb5559
[Python 2] Add support for unicode field names
aubustou Aug 28, 2019
8ea2086
Add support for generic SQLAlchemy Array type (#246)
Forever-Young Sep 9, 2019
0544f81
Add support for Python enums in sqlalchemy_utils.ChoiceType (#240)
metheoryt Sep 11, 2019
89c3726
ValueError: The options 'only_fields' and 'exclude_fields' cannot be …
clemens-tolboom Oct 23, 2019
98e6fe7
Fix N+1 problem for one-to-one and many-to-one relationships (#253)
jnak Nov 18, 2019
d90de4a
Fix N+1 problem for one-to-many and many-to-many relationships (#254)
jnak Jan 22, 2020
631513f
Add benchmark for connection fields (#259)
jnak Jan 24, 2020
6dca279
Add class property `connection` to `SQLAlchemyObjectType` (#263)
jnak Feb 11, 2020
4c5b4d1
[documentation] Fix Connection patterns (#264)
jnak Feb 12, 2020
7a48d3d
Bump promise to 2.3 (#265)
jnak Feb 12, 2020
17d535e
Add `batching` params (#260)
jnak Feb 12, 2020
3c3442e
Release 2.3.0.dev1 (#266)
jnak Feb 12, 2020
421f8e4
Fix deprecation warning in tests (#268)
dpep Feb 24, 2020
849217a
Add support for Non-Null SQLAlchemyConnectionField (#261)
chrisberks Jun 4, 2020
20ecaea
Release 2.3.0 (#278)
jnak Jun 4, 2020
cba727c
Move from travis to github actions (#316)
mvanlonden Sep 16, 2021
d6dd67e
Graphene v3 (tests) (#317)
richin13 Sep 21, 2021
57cd786
Build clean up (#318)
mvanlonden Sep 21, 2021
7bf0aa5
I resolved spelling and capitalization mistakes. (#290)
quinnkj Apr 8, 2022
771f4f5
Fix for import from graphql-relay-py (#329) (#330)
Cito Apr 27, 2022
869a55b
Add support for N-Dimensional Arrays
jbeard4 Apr 28, 2022
5da2048
🥅 Don't suppress SQLAlchemy errors when mapping classes (#169)
connorbrinton Apr 28, 2022
0820da7
Support setting @hybrid_property's return type from the functions typ…
flipbit03 Apr 29, 2022
b0aa63c
Added suport for Optional[T] in @hybrid_property's type annotation in…
flipbit03 May 3, 2022
a47dbb3
Pick up the docstrings of hybrid properties (#344)
bim9262 May 5, 2022
294d529
Update README.md
erikwrede Jun 2, 2022
f16d434
Add Python 3.10 & Update Build Scripts (#352)
erikwrede Jun 3, 2022
a702569
Native support for additional Type Converters (#353)
erikwrede Jul 15, 2022
dfee3e9
Release new beta
erikwrede Jul 15, 2022
a03a8b1
Use Graphene DataLoader in graphene>=3.1.1 (#360)
erikwrede Sep 8, 2022
bb7af4b
3.0.0b3
erikwrede Sep 8, 2022
43df4eb
feat: Support Sorting in Batch ConnectionFields & Deprecate UnsortedC…
PaulSchweizer Sep 9, 2022
b3657b0
Add Black to pre-commit (#361)
erikwrede Sep 12, 2022
0a765a1
Made Relationshiploader utilize the new and improved DataLoader imple…
flipbit03 Sep 13, 2022
75abf0b
feat: Add support for UUIDs in `@hybrid_property`-ies (#363)
flipbit03 Oct 1, 2022
8bfa1e9
chore: limit CI runs to master pushes & PRs (#366)
erikwrede Nov 21, 2022
2edeae9
feat: Support GQL interfaces for polymorphic SQLA models (#365)
polgfred Nov 28, 2022
32d0d18
feat: support for async sessions (#350)
jendrikjoe Dec 21, 2022
a03e74d
docs: fix installation instruction (#372)
zahrevsky Jan 2, 2023
2041835
refactor!: use the same conversion system for hybrids and columns (#371)
erikwrede Jan 4, 2023
d3a4320
feat!: Stricter non-null fields for relationships (#367)
polgfred Jan 13, 2023
1708fcf
fix: allow type converter inheritance again (#377)
erikwrede Jan 27, 2023
185a662
docs: add docs pipeline
erikwrede Feb 24, 2023
686613d
docs: extend docs and add autodoc api docs
erikwrede Feb 24, 2023
aa668d1
docs: add relay to index
erikwrede Feb 24, 2023
39a64e1
docs: fix sphinx problems and add autodoc
erikwrede Feb 24, 2023
e175f87
housekeeping: add issue management workflow
erikwrede Feb 24, 2023
ba0597f
chore: limit lint runs to master pushes and PRs (#382)
sabard Feb 27, 2023
506f58c
fix: warnings in docs build (#383)
sabard Feb 27, 2023
3720a23
release: 3.0.0b4
erikwrede Feb 27, 2023
2ca659a
docs: update PyPI page (#384)
sabard Feb 27, 2023
882205d
fix: set README content_type (#385)
sabard Feb 27, 2023
d0668cc
feat: SQLAlchemy 2.0 support (#368)
erikwrede May 14, 2023
f5f05d1
docs: Add database session to the example (#249)
clemens-tolboom Oct 6, 2023
1436807
feat: association_proxy support (#267)
dpep Oct 6, 2023
b94230e
chore: recreate loader if old loader is on different loop (#395)
zeptonaut Oct 9, 2023
c927ada
feat: add filters (#357)
sabard Dec 4, 2023
ae4f87c
fix: keep converting tuples to strings for composite primary keys in …
erikwrede Dec 4, 2023
9c2bc84
release: 3.0rc1
erikwrede Dec 4, 2023
b30bc92
feat(filters): Added DateTimeFilter (#404)
Salamek Mar 5, 2024
eb9c663
fix: create_filters option now does what it says (#414)
skolazbynek Sep 13, 2024
a6161dd
hoursekeeping: add support for python 3.12 (#417)
richin13 Dec 5, 2024
febdc45
release: 3.0.0rc2
erikwrede Dec 5, 2024
72c3cce
fix: Do not create filter class if create_filters is False (#420)
romeroyonatan Apr 7, 2025
83e0c17
chore: update tests actions
erikwrede Apr 7, 2025
6dbd94f
chore: update deploy actions
erikwrede Apr 7, 2025
4ea6ee8
chore: update lint actions (#421)
erikwrede Apr 7, 2025
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
26 changes: 26 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 🚀 Deploy to PyPI

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build wheel and source tarball
run: |
pip install wheel
python setup.py sdist bdist_wheel
- name: Publish a Python distribution to PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
19 changes: 19 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Deploy Docs

# Runs on pushes targeting the default branch
on:
push:
branches: [master]

jobs:
pages:
runs-on: ubuntu-22.04
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
steps:
- id: deployment
uses: sphinx-notes/pages@v3
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint

on:
push:
branches:
- 'master'
pull_request:
branches:
- '*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run lint 💅
run: tox
env:
TOXENV: flake8
49 changes: 49 additions & 0 deletions .github/workflows/manage_issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Issue Manager

on:
schedule:
- cron: "0 0 * * *"
issue_comment:
types:
- created
issues:
types:
- labeled
pull_request_target:
types:
- labeled
workflow_dispatch:

permissions:
issues: write
pull-requests: write

concurrency:
group: lock

jobs:
lock-old-closed-issues:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v4
with:
issue-inactive-days: '180'
process-only: 'issues'
issue-comment: >
This issue has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related topics referencing
this issue.
close-labelled-issues:
runs-on: ubuntu-latest
steps:
- uses: tiangolo/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
config: >
{
"needs-reply": {
"delay": 2200000,
"message": "This issue was closed due to inactivity. If your request is still relevant, please open a new issue referencing this one and provide all of the requested information."
}
}
44 changes: 44 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Tests

on:
push:
branches:
- 'master'
pull_request:
branches:
- '*'

jobs:
test:
runs-on: ubuntu-latest
strategy:
max-parallel: 10
matrix:
sql-alchemy: [ "1.2", "1.3", "1.4","2.0" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with tox
run: tox
env:
SQLALCHEMY: ${{ matrix.sql-alchemy }}
TOXENV: ${{ matrix.toxenv }}
- name: Upload coverage.xml
if: ${{ matrix.sql-alchemy == '1.4' && matrix.python-version == '3.10' }}
uses: actions/upload-artifact@v4
with:
name: graphene-sqlalchemy-coverage
path: coverage.xml
if-no-files-found: error
- name: Upload coverage.xml to codecov
if: ${{ matrix.sql-alchemy == '1.4' && matrix.python-version == '3.10' }}
uses: codecov/codecov-action@v3
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ __pycache__/
.Python
env/
.venv/
venv/
build/
develop-eggs/
dist/
Expand All @@ -26,6 +27,7 @@ var/
*.egg-info/
.installed.cfg
*.egg
.python-version

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -47,6 +49,7 @@ nosetests.xml
coverage.xml
*,cover
.pytest_cache/
.benchmarks/

# Translations
*.mo
Expand All @@ -67,3 +70,9 @@ target/
# Databases
*.sqlite3
.vscode

# Schema
*.gql

# mypy cache
.mypy_cache/
39 changes: 22 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
default_language_version:
python: python3.7
python: python3.8
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: c8bad492e1b1d65d9126dba3fe3bd49a5a52b9d6 # v2.1.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: ^docs/.*$
- id: trailing-whitespace
- id: trailing-whitespace
exclude: README.md
- repo: git://github.com/PyCQA/flake8
rev: 88caf5ac484f5c09aedc02167c59c66ff0af0068 # 3.7.7
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: flake8
- repo: git://github.com/asottile/seed-isort-config
rev: v1.7.0
- id: isort
name: isort (python)
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
hooks:
- id: seed-isort-config
- repo: git://github.com/pre-commit/mirrors-isort
rev: v4.3.4
- id: pyupgrade
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: isort
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 4.0.0
hooks:
- id: flake8
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

48 changes: 34 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
Please read [UPGRADE-v2.0.md](https://github.com/graphql-python/graphene/blob/master/UPGRADE-v2.0.md)
to learn how to upgrade to Graphene `2.0`.
Version 3.0 is in beta stage. Please read https://github.com/graphql-python/graphene-sqlalchemy/issues/348 to learn about progress and changes in upcoming
beta releases.

---

# ![Graphene Logo](http://graphene-python.org/favicon.png) Graphene-SQLAlchemy [![Build Status](https://travis-ci.org/graphql-python/graphene-sqlalchemy.svg?branch=master)](https://travis-ci.org/graphql-python/graphene-sqlalchemy) [![PyPI version](https://badge.fury.io/py/graphene-sqlalchemy.svg)](https://badge.fury.io/py/graphene-sqlalchemy) [![Coverage Status](https://coveralls.io/repos/graphql-python/graphene-sqlalchemy/badge.svg?branch=master&service=github)](https://coveralls.io/github/graphql-python/graphene-sqlalchemy?branch=master)
# ![Graphene Logo](http://graphene-python.org/favicon.png) Graphene-SQLAlchemy
[![Build Status](https://github.com/graphql-python/graphene-sqlalchemy/workflows/Tests/badge.svg)](https://github.com/graphql-python/graphene-sqlalchemy/actions)
[![PyPI version](https://badge.fury.io/py/graphene-sqlalchemy.svg)](https://badge.fury.io/py/graphene-sqlalchemy)
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/graphql-python/graphene-sqlalchemy?color=green&include_prereleases&label=latest)
[![codecov](https://codecov.io/gh/graphql-python/graphene-sqlalchemy/branch/master/graph/badge.svg?token=Zi5S1TikeN)](https://codecov.io/gh/graphql-python/graphene-sqlalchemy)



A [SQLAlchemy](http://www.sqlalchemy.org/) integration for [Graphene](http://graphene-python.org/).

## Installation

For instaling graphene, just run this command in your shell
For installing Graphene, just run this command in your shell.

```bash
pip install "graphene-sqlalchemy>=2.0"
pip install --pre "graphene-sqlalchemy"
```

## Examples
Expand All @@ -34,7 +39,7 @@ class UserModel(Base):
last_name = Column(String)
```

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

```python
import graphene
Expand All @@ -43,10 +48,10 @@ from graphene_sqlalchemy import SQLAlchemyObjectType
class User(SQLAlchemyObjectType):
class Meta:
model = UserModel
# only return specified fields
only_fields = ("name",)
# exclude specified fields
exclude_fields = ("last_name",)
# use `only_fields` to only expose specific fields ie "name"
# only_fields = ("name",)
# use `exclude_fields` to exclude specific fields ie "last_name"
# exclude_fields = ("last_name",)

class Query(graphene.ObjectType):
users = graphene.List(User)
Expand All @@ -58,6 +63,21 @@ class Query(graphene.ObjectType):
schema = graphene.Schema(query=Query)
```

We need a database session first:

```python
from sqlalchemy import (create_engine)
from sqlalchemy.orm import (scoped_session, sessionmaker)

engine = create_engine('sqlite:///database.sqlite3', convert_unicode=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
# We will need this for querying, Graphene extracts the session from the base.
# Alternatively it can be provided in the GraphQLResolveInfo.context dictionary under context["session"]
Base.query = db_session.query_property()
```

Then you can simply query the schema:

```python
Expand Down Expand Up @@ -104,11 +124,11 @@ schema = graphene.Schema(query=Query)

### Full Examples

To learn more check out the following [examples](examples/):
To learn more check out the following [examples](https://github.com/graphql-python/graphene-sqlalchemy/tree/master/examples/):

- [Flask SQLAlchemy example](examples/flask_sqlalchemy)
- [Nameko SQLAlchemy example](examples/nameko_sqlalchemy)
- [Flask SQLAlchemy example](https://github.com/graphql-python/graphene-sqlalchemy/tree/master/examples/flask_sqlalchemy)
- [Nameko SQLAlchemy example](https://github.com/graphql-python/graphene-sqlalchemy/tree/master/examples/nameko_sqlalchemy)

## Contributing

See [CONTRIBUTING.md](/CONTRIBUTING.md)
See [CONTRIBUTING.md](https://github.com/graphql-python/graphene-sqlalchemy/blob/master/CONTRIBUTING.md)
Loading