Skip to content

Commit

Permalink
Merge pull request #5 from MDoreto/fix-defaultvalue-queryfilter
Browse files Browse the repository at this point in the history
🐛 fix: default value for query_filter
  • Loading branch information
MDoreto committed Jan 16, 2024
2 parents 4513efd + 7c80035 commit e5b5b8e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions graphemy/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(
context_getter: callable = None,
permission_getter: callable = None,
dl_filter: callable = None,
query_filter: callable = True,
query_filter: callable = None,
engine=None,
extensions: list = [],
**kwargs,
Expand All @@ -65,7 +65,7 @@ def __init__(
for root, dirs, files in os.walk(Setup.folder):
for file in files:
if file.endswith('.py') and file != '__init__.py':
count +=1
count += 1
module_name = os.path.splitext(file)[0]
module_path = os.path.join(root, module_name)
module_path_rel = os.path.relpath(
Expand Down Expand Up @@ -95,7 +95,7 @@ def __init__(
]:
classes[n] = (cls, module_path_rel)
classes_folder[module_path_rel] = cls
print(count, " loaded files in ", os.getcwd())
print(count, ' loaded files in ', os.getcwd())
need_query = True
need_mutation = True
for n, (cls, path) in classes.items():
Expand Down
9 changes: 6 additions & 3 deletions graphemy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@ async def execute_query(cls, query):
else:
with Session(cls.engine) as session:
r = session.exec(query).all()
return r

@classmethod
def setup(cls, engine, folder=None, get_perm=None, query_filter=True):
def setup(cls, engine, folder=None, get_perm=None, query_filter=None):
if engine and 'async' in engine.__module__:
cls.async_engine = True
cls.engine = engine
if query_filter:
cls.query_filter = query_filter
else:
def query_filter_default(cls,info):

def query_filter_default(cls, info):
return True

cls.query_filter = query_filter_default

if folder:
cls.folder = folder
if get_perm:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "graphemy"
version = "0.3.1"
version = "0.3.2"
description = "A Python library for integrating SQLModel and Strawberry, providing a seamless GraphQL integration with FastAPI and advanced features for database interactions."
authors = ["Matheus Doreto <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit e5b5b8e

Please sign in to comment.