-
Notifications
You must be signed in to change notification settings - Fork 229
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
how to handle recursive queries? #114
Comments
Yo! I just managed to solve my problem with a solution that satisfies me for the moment (and because I have no better idea...). It consists in extracting a list of ids from the recursive select and using it to filter the Location objects to return.
Not sure it is the best or more efficient solution but it works... |
Recursive queries are not intended by GraphQL. Here it is described why: |
Unless GQL Spec changes, I don't see a case for adding support for recursive queries. The alternative, for now, is to use the workaround by @Tryph or change the schema design. |
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. |
Hello,
I am trying to handle recursive query with graphene-sqlachemy using a postgres database and cannot find a way to achieve what i want.
I have the following model:
As you can see, this model references itself, and represents a tree of locations. It is mapped by the following graphene type:
The
genealogy
attribute is intended to give access to a list of all parents of a location. To achieve this, theresolve_genealogy
function builds a recursive select query and returns it.The recursive select returns good results but in the form of
models.Location
instances, notLocation
instances.This causes the following error
Exception: Received incompatible instance "(1, 'Parc Hélitas', 0, "'helit':2 'parc':1")".
because the result type is not mapped...Below is the traceback:
Is there a way to map model instances to SQLAlchemyObjectType ones?
Is there a better way to handle recursive queries?
Am I doing it totally wrong? Is there a proper way to get a list of parents recursively?
The text was updated successfully, but these errors were encountered: