Skip to content

Method data fetcher on root query #3

@alexkrebiehl

Description

@alexkrebiehl

I am trying to leverage your package to make a schema builder. To do this, I scan my package for a certain class annotation, and construct a GraphQLObjectType from any of those classes found.

I'm having a problem with the MethodDataFetcher on methods using this approach (the GraphQLDataFetcher annotation with a separate data fetching class works). When the MethodDataFetcher tries to resolve the field, environment.getSource() is null and the fetcher returns null. This only appears to be a problem for fields defined on the QueryRoot.

A root fields node may be defined like this:

class ModelRootQueries {
  public Model modelById(@GraphQLName("id") String id) {
    // never invoked
    return ModelService.get(id);
  }
}

I am constructing my QueryRoot like so:

GraphQLObjectType node = GraphQLAnnotations.newObject(ModelRootQueries.class);
root.fields(node.getFieldDefinitions();
...
GraphQLSchema schema = newSchema.query(root).build();

In this case, the body of the method is never called, and data ends up being null.

I'd appreciate some insight into whether I'm wiring it incorrectly, or if there's a problem with the MethodDataFetcher's implementation.

Thanks,
Alex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions