Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Querydsl integration #59

Closed
wants to merge 3 commits into from
Closed

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Jun 18, 2021

Spring Data repositories that support Querydsl are now supported as DataFetchers returning single objects and iterables including projection support.

interface ArtifactRepositories extends CrudRepository<ArtifactRepository, String>, QuerydslPredicateExecutor<ArtifactRepository> {}

ArtifactRepositories repositories = …;
DataFetcher<ArtifactRepository> single = QuerydslDataFetcherSupport.builder(repositories).single();
DataFetcher<Iterable<ArtifactRepository>> many = QuerydslDataFetcherSupport.builder(repositories).many();

Querydsl predicates are built from the query arguments and can be customized with QuerydslBinderCustomizer to alter comparison (e.g. starts with instead of equals) for individual properties or to generally augment the query. QuerydslDataFetcherSupport also provides projection support (interface projection, DTO projection):

interface BookProjection {

	@Value("#{target.name + ' by ' + target.author}")
	String getName();

	String getAuthor();
}

ArtifactRepositories repositories = …;
DataFetcher<BookProjection> single = QuerydslDataFetcherSupport.builder(repositories).projectAs(BookProjection.class).single();

Spring Data repositories that support Querydsl are now supported as DataFetchers returning single objects and iterables including projection support.
@rstoyanchev rstoyanchev self-assigned this Jun 22, 2021
@rstoyanchev rstoyanchev added the type: enhancement A general enhancement label Jun 22, 2021
@rstoyanchev rstoyanchev added this to the 1.0 M1 milestone Jun 22, 2021
@rstoyanchev rstoyanchev added the in: data Issues related to working with data label Jun 22, 2021
Copy link
Contributor

@rstoyanchev rstoyanchev left a comment

Choose a reason for hiding this comment

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

I've raised a couple of points around the shape of the public API which might require some moving things around. I'm putting it through for consideration, potentially to make a pass, and I'll have another look and add more comments after when that's settled.

As an extra comment I think it would be good to consider including reactive support as well, perhaps as part of the same builder. I think it's important because we consider how each is exposed from the start and we do support both Spring MVC and WebFlux as foundations.

Rename QuerydslDataFetcherSupport to QuerydslDataFetcher. Add reactive Querydsl support.
rstoyanchev pushed a commit that referenced this pull request Jun 24, 2021
Spring Data repositories that support Querydsl are now supported
as DataFetchers returning single objects and iterables including
projection support.

See gh-59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues related to working with data type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants