Skip to content

Migrate remaining mutations off legacy [UseProjection] #136

Description

@Dejmenek

Context

Every GraphQL query (GetTournaments, GetTournamentById) already moved off the pre-v16 pagination/projection middleware onto the QueryContext<T> + .With(query) pattern from GreenDonut.Data (see the HotChocolate v16 migration commit and the subsequent implementation-first type migration). Five mutations were never updated and still use the old [UseFirstOrDefault] [UseProjection] pattern, returning IQueryable<T> built from a .Where(...) clause:

  • TournamentMutations.CreateTournament
  • TournamentMutations.UpdateTournament
  • BracketMutations.GenerateBracket
  • BracketMutations.UpdateRound
  • ParticipantMutations.AddParticipant

This is inconsistent with the rest of the schema, and [UseProjection] was never adapted for the resolver-based fields (Owner, Bracket, Participants on Tournament; equivalent fields on Bracket) introduced by the implementation-first migration — it was designed to build a .Select() over plain bound properties, so there's an open question of whether it's doing anything useful for these payload types now, or is just dead weight (or a latent bug source, similar to the totalCount/IncludeTotalCount and email/BindMember bugs already found and fixed in this migration).

Task

Migrate all 5 mutations to the same pattern as TournamentQueries.GetTournamentById:

  • Add a QueryContext<T> query parameter (from GreenDonut.Data).
  • Drop [UseProjection].
  • Apply .With(query) to the final returned IQueryable<T> instead of returning the bare .Where(...) clause.

After migrating, check whether .AddProjections() in GraphQLExtensions.cs has any remaining call sites — if not, remove it along with the HotChocolate.Data projection registration, since nothing in the schema would use [UseProjection] anymore.

Verification

  • dotnet build — confirm compilation.
  • Run TournamentMutationTests, BracketMutationTests, ParticipantMutationTests — confirm no regressions, especially assertions that read owner/bracket/participants/etc. off a mutation payload.
  • Manually verify a mutation payload query selecting only a subset of fields (e.g. createTournament(...) { tournament { id name } }) still returns correctly-shaped data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions