ChilliCream / ChilliCream/graphql-platform

Extending edge type with relationship data

Open
#5,036 10 comments 4 reactions 1 assignee View on GitHub

@michaelstaib is already working on this.

Since May 9, 2022.

🌶️ hot chocolate Area: EntityFramework
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

Is your feature request related to a problem?

We use Hot Chocolate on top of EF Core with various entities being in many-to-many relationship with additional relationship data in the join entity types (eg. PostTag.PublicationDate in the sample below).

We would like to add the relationship data to the edge types (as suggested here), but couldn't figure out any way to achieve it.

public class Post
{
    public int PostId { get; set; }
    public string Title { get; set; }
    public string Content { get; set; }

    [UsePaging]
    public ICollection<Tag> Tags { get; set; }

    public ICollection<PostTag> PostTags { get; set; }
}

public class Tag
{
    public string TagId { get; set; }

    [UsePaging]
    public ICollection<Post> Posts { get; set; }

    public ICollection<PostTag> PostTags { get; set; }
}

public class PostTag
{
    public DateTime PublicationDate { get; set; } // should be included in the edge type

    public int PostId { get; set; }
    public Post Post { get; set; }

    public string TagId { get; set; }
    public Tag Tag { get; set; }
}

(we also use projections, filtering and sorting)

The solution you'd like

Any solution, that would allow extending edge types with data from join entity type. For instance placing the UsePaging attribute on the navigation property of the join entity and specifying a selector for node.

public class Tag
{
    public string TagId { get; set; }

    // public ICollection<Post> Posts { get; set; }

    [UsePaging(NodeSelector = "Post"]
    public ICollection<PostTag> Posts { get; set; }
}
Product

Hot Chocolate

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.