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 @@ -102,8 +102,8 @@ public class GraphQLJpaSchemaBuilder implements GraphQLSchemaBuilder {
private Map<Class<?>, GraphQLOutputType> classCache = new HashMap<>();
private Map<EntityType<?>, GraphQLObjectType> entityCache = new HashMap<>();
private Map<ManagedType<?>, GraphQLInputObjectType> inputObjectCache = new HashMap<>();
private Map<EmbeddableType<?>, GraphQLObjectType> embeddableOutputCache = new HashMap<>();
private Map<EmbeddableType<?>, GraphQLInputObjectType> embeddableInputCache = new HashMap<>();
private Map<Class<?>, GraphQLObjectType> embeddableOutputCache = new HashMap<>();
private Map<Class<?>, GraphQLInputObjectType> embeddableInputCache = new HashMap<>();

private static final Logger log = LoggerFactory.getLogger(GraphQLJpaSchemaBuilder.class);

Expand Down Expand Up @@ -206,7 +206,7 @@ private GraphQLFieldDefinition getQueryFieldSelectDefinition(EntityType<?> entit
.build();
}

private Map<ManagedType<?>, GraphQLArgument> whereArgumentsMap = new HashMap<>();
private Map<Class<?>, GraphQLArgument> whereArgumentsMap = new HashMap<>();

private GraphQLArgument getWhereArgument(ManagedType<?> managedType) {
String typeName="";
Expand All @@ -218,7 +218,7 @@ private GraphQLArgument getWhereArgument(ManagedType<?> managedType) {

String type = namingStrategy.pluralize(typeName)+"CriteriaExpression";

GraphQLArgument whereArgument = whereArgumentsMap.get(managedType);
GraphQLArgument whereArgument = whereArgumentsMap.get(managedType.getJavaType());

if(whereArgument != null)
return whereArgument;
Expand Down Expand Up @@ -259,12 +259,12 @@ private GraphQLArgument getWhereArgument(ManagedType<?> managedType) {
.build();

whereArgument = GraphQLArgument.newArgument()
.name(QUERY_WHERE_PARAM_NAME)
.description("Where logical specification")
.type(whereInputObject)
.build();
.name(QUERY_WHERE_PARAM_NAME)
.description("Where logical specification")
.type(whereInputObject)
.build();

whereArgumentsMap.put(managedType, whereArgument);
whereArgumentsMap.put(managedType.getJavaType(), whereArgument);

return whereArgument;

Expand Down Expand Up @@ -475,11 +475,11 @@ private GraphQLArgument getArgument(Attribute<?,?> attribute) {
}

private GraphQLType getEmbeddableType(EmbeddableType<?> embeddableType, boolean input) {
if (input && embeddableInputCache.containsKey(embeddableType))
return embeddableInputCache.get(embeddableType);
if (input && embeddableInputCache.containsKey(embeddableType.getJavaType()))
return embeddableInputCache.get(embeddableType.getJavaType());

if (!input && embeddableOutputCache.containsKey(embeddableType))
return embeddableOutputCache.get(embeddableType);
if (!input && embeddableOutputCache.containsKey(embeddableType.getJavaType()))
return embeddableOutputCache.get(embeddableType.getJavaType());
String embeddableTypeName = namingStrategy.singularize(embeddableType.getJavaType().getSimpleName())+ (input ? "Input" : "") +"EmbeddableType";
GraphQLType graphQLType=null;
if (input) {
Expand All @@ -504,9 +504,9 @@ private GraphQLType getEmbeddableType(EmbeddableType<?> embeddableType, boolean
.build();
}
if (input) {
embeddableInputCache.putIfAbsent(embeddableType, (GraphQLInputObjectType) graphQLType);
embeddableInputCache.putIfAbsent(embeddableType.getJavaType(), (GraphQLInputObjectType) graphQLType);
} else{
embeddableOutputCache.putIfAbsent(embeddableType, (GraphQLObjectType) graphQLType);
embeddableOutputCache.putIfAbsent(embeddableType.getJavaType(), (GraphQLObjectType) graphQLType);
}

return graphQLType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package com.introproventures.graphql.jpa.query.schema.model.embedded;

import javax.persistence.Embedded;
import javax.persistence.Entity;

import lombok.Data;
Expand All @@ -12,5 +13,9 @@
public class Car extends Vehicle {

String brand;

// Shared between Car and Boat. Fixes https://github.com/introproventures/graphql-jpa-query/issues/91
@Embedded
Engine engine;

}
8 changes: 4 additions & 4 deletions graphql-jpa-query-schema/src/test/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ insert into author_phone_numbers(phone_number, author_id) values
('4-123-5678', 4);

-- Car
insert into Car (id, brand) values
(1, 'Ford'),
(2, 'Cadillac'),
(3, 'Toyota');
insert into Car (id, brand, identification) values
(1, 'Ford', 'xxxxx'),
(2, 'Cadillac', 'yyyyy'),
(3, 'Toyota', 'zzzzz');


-- Boat
Expand Down