Skip to content

graphql.schema.DataFetchingEnvironment can be an interface #260

Closed

Description

@jimexist

So that it is easier for mocking.

Glad to provide a PR if needed.

Activity

  1. dminkovsky commented on Dec 9, 2016

    @dminkovsky
    Contributor

    That sounds good to me. Thank you!

  2. bbakerman commented on Dec 11, 2016

    @bbakerman
    Member

    Can I make another suggestion... it should generic as well.

        public DataFetcher exampleFetcher() {
        return environment -> {
            GraphContext context = (GraphContext) environment.getContext();
            return supplierMethodCall(context);
        };
    }
    

    With no generics we have the above. The ACTUAL return type is Object so its hard to maintain. But the shape of fetched objects are really important.

    Where as

    public DataFetcher<FooObject> exampleFetcher() {
        return environment -> {
            GraphContext context = (GraphContext) environment.getContext();
            return supplierMethodCall(context);
        };
    }
    

    Tells a maintainer what they need to know. It must return a FooObject and hence so must the method call etc..

    In fact this could be applied to a number of places in GraphQL Java. I think I may raise another issue to cover this specifically rather than hijack this isssue

  3. jimexist commented on Dec 12, 2016

    @jimexist
    ContributorAuthor

    @bbakerman i agree with you but i would go ahead and make my PR smaller - maybe your idea is better implemented in another PR.

  4. dminkovsky commented on Jan 18, 2017

    @dminkovsky
    Contributor

    Fixed in #301. Thank you @jimexist!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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