Skip to content

Comments

Add generic DataFetcherResult.newBuilder(T data) method#4254

Merged
bbakerman merged 2 commits intographql-java:masterfrom
jord1e:generic-dfr-builder
Feb 22, 2026
Merged

Add generic DataFetcherResult.newBuilder(T data) method#4254
bbakerman merged 2 commits intographql-java:masterfrom
jord1e:generic-dfr-builder

Conversation

@jord1e
Copy link
Contributor

@jord1e jord1e commented Feb 20, 2026

This is something that has always been on my mind, I usually put it in a utility method myself. Would be great if it makes 26.0

It turns:

@MutationMapping
public DataFetcherResult<MyPayload> myField() {
  return DataFetcherResult.<MyPayload>newResult()
      .data(MyPayload.newBuilder().build())
      .localContext(...)
      .build();
}

into

@MutationMapping
public DataFetcherResult<MyPayload> myField() {
  return DataFetcherResult.newResult(MyPayload.newBuilder().build())
      .localContext(...)
      .build();
}

This prevents you from having to write your own generic before newBuilder <>

Thank you for the work as always

@jord1e jord1e force-pushed the generic-dfr-builder branch from 25ebe08 to bc7e739 Compare February 20, 2026 10:51
Copy link
Member

@bbakerman bbakerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough - thanks

@bbakerman bbakerman merged commit f7a2377 into graphql-java:master Feb 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants