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

Filter by dynamic schema #213

Open
nazarlitvin opened this issue Sep 12, 2022 · 0 comments
Open

Filter by dynamic schema #213

nazarlitvin opened this issue Sep 12, 2022 · 0 comments

Comments

@nazarlitvin
Copy link

nazarlitvin commented Sep 12, 2022

Hi, in my application, I use before_marshmallow to set the schema based on a user type, in overall it works well, but I faced a few difficulties:

  1. I have to provide a default schema and only then override it. Otherwise, it doesn't work. Like this:
schema = BaseSchema

def before_marshmallow(self, args, kwargs):
  if (kwargs["user_type"] == "A"):
    self.schema = SchemaA
  elif (kwargs["user_type"] == "B"):
    self.schema = SchemaB

But, again, on overall it's OK.

  1. Much important issue is with filtering. With my approach, I'm only able to filter by fields from BaseSchema. Is there any workaround?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant