flask-rest-jsonapi icon indicating copy to clipboard operation
flask-rest-jsonapi copied to clipboard

Support for filtering on nested fields

Open kiptoomm opened this issue 6 years ago • 0 comments
trafficstars

I was looking at the sample filtering docs.

If I had my PersonSchema using fields.Nested instead of fields.Relationships, like this:

class PersonSchema(Schema):
    ...
    computers = fields.Nested(ComputerSchema, exclude=('person',))
    ...

How can I perform filtering with a call similar to the one provided in the sample?

For me, GET /persons?filter=[ { "name": "computers", "op": "any", "val": { "name": "serial", "op": "ilike", "val": "%Amstrad%" } } ] HTTP/1.1 Accept: application/vnd.api+json

leads to an error like so:

{
detail: "PersonSchema has no relationship attribute computers",
status: "400",
title: "Invalid filters querystring parameter."
}

Will appreciate any ideas. I'm migrating from flask-restless and would much prefer to keep using nested fields as opposed to relationships to preserve the way my current API clients work

kiptoomm avatar May 28 '19 19:05 kiptoomm