Support for PropertyDataFetcher behavior
When using graphql-java alone and taking the approach of writing DataFetchers, the framework will allow you to return a Map object that contains the property names and values for the corresponding GraphQL type and the framework will then map this to the appropriate GraphQL type using the PropertyDataFetcher (as described in https://graphql-java.readthedocs.io/en/latest/schema.html under DataFetcher and TypeResolver).
This same behavior was not supported when using graphql-java-tools with the GraphQLResolver approach up until now.
Here is an example:
public class Book {
private int id;
private String name;
private int authorId;
// constructor and getters/setters ...
}
public class BookResolver implements GraphQLResolver<Book> {
public Map author(Book book) {
return Collections.unmodifiableMap(new HashMap<String, Object>() {
{
put("id", "1");
put("name", "smith");
}
});
}
}
The GraphQL schema file is:
type Query {
books: [Book!]
}
type Book {
id: Int!
name: String!
author: Author!
}
type Author {
id: Int!
name: String!
}
Option for disabling introspection query
Graphql-java provides a feature to disable the introspection query: https://graphql-java.readthedocs.io/en/latest/execution.html?highlight=introspection#limiting-field-visibility. They do warn that it puts your server in contravention of the GraphQL specification and expectations of most clients so use this with caution.