Using problem (ignore)
dmalisani opened this issue · comments
I'm trying that it works the following code , but despite I tested qs result is correct just before return... The final result (showed in frontend) is obtained from the default database.
What is there in middle?
This is a no desirable result
def resolve_articulos(self, *args, **kwargs):
-- usuario = args[0].context.user
-- if not usuario.is_authenticated:
---- return Articulo.objects.none()
-- else:
---- db = usuario.perfil.empresa.base_datos
---- if len(db)>0:
------ qs=Articulo.objects.using(db).all()
---- else:
------ qs=Articulo.objects.all()
-- return qs
@dmalisani I'm not sure I understand the problem. Can you include an example of the problem that I can reproduce?
Ok, my English is not very good, but I'll try
There is no much code for show it...
I describe my problem.
Each user has assigned a database (they are named in settings.py)
I'm trying that graphene get results from such database according to user.
Resolve def (pasted in my issue) works fine.
If I print just before return line... I can see right result,
But at front-end (default graphene test front-end) it seems ignore resolve results and shows "default" database results.
The question is... what is trace after def resolve until response for frontend?
There is a bug (I think) in DjangoFilterConnectionField
I have following code:
def resolve_articulos(self, *args, **kwargs):
usuario = args[0].context.user
if not usuario.is_authenticated:
return Articulo.objects.none()
else:
db = usuario.perfil.empresa.base_datos
if len(db)>0:
qs=Articulo.objects.using(db).all()
else:
qs=Articulo.objects.all()
return qs
if I use
articulos = graphene.List(ArticuloNode)
works as I expect (it choices right DB according to user)
but if I use
articulos = DjangoFilterConnectionField(ArticuloNode)
it ignores DB choice and show result from default db
despite that I can see that used right resolve_articulos but It's overrided (overwrited) later.
@dmalisani it seems the issue is related to graphene-django, could you post it there? It will help to localize a fix for it ;)