Need help on customize relay.Connection #108
Comments
Hi @sahmadreza , First of all, did you Also, can you try replacing |
hey @bellini666 Thanks for your reply.
Yes, I just forgot to add
I tried it but it didn't work and all the I found a solution which is like this: ...
@gql.django.type(Collection, filters=CollectionFilter, order=CollectionOrder)
class CollectionNode(relay.Node):
...
@gql.django.connection
def photos(self: Collection) -> List["PhotoNode"]:
return self.photos.filter(is_public=True) |
Now my question is, how can I put a filter for a single for example, I want to show just a photo with a filter @gql.type
class Query:
"""All available queries for this schema."""
photo: Optional[PhotoNode] = gql.django.node(description='Get a single Photo detail.') Query photo(id: "UGhvdG9Ob2RlOjM2"){
id
title
status
} |
Interesting... I'll have to check why your previous solution did not work, since in theory there's not much difference between your previous code and your workaround (except from the fact that you filtered the query)
You can easily define your own custom field in this case and add extra parameters to it |
@bellini666 I'm having a very similar issue. Did you manage to check that?
|
Hey @Nimov , Not yet, but in theory this should be working. Basically the relay resolver will call the type's resolve_node method, which in the case of a django type is defined to call this function:
get_queryset attribute and calls it.
You can try checking if any of those steps are failing, that will bring us closer to the real issue |
Fix ordering with custom filters
@bellini666 I'm running into this same issue. My schema looks similar to the original post: I have a connection as a subfield on a top-level node, and
In that last function, I'm not sure where in this chain the |
Ok I got it to work pretty easily, with this change: main...LucasPickering:strawberry-django-plus:108-connection-fix The trouble with this is that I'm afraid that removing the |
@LucasPickering thanks for taking the time to look at that. After seeing your PR, I wonder if it would be enough to do something similar to You have the The Feel free to open a PR and we can continue the implementation discussion in there :) |
I have types like this and I want the
CollectionNode
to show photos with filteris_public=1
not all photostypes:
schema :
photo_list
query is fine and shows public photos butcollection_list -> photos
not working and show all photosThe text was updated successfully, but these errors were encountered: