Open cmeeren opened 3 months ago
I see this was labeled Area: F#
, but this is not F#-specific. Here is C# code to repro:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGraphQLServer().AddQueryType<Query>();
var app = builder.Build();
app.MapGraphQL();
app.Run();
public class Query
{
[UsePaging(RequirePagingBoundaries = true, AllowBackwardPagination = false)]
public IEnumerable<string> Test() => new[] { "a" };
}
Here is part of the schema this produces:
type Query {
test(
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
): TestConnection
}
I just discovered that there's no workaround: Applying [<GraphQLNonNullType>]
to the first
parameter in this case has no effect. It's still nullable.
Product
Hot Chocolate
Is your feature request related to a problem?
I am using
UsePaging
. I am returning a bigIEnumerable
and want to require the client to paginate the request, henceRequirePagingBoundaries=true
. At the same time I want to be able to move to offset-based DB pagination later without breaking the client, which means I must disallow backward pagination, henceAllowBackwardPagination=false
.Using this combination of parameters, the query has a
first
parameter and anafter
parameter. However, both of these are nullable/optional in the schema.The solution you'd like
There is the possibility of an improvement here: With this combination of parameters,
first
is required and must be non-null
, otherwise HotChocolate returns an error. This should be reflected in the type system, changingfirst
fromInt
toInt!
.(My assumption is that this is not normally done for
RequirePagingBoundaries=true
because this requires eitherfirst
orlast
, but in combination withAllowBackwardPagination=false
, thefirst
parameter is required.)