Skip to content

Commit

Permalink
Fixed rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Klish committed May 28, 2020
1 parent 10b118a commit aaf621f
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ public void testSubCollectionFetchWithSortingAndFilters() {

String expected = "SELECT example_Book FROM example.Author example_Author__fetch "
+ "JOIN example_Author__fetch.books example_Book "
+ "LEFT JOIN FETCH example_Book.publisher example_Book_publisher "
+ "WHERE example_Book_publisher.name IN (:publisher_name_XXX) AND example_Author__fetch=:example_Author__fetch order by example_Book.title asc";
+ "LEFT JOIN FETCH example_Book.publisher example_Book_publisher "
+ "WHERE example_Book_publisher.name IN (:publisher_name_XXX) AND example_Author__fetch=:example_Author__fetch order by example_Book.title asc";

String actual = query.getQueryText();
actual = actual.replaceFirst(":publisher_name_\\w+", ":publisher_name_XXX");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class GraphQLConversionUtils {
public GraphQLConversionUtils(EntityDictionary entityDictionary, NonEntityDictionary nonEntityDictionary) {
this.entityDictionary = entityDictionary;
this.nonEntityDictionary = nonEntityDictionary;
this.nameUtils = new GraphQLNameUtils(dictionary);
this.nameUtils = new GraphQLNameUtils(entityDictionary);
registerCustomScalars();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import graphql.Scalars;
import graphql.schema.DataFetcher;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLInputObjectType;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLList;
import graphql.schema.GraphQLObjectType;
Expand Down Expand Up @@ -69,8 +68,6 @@ public class ModelBuilder {
private Map<Class<?>, GraphQLObjectType> connectionObjectRegistry;
private Set<Class<?>> excludedEntities;

private HashMap<String, GraphQLInputType> convertedInputs = new HashMap<>();

/**
* Class constructor, constructs the custom arguments to handle mutations
* @param entityDictionary elide entity dictionary
Expand All @@ -82,7 +79,7 @@ public ModelBuilder(EntityDictionary entityDictionary,
DataFetcher dataFetcher, String apiVersion) {
this.generator = new GraphQLConversionUtils(entityDictionary, nonEntityDictionary);
this.entityDictionary = entityDictionary;
this.nameUtils = new GraphQLNameUtils(dictionary);
this.nameUtils = new GraphQLNameUtils(entityDictionary);
this.dataFetcher = dataFetcher;
this.apiVersion = apiVersion;

Expand Down Expand Up @@ -152,7 +149,7 @@ public void withExcludedEntities(Set<Class<?>> excludedEntities) {
* @return The built schema.
*/
public GraphQLSchema build() {
Set<Class<?>> allClasses = dictionary.getBoundClassesByVersion(apiVersion);
Set<Class<?>> allClasses = entityDictionary.getBoundClassesByVersion(apiVersion);

if (allClasses.isEmpty()) {
throw new IllegalArgumentException("None of the provided classes are exported by Elide");
Expand Down Expand Up @@ -265,7 +262,7 @@ private GraphQLObjectType buildQueryObject(Class<?> entityClass) {
log.debug("Building query attribute {} {} with arguments {} for entity {}",
attribute,
attributeClass.getName(),
dictionary.getAttributeArguments(attributeClass, attribute).toString(),
entityDictionary.getAttributeArguments(attributeClass, attribute).toString(),
entityClass.getName());

GraphQLType attributeType =
Expand Down Expand Up @@ -384,22 +381,6 @@ private GraphQLInputType buildInputObjectStub(Class<?> clazz) {

GraphQLInputType attributeType = generator.attributeToInputObject(clazz, attributeClass, attribute);

if (attributeType instanceof GraphQLInputObjectType) {
String objectName = attributeType.getName();
if (!convertedInputs.containsKey(objectName)) {
MutableGraphQLInputObjectType wrappedType =
new MutableGraphQLInputObjectType(
objectName,
((GraphQLInputObjectType) attributeType).getDescription(),
((GraphQLInputObjectType) attributeType).getFields()
);
convertedInputs.put(objectName, wrappedType);
attributeType = wrappedType;
} else {
attributeType = convertedInputs.get(objectName);
}
}

builder.field(newInputObjectField()
.name(attribute)
.type(attributeType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,10 @@
*/
@Slf4j
public class PersistentResourceFetcher implements DataFetcher<Object> {
private final ElideSettings settings;

@Getter
private final NonEntityDictionary nonEntityDictionary;

public PersistentResourceFetcher(ElideSettings settings, NonEntityDictionary nonEntityDictionary) {
this.settings = settings;
public PersistentResourceFetcher(NonEntityDictionary nonEntityDictionary) {
this.nonEntityDictionary = nonEntityDictionary;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public QueryRunner(Elide elide, String apiVersion) {
this.apiVersion = apiVersion;

NonEntityDictionary nonEntityDictionary = new NonEntityDictionary();
PersistentResourceFetcher fetcher = new PersistentResourceFetcher(elide.getElideSettings(),
nonEntityDictionary);
ModelBuilder builder = new ModelBuilder(elide.getElideSettings().getDictionary(), nonEntityDictionary, fetcher, apiVersion);
PersistentResourceFetcher fetcher = new PersistentResourceFetcher(nonEntityDictionary);
ModelBuilder builder = new ModelBuilder(elide.getElideSettings().getDictionary(),
nonEntityDictionary, fetcher, apiVersion);

this.api = new GraphQL(builder.build());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public void checkAttributeArguments() {
dictionary.addArgumentsToAttribute(Book.class, FIELD_PUBLISH_DATE, arguments);

DataFetcher fetcher = mock(DataFetcher.class);
ModelBuilder builder = new ModelBuilder(dictionary, fetcher, NO_VERSION);
ModelBuilder builder = new ModelBuilder(dictionary, new NonEntityDictionary(), fetcher, NO_VERSION);

GraphQLSchema schema = builder.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public PersistentResourceFetcherTest() {
inMemoryDataStore.populateEntityDictionary(dictionary);
NonEntityDictionary nonEntityDictionary = new NonEntityDictionary();
ModelBuilder builder = new ModelBuilder(dictionary, nonEntityDictionary,
new PersistentResourceFetcher(settings, nonEntityDictionary), NO_VERSION);
new PersistentResourceFetcher(nonEntityDictionary), NO_VERSION);

api = new GraphQL(builder.build());

Expand Down

0 comments on commit aaf621f

Please sign in to comment.