diff --git a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/CalculatedEntityTests.java b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/CalculatedEntityTests.java index e63463bfb..044d298ed 100644 --- a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/CalculatedEntityTests.java +++ b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/CalculatedEntityTests.java @@ -1,11 +1,16 @@ package com.introproventures.graphql.jpa.query.schema; +import java.util.Optional; + import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.tuple; +import static org.assertj.core.api.BDDAssertions.then; import static org.assertj.core.util.Lists.list; import javax.persistence.EntityManager; +import graphql.schema.GraphQLFieldDefinition; +import graphql.schema.GraphQLSchema; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -46,6 +51,9 @@ public GraphQLSchemaBuilder graphQLSchemaBuilder(final EntityManager entityManag @Autowired private GraphQLExecutor executor; + @Autowired + private GraphQLSchemaBuilder schemaBuilder; + @Test public void contextLoads() { Assert.isAssignable(GraphQLExecutor.class, executor.getClass()); @@ -117,4 +125,33 @@ public void testIgnoreFields() { ); } + @Test + public void shouldInheritMethodDescriptionFromBaseClass() { + //when + GraphQLSchema schema = schemaBuilder.build(); + + //then + Optional field = getFieldForType("parentTransientGetter", + "CalculatedEntity", + schema); + then(field) + .isPresent().get() + .extracting("description") + .isNotNull() + .containsExactly("getParentTransientGetter"); + } + + private Optional getFieldForType(String fieldName, + String type, + GraphQLSchema schema) { + return schema.getQueryType() + .getFieldDefinition(type) + .getType() + .getChildren() + .stream() + .map(GraphQLFieldDefinition.class::cast) + .filter(graphQLFieldDefinition -> graphQLFieldDefinition.getName().equals(fieldName)) + .findFirst(); + } + }