ChilliCream / ChilliCream/graphql-platform
Support using [ReferenceResolver] when using resolver types with schema first.
Nobody has claimed this yet.
- 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?
AFAIK, the only option to integrate schema first with Apollo Federation (specifically entity resolution) is to add a type extension that completely overwrites the the key/field and specifies the reference resolver. This seems to go against the idea of doing schema first as extensions seem to occur after the schema is bound. (Unsure if overwriting types with extensions during schema first is really supported)
The solution you'd like
I'd like to be able to use AddResolver<TResolver> and be able to decorate a method on the TResolver class with the [ReferenceResolver] attribute.
Full example:
// Configuration
builder.AddDocumentFromFile("./schema.graphql")
.BindRunetimeType<UserDto>("User")
.AddResolver<UserResolver>("User");
// UserResolver
public class UserResolver
{
[ReferenceResolver]
public Task<UserDto?> ReferenceResolver(int id)
{
return new UserDto(id);
}
}
public record UserDto(string Id);
# schema.graphql
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.0",
import: ["@key"])
type User @key(fields: "id") {
id: ID!
}
Stretch goal, if we could get a schema first example under the Apollo Federation project.
Product
Hot Chocolate
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 tracing schema-first binding through AddDocumentFromFile, BindRunetimeType, and AddResolver, then inspect how [ReferenceResolver] methods are discovered. Done means the provided UserResolver and schema-first Apollo Federation example work without a type extension, with coverage for the demonstrated configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100