graphql-jpa-query icon indicating copy to clipboard operation
graphql-jpa-query copied to clipboard

getResultStream should use query.getResultStream instead of query.getResultList().stream

Open th3nu11 opened this issue 4 years ago • 0 comments

Hi all,

I am writing to you for help to check if my fixed is correct.

Seems that in the class/method GraphQLJpaQueryFactory::getResultStream that should return a stream but to do that the method convert the query stream to list. See code here: https://github.com/introproventures/graphql-jpa-query/blob/aeb8766ac00ae2b5f3c09938df5a720022c89351/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaQueryFactory.java#L264

This thing resolves the entire query and does't use the jpa stream. I think the code should be

 return query.getResultStream()
                    .peek(entityManager::detach);

instead of the actual code:

 return query.**getResultList()
                    .stream()**
                    .peek(entityManager::detach);

Can you confirm if I am right or not?

Regards, Carlo

th3nu11 avatar Mar 17 '21 10:03 th3nu11