Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ protected <T> Stream<T> getResultStream(TypedQuery<T> query,
}

// Let's execute query and get wrap result into stream
return query.getResultStream()
.peek(entityManager::detach);
return query.getResultList()
.stream();
}

protected Object querySingleResult(final DataFetchingEnvironment environment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

package com.introproventures.graphql.jpa.query.schema.impl;

import static javax.persistence.metamodel.Attribute.PersistentAttributeType.EMBEDDED;

import java.util.Optional;

import javax.persistence.metamodel.Attribute.PersistentAttributeType;
import javax.persistence.metamodel.SingularAttribute;

import org.dataloader.DataLoader;
Expand All @@ -27,6 +28,7 @@
import org.dataloader.MappedBatchLoaderWithContext;

import graphql.GraphQLContext;
import graphql.language.Argument;
import graphql.language.Field;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
Expand Down Expand Up @@ -55,11 +57,12 @@ public Object get(DataFetchingEnvironment environment) {
GraphQLType parentType = environment.getParentType();

Object source = environment.getSource();
Optional<Argument> whereArgument = queryFactory.getArgument(field, "where");
Boolean isOptional = queryFactory.getOptionalArgumentValue(environment,
field,
attribute);
// Resolve collection query if where argument is present
if (isOptional && !PersistentAttributeType.EMBEDDED.equals(attribute.getPersistentAttributeType())) {
if ((whereArgument.isPresent() && isOptional) && !EMBEDDED.equals(attribute.getPersistentAttributeType())) {
Object parentIdValue = queryFactory.getParentIdAttributeValue(source);
String dataLoaderKey = parentType.getName() + "." + Optional.ofNullable(field.getAlias())
.orElseGet(attribute::getName);
Expand Down