Skip to content

Fix filter and sort arguments on interface fields#9137

Merged
michaelstaib merged 2 commits intomainfrom
mst/filter-interface
Feb 18, 2026
Merged

Fix filter and sort arguments on interface fields#9137
michaelstaib merged 2 commits intomainfrom
mst/filter-interface

Conversation

@michaelstaib
Copy link
Copy Markdown
Member

Fixes #8461

@michaelstaib michaelstaib merged commit ef23f90 into main Feb 18, 2026
228 of 230 checks passed
@michaelstaib michaelstaib deleted the mst/filter-interface branch February 18, 2026 15:43
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (a25daf5) to head (7f39931).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #9137   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

Fusion Gateway Performance Results

Simple Composite Query

Req/s Err%
Constant (50 VUs) 2907.96 0.00%
Ramping (0-500-0 VUs) 3357.62 0.00%
Response Times & Query
Min Med Avg P90 P95 Max
Constant 0.81ms 15.09ms 16.97ms 30.79ms 36.16ms 170.93ms
Ramping 0.79ms 64.30ms 66.37ms 123.65ms 138.75ms 256.88ms
query TestQuery {
  topProducts(first: 5) {
    inStock
    name
    price
    shippingEstimate
    upc
    weight
    reviews {
      id
      body
      author {
        id
        username
        name
      }
    }
  }
}

Deep Recursion Query

Req/s Err%
Constant (50 VUs) 739.07 0.00%
Ramping (0-500-0 VUs) 824.70 0.00%
Response Times & Query
Min Med Avg P90 P95 Max
Constant 9.21ms 62.73ms 66.13ms 81.83ms 90.52ms 339.17ms
Ramping 1.84ms 254.76ms 261.57ms 517.20ms 551.51ms 670.87ms
query TestQuery {
  users {
    id
    username
    name
    reviews {
      id
      body
      product {
        inStock
        name
        price
        shippingEstimate
        upc
        weight
        reviews {
          id
          body
          author {
            id
            username
            name
            reviews {
              id
              body
              product {
                inStock
                name
                price
                shippingEstimate
                upc
                weight
              }
            }
          }
        }
      }
    }
  }
  topProducts(first: 5) {
    inStock
    name
    price
    shippingEstimate
    upc
    weight
    reviews {
      id
      body
      author {
        id
        username
        name
        reviews {
          id
          body
          product {
            inStock
            name
            price
            shippingEstimate
            upc
            weight
          }
        }
      }
    }
  }
}

Variable Batching Throughput

Req/s Err%
Constant (50 VUs) 23083.97 0.00%
Ramping (0-500-0 VUs) 18381.86 0.00%
Response Times & Query
Min Med Avg P90 P95 Max
Constant 0.10ms 1.75ms 2.12ms 4.03ms 4.91ms 53.96ms
Ramping 0.10ms 9.48ms 11.50ms 23.58ms 28.40ms 112.73ms
query TestQuery($upc: ID!, $price: Long!, $weight: Long!) {
  productByUpc(upc: $upc) {
    inStock
    shippingEstimate(weight: $weight, price: $price)
  }
}

Variables (5 sets batched per request)

[
  { "upc": "1", "price": 899, "weight": 100 },
  { "upc": "2", "price": 1299, "weight": 1000 },
  { "upc": "3", "price": 15, "weight": 20 },
  { "upc": "4", "price": 499, "weight": 100 },
  { "upc": "5", "price": 1299, "weight": 1000 }
]

Run 22145750356 • Commit da947ec • Wed, 18 Feb 2026 16:00:14 GMT

@MarkArchitect
Copy link
Copy Markdown

There is some problem when using: new type extension API for interfaces, which allows you to add base resolvers for common functionality

With version with abstract class this works

{
    public static IEnumerable<Book> GetFakeBooks()
    {
        return [new Book() {Id=1, Title = "BookTitleTest" }
        , new Book() {Id=2, Title = "BookTitleTest2" }
        , new Book() { Id=3,Title = "BookTitleTest3" }
        , new Book() {Id=4, Title = "BookTitleTest4" }];
    }
}
 


[InterfaceType("SharedInterface")]
public abstract class ISharedInterface
{
    [UsePaging]
    [UseFiltering]
    [UseSorting]
    public IEnumerable<Book> Books(
        [Parent] ISharedInterface parent)

         => FakeData.GetFakeBooks();
}



 
public sealed class AuthorWithData : ISharedInterface
{
    public string Name { get; set; } = default!;
}


[QueryType]
public static partial class QueryWithData
{

    public static AuthorWithData GetAuthor() => new AuthorWithData { Name = "Author" };
    public static Book GetBook() => new Book { Id = 1, Title = "BookTitle" };
}

but with version with new type extension API for interfaces it does not work:

public static class FakeData
{
    public static IEnumerable<Book> GetFakeBooks()
    {
        return [new Book() {Id=1, Title = "BookTitleTest" }
        , new Book() {Id=2, Title = "BookTitleTest2" }
        , new Book() { Id=3,Title = "BookTitleTest3" }
        , new Book() {Id=4, Title = "BookTitleTest4" }];
    }
}
 
[GraphQLName("SharedInterface")]
public interface ISharedInterface
{

}

[InterfaceType<ISharedInterface>]
public static partial class BookInterfaces
{
    [UsePaging]
    [UseFiltering]
    [UseSorting]
    public static IEnumerable<Book> Books(
        [Parent] ISharedInterface parent)

         => FakeData.GetFakeBooks();
}
 
public sealed class AuthorWithData : ISharedInterface
{
    public string Name { get; set; } = default!;
}


[QueryType]
public static partial class QueryWithData
{

    public static AuthorWithData GetAuthor() => new AuthorWithData { Name = "Author" };
    public static Book GetBook() => new Book { Id = 1, Title = "BookTitle" };
}

First there is error

"errors": [
    {
      "message": "The resolver parent type of field `BooksConnection.nodes` is `<>z__ReadOnlyArray`1[HotChocolate.Template.Server.Types.Book]` but the resolver requested the type `HotChocolate.Types.Pagination.IConnection`. The resolver was unable to cast the parent type to the requested type.",
      "path": [
        "author",
        "books",
        "nodes"
      ],
      "extensions": {
        "code": "HC0053",
        "coordinate": "BooksConnection.nodes"
      }
    }
  ],

Second when i change method to get connection as in this code

[InterfaceType<ISharedInterface>]
public static partial class BookInterfaces
{
    [UsePaging]
    [UseFiltering]
    [UseSorting]
    public static async Task<Connection<Book>> Books(
        [Parent] ISharedInterface parent
        ,QueryContext<Book> query
        ,IResolverContext resolverContext)

         => await FakeData.GetFakeBooks().AsQueryable().With(query).ApplyCursorPaginationAsync(resolverContext);
}

The query predicate and sorting are null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter and sort parameters aren't included if the field is on an interface

2 participants