ChilliCream / ChilliCream/graphql-platform
Support for returning Edge types in Mutations for Relay-style connections
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.8k
- Forks
- 810
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 98
Description
Product
Hot Chocolate
Is your feature request related to a problem?
Background
In Relay, there are directives like appendEdge and prependEdge that allow direct insertion of results into a connection. For example, as documented in the Relay documentation, you can easily append or prepend edges to existing connections in mutations.
Current Situation
In Hot Chocolate GraphQL, when using UsePaging for queries, it correctly returns Edge and Node types. However, for mutations, there doesn't seem to be a built-in way to transform and return data in the Edge format.
Question / Feature Request
Is there a recommended approach or existing feature in Hot Chocolate GraphQL for returning Edge types in mutations when working with Relay-style connections? If not, would it be possible to add support for this?
This feature would be particularly useful for maintaining consistency between query and mutation interfaces, especially when working with paginated data or implementing real-time updates to lists.
Any insights or suggestions on how to handle this scenario would be greatly appreciated. Thank you for your time and consideration!
The solution you'd like
I would like to see an attribute or utility function that allows mutation return types to be easily converted to Edge types. Specifically:
An attribute that can be applied to mutation methods, similar to [UsePaging] for queries, but for mutations. For example:
[UseEdgeReturn]
public async Task<FooPayload> AddFooMutation(AddFooInput input)
{
// Implementation
}
This attribute would automatically wrap the return value in an Edge type.
A utility function that can be used within mutation resolvers to convert a return value to an Edge type. For example:
public async Task<FooEdge> AddFooMutation(AddFooInput input)
{
var foo = await _fooService.AddFoo(input);
return foo.ToEdge(); // Utility extension method
}
Either of these solutions would greatly simplify the process of returning Edge types from mutations, maintaining consistency with the Relay specification and making it easier to work with connections in a Relay-compatible way.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing UsePaging behavior and the Relay connection behavior described in the issue. Decide how mutation return values should expose Edge types, then add coverage for the supported behavior; the issue does not name repository files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100