ChilliCream / ChilliCream/graphql-platform
Make generated client query interface to implement well known interface
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.8k
- Forks
- 810
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 98
Description
Product
Strawberry Shake
Is your feature request related to a problem?
Each query generates interface with configure API methods:
public partial interface INamedQuery : global::StrawberryShake.IOperationRequestFactory {
INamedQuery With(global::System.Action<global::StrawberryShake.OperationRequest> configure);
INamedQuery WithRequestUri(global::System.Uri requestUri);
INamedQuery WithHttpClient(global::System.Net.Http.HttpClient httpClient);
}
Please introduce well-known interface (IQueryRequestConfigure<T> ?) for these 3 methods and make the generated query client to implement it:
namespace StrawberryShake;
public interface IQueryRequestConfigure<TSelf>
where TSelf : IQueryRequestConfigure<TSelf>
{
TSelf With(Action<OperationRequest> configure);
TSelf WithRequestUri(Uri requestUri);
TSelf WithHttpClient(HttpClient httpClient);
}
public partial interface INamedQuery : global::StrawberryShake.IOperationRequestFactory,
IQueryRequestConfigure<INamedQuery > // added
{
// With / WithRequestUri / WithHttpClient inherited – no longer emitted
global::System.Threading.Tasks.Task<...> ExecuteAsync(...);
global::System.IObservable<...> Watch(...);
}
This will allow global configuration for all requests:
public static class QueryRequestConfigureExtensions
{
public static T ConfigureDefaults<T>(this T operation)
where T : IQueryRequestConfigure<T>
=> operation
.WithRequestUri(requestUri)
.WithHttpClient(httpClient);
}
INamedQuery query = sp.GetRequiredService<INamedQuery>();
IAnotherQuery anotherQuery = sp.GetRequiredService<IAnotherQuery >();
var result = await query
.ConfigureDefaults()
.ExecuteAsync(paging, where: null, ct)
var result = await anotherQuery
.ConfigureDefaults()
.ExecuteAsync(paging, where: null, ct)
Thanks.
The solution you'd like
WithXXX API applicable to all generated clients
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 at Strawberry Shake's generated query-client path and the generated INamedQuery declarations, then trace how With, WithRequestUri, and WithHttpClient are emitted. Introduce the requested shared interface and update generation so query clients implement it without duplicate members. Done when the shown ConfigureDefaults pattern works for generated queries and the existing generation checks remain valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, graphql
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100