|
16 | 16 |
|
17 | 17 | package com.introproventures.graphql.jpa.query.schema.impl; |
18 | 18 |
|
| 19 | +import static javax.persistence.metamodel.Attribute.PersistentAttributeType.EMBEDDED; |
| 20 | + |
19 | 21 | import java.util.Optional; |
20 | 22 |
|
21 | | -import javax.persistence.metamodel.Attribute.PersistentAttributeType; |
22 | 23 | import javax.persistence.metamodel.SingularAttribute; |
23 | 24 |
|
24 | 25 | import org.dataloader.DataLoader; |
|
27 | 28 | import org.dataloader.MappedBatchLoaderWithContext; |
28 | 29 |
|
29 | 30 | import graphql.GraphQLContext; |
| 31 | +import graphql.language.Argument; |
30 | 32 | import graphql.language.Field; |
31 | 33 | import graphql.schema.DataFetcher; |
32 | 34 | import graphql.schema.DataFetchingEnvironment; |
@@ -55,11 +57,12 @@ public Object get(DataFetchingEnvironment environment) { |
55 | 57 | GraphQLType parentType = environment.getParentType(); |
56 | 58 |
|
57 | 59 | Object source = environment.getSource(); |
| 60 | + Optional<Argument> whereArgument = queryFactory.getArgument(field, "where"); |
58 | 61 | Boolean isOptional = queryFactory.getOptionalArgumentValue(environment, |
59 | 62 | field, |
60 | 63 | attribute); |
61 | 64 | // Resolve collection query if where argument is present |
62 | | - if (isOptional && !PersistentAttributeType.EMBEDDED.equals(attribute.getPersistentAttributeType())) { |
| 65 | + if ((whereArgument.isPresent() && isOptional) && !EMBEDDED.equals(attribute.getPersistentAttributeType())) { |
63 | 66 | Object parentIdValue = queryFactory.getParentIdAttributeValue(source); |
64 | 67 | String dataLoaderKey = parentType.getName() + "." + Optional.ofNullable(field.getAlias()) |
65 | 68 | .orElseGet(attribute::getName); |
|
0 commit comments