Strawberry GraphQL @ 0.258.0

Released

Add the ability to override the “max results” a relay’s connection can return on a per-field basis.

The default value for this is defined in the schema’s config, and set to 100 unless modified by the user. Now, that per-field value will take precedence over it.

For example:

@strawerry.type
class Query:
    # This will still use the default value in the schema's config
    fruits: ListConnection[Fruit] = relay.connection()
 
    # This will reduce the maximum number of results to 10
    limited_fruits: ListConnection[Fruit] = relay.connection(max_results=10)
 
    # This will increase the maximum number of results to 10
    higher_limited_fruits: ListConnection[Fruit] = relay.connection(max_results=10_000)

Note that this only affects ListConnection and subclasses. If you are implementing your own connection resolver, there’s an extra keyword named max_results: int | None that will be passed to it.

Releases contributed by @bellini666 via #3746