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

field level relay results limit #3536

Open
2 of 3 tasks
Eraldo opened this issue Jun 8, 2024 · 3 comments
Open
2 of 3 tasks

field level relay results limit #3536

Eraldo opened this issue Jun 8, 2024 · 3 comments

Comments

@Eraldo
Copy link

Eraldo commented Jun 8, 2024

Feature Request Type

  • Core functionality
  • Alteration (enhancement/optimization) of existing feature(s)
  • New behavior

Description

Current:

The maximum of returned results for a relay connection defaults to 100 and can be changed by a schema wide setting:

relay_max_results: int = 100

Example:

MAX_RELAY_RESULTS = 777
schema_config = StrawberryConfig(relay_max_results=MAX_RELAY_RESULTS)

schema = Schema(
    query=Query,
    mutation=Mutation,
    extensions=[
        DjangoOptimizerExtension,
    ],
    config=schema_config,
)

Improvement:

The maximum results returned can be overwritten on a per field level via a field setting.

Example:

@strawberry.type
MAX_RELAY_ITEM_RESULTS = 777

class Query:
    my_items: ListConnectionWithTotalCount[MyItemType] = strawberry_django.connection(
        relay_max_results=MAX_RELAY_ITEM_RESULTS
    )

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@erikwrede
Copy link
Member

I like the approach using StrawberryConfig, as well as the per-field settings - both can be valid use cases (e.g. nested fields with filters on a nested connection). @bellini666 what's your take on this?

@Eraldo happy to review any PR on this if you have the time to push something 😊

@erikwrede
Copy link
Member

I also think we should have this for defaults in relay

@bellini666
Copy link
Member

I like the approach using StrawberryConfig, as well as the per-field settings - both can be valid use cases (e.g. nested fields with filters on a nested connection). @bellini666 what's your take on this?

Me too! Makes sense in my head.

I would maybe just call it max_results, as it is already a field that will exists only in the connection function, meaning relay_ is already implied. (but no strong feelings)

@Eraldo happy to review any PR on this if you have the time to push something 😊

+1

I also think we should have this for defaults in relay

We already have the schema config one, I think the only one missing here is the per-field one.

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

3 participants