From 7c80035bb76e6025224c0e7f6f75c8dfba7cee51 Mon Sep 17 00:00:00 2001 From: Matheus Doreto Date: Tue, 16 Jan 2024 10:23:38 -0300 Subject: [PATCH] :bug: fix: default value for query_filter --- graphemy/router.py | 6 +++--- graphemy/setup.py | 9 ++++++--- pyproject.toml | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/graphemy/router.py b/graphemy/router.py index f81bfa4..c5a0d44 100644 --- a/graphemy/router.py +++ b/graphemy/router.py @@ -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, @@ -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( @@ -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(): diff --git a/graphemy/setup.py b/graphemy/setup.py index 75b6f14..adefeb1 100644 --- a/graphemy/setup.py +++ b/graphemy/setup.py @@ -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: diff --git a/pyproject.toml b/pyproject.toml index 37ee5f6..ddacce2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] readme = "README.md"