Skip to content

Self referencing one-to-many with connection paging #449

@BRUS1NATOR

Description

@BRUS1NATOR

Error when requesting self referencing 1-N relationship with connetion paging:

{
  "errors": [
    {
      "message": "Field 'people' - When called from 'VisitLambda', rewriting a node of type 'System.Linq.Expressions.ParameterExpression' must return a non-null value of the same type. Alternatively, override 'VisitLambda' and change it to not visit children of this type."
    }
  ]
}

How to reproduce

With demo project add properties to class Person

[JsonIgnore]
public Person? Parent { get; set; }

public List<Person> Children { get; set; } = [];

Configure ef core

builder.Entity<Person>().HasMany(p => p.Children).WithOne(a => a.Parent);

Configure connection paging

queryType.ReplaceField("people", db => db.People.OrderBy(e => e.Id), "Get a page of people").UseConnectionPaging();

Make a request with children property

{
people(first: 5) {
    edges {
      cursor
      node { # this is your expected Movie context
        id
        name
        children
        {
          id
          name
        }
      }
    }
    pageInfo {
      hasPreviousPage
      hasNextPage
      startCursor
      endCursor
    }
    totalCount
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions