Skip to content

Commit

Permalink
Merge pull request #430 from velias/429-BootstrapError
Browse files Browse the repository at this point in the history
#429 - patched Bootstrap.generateGraphQLSchema when generic type with
  • Loading branch information
phillip-kruger authored Oct 1, 2020
2 parents 2230d81 + ccdb874 commit 34c74cb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ private void createGraphQLInterfaceType(InterfaceType interfaceType) {
GraphQLInterfaceType graphQLInterfaceType = interfaceTypeBuilder.build();
// To resolve the concrete class
this.codeRegistryBuilder.typeResolver(graphQLInterfaceType, new InterfaceResolver(interfaceType));
this.interfaceMap.put(interfaceType.getClassName(), graphQLInterfaceType);
this.interfaceMap.put(interfaceType.getName(), graphQLInterfaceType);
}

private void createGraphQLInputObjectTypes() {
Expand All @@ -316,7 +316,7 @@ private void createGraphQLInputObjectType(InputType inputType) {
}

GraphQLInputObjectType graphQLInputObjectType = inputObjectTypeBuilder.build();
inputMap.put(inputType.getClassName(), graphQLInputObjectType);
inputMap.put(inputType.getName(), graphQLInputObjectType);
}

private void createGraphQLObjectTypes() {
Expand Down Expand Up @@ -369,15 +369,15 @@ private void createGraphQLObjectType(Type type) {
if (type.hasInterfaces()) {
Set<Reference> interfaces = type.getInterfaces();
for (Reference i : interfaces) {
if (interfaceMap.containsKey(i.getClassName())) {
GraphQLInterfaceType graphQLInterfaceType = interfaceMap.get(i.getClassName());
if (interfaceMap.containsKey(i.getName())) {
GraphQLInterfaceType graphQLInterfaceType = interfaceMap.get(i.getName());
objectTypeBuilder = objectTypeBuilder.withInterface(graphQLInterfaceType);
}
}
}

GraphQLObjectType graphQLObjectType = objectTypeBuilder.build();
typeMap.put(type.getClassName(), graphQLObjectType);
typeMap.put(type.getName(), graphQLObjectType);

// Register this output for interface type resolving
InterfaceOutputRegistry.register(type, graphQLObjectType);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.smallrye.graphql.test;

public class ClassWithOneGenericsParam<T> {

public T getParam1() {
return null;
}

public String getName() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ public List<String> listDefault(@DefaultValue("[\"electric\",\"blue\"]") List<St
return values;
}

// issue #429 reproducer part 1
@Query
public ClassWithOneGenericsParam<String> getGeneric1() {
return null;
}

// issue #429 reproducer part 2
@Query
public ClassWithOneGenericsParam<Integer> getGeneric2() {
return null;
}

// This method will be ignored, with a WARN in the log, due to below duplicate
@Name("timestamp")
public TestSource getTestSource(@Source TestObject testObject, String indicator) {
Expand Down

0 comments on commit 34c74cb

Please sign in to comment.