Skip to content
Merged
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
@@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -117,4 +125,33 @@ public void testIgnoreFields() {
);
}

@Test
public void shouldInheritMethodDescriptionFromBaseClass() {
//when
GraphQLSchema schema = schemaBuilder.build();

//then
Optional<GraphQLFieldDefinition> field = getFieldForType("parentTransientGetter",
"CalculatedEntity",
schema);
then(field)
.isPresent().get()
.extracting("description")
.isNotNull()
.containsExactly("getParentTransientGetter");
}

private Optional<GraphQLFieldDefinition> 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();
}

}