Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Two different classes used for type" reports null class #30

Closed
also opened this issue Jun 29, 2017 · 0 comments
Closed

"Two different classes used for type" reports null class #30

also opened this issue Jun 29, 2017 · 0 comments
Labels

Comments

@also
Copy link
Contributor

also commented Jun 29, 2017

With graphql-java-tools 3.1.2, I get an error that refers to the class null instead of the actual class:

Exception in thread "main" com.coxautodev.graphql.tools.SchemaClassScannerError: Two different classes used for type Scalar:
- class java.lang.Object:
|   return type of method public java.lang.Object com.example.GraphQLToolsErrorExample$Query.a()

- null:
|   return type of method public java.lang.String com.example.GraphQLToolsErrorExample$Query.b()
	at com.coxautodev.graphql.tools.SchemaClassScanner.handleFoundType(SchemaClassScanner.kt:208)
	at com.coxautodev.graphql.tools.SchemaClassScanner.handleFoundType(SchemaClassScanner.kt:193)
	at com.coxautodev.graphql.tools.SchemaClassScanner.handleFieldMethod(SchemaClassScanner.kt:185)
	at com.coxautodev.graphql.tools.SchemaClassScanner.scanObjectForDictionaryItems(SchemaClassScanner.kt:177)
	at com.coxautodev.graphql.tools.SchemaClassScanner.scanForClasses(SchemaClassScanner.kt:95)
	at com.coxautodev.graphql.tools.SchemaParserBuilder.build(SchemaParserBuilder.kt:107)
	at com.example.GraphQLToolsErrorExample.main(GraphQLToolsErrorExample.java:37)

Here's a simple example to reproduce:

package com.example;

import com.coxautodev.graphql.tools.GraphQLRootResolver;
import com.coxautodev.graphql.tools.SchemaParser;

public class GraphQLToolsErrorExample {
  public static class Query implements GraphQLRootResolver {
    public Object a() {
      return "a";
    }
    public String b() {
      return "b";
    }
  }
  public static void main(String... args) {
    SchemaParser.newParser()
        .schemaString("scalar Scalar type Query { a: Scalar b: Scalar}")
        .resolvers(new Query())
        .build()
        .makeExecutableSchema();
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants