HotChocolate configure backend property for filter criteria

HotChocolate configure backend property for filter criteria


0

I have a project using HotChocolate and EFCore where I have the following entities:

public class Entity
{
  public int EntityId { get; set; }
  public string Name { get; set; }
  public string AuthorId { get; set; }
}

public class Author
{
  public string AuthorId { get; set; }
  public string Name { get; set; }
}

There is no association between the Entity and Author tables.
The Author is retrieved by a LEFT JOIN.

The Entity type is exposed in GraphQL as follows:

public class EntityDto
{
  public int EntityId { get; set; }
  public string Name { get; set; }
  public Author Author { get; set; }
}

[UseOffsetPaging, UseProjection, UseFiltering, UseSorting]
public IQueryable<EntityDto> Entities([Service] DbContext dbContext)
{
    return dbContext.Entity
      .GroupJoin(...)
      .Select(...);
}

Now, I’m willing to be able to apply the following filter criteria:

query {
  entities(where: { author: { eq: "John" } }) {
    ...
  }
}

The author filter should get applied on the AuthorId property of the Entity class.

How can I achieve that?


Load 4 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *