contrib icon indicating copy to clipboard operation
contrib copied to clipboard

entgql: prefer edge schema over normal edge rel

Open tankbusta opened this issue 2 years ago • 7 comments

Edge Schema's are awesome and allow you to store metadata about a relationship (like when 2 user's first became friends) but the gql generator places both edges (friends and friendship) inside the node. However, the friendship edge looses the ability to filter. I noticed it creates the WhereInput fields inside the Go model but not GraphQL

https://github.com/ent/contrib/blob/7ed77ac9d07696176d7dfd80fd4cb3e8a1334582/entgql/internal/todo/ent/gql_where_input.go#L683-L689

This PR adds support for including the missing WhereInput fields in the schema and dropping the redundant edge on the nodes that have an edge schema. I would consider this a breaking change as it removes an edge that exists today but I struggled wondering how we could support backwards compatibility so I'm open to suggestions.

I will probably need to run the Code Generator on all the examples after we've discussed this a bit more in-depth.

tankbusta avatar Dec 31 '22 02:12 tankbusta