Skip to content

Support property lookup by field (not just methods) #40

Closed

Description

@konrad-garus

I'd like to be able to use immutable data types, implemented as classes with public final fields like this:

public class Foo {
    public final String bar;

    public Foo(String bar) {
        this.bar = bar;
    }
}

However, right now graphql-java-tools seems to require bar to be a method or a getter (like getBar()).

I can work this around by adding a getter, but it's really noisy and messy:

public class Foo {
    public final String bar;

    public Foo(String bar) {
        this.bar = bar;
    }

    public String getBar() {
        return bar;
    }
}

Activity

  1. apottere commented on Jul 11, 2017

    @apottere
    Collaborator

    This seems reasonable. Should it only inspect final fields or any public field with that name?

  2. konrad-garus commented on Jul 11, 2017

    @konrad-garus
    Author

    Actually, I would suggest any field. Public or private, final or not. It's similar to what other libraries do, like Spring, Jackson, Hibernate to name a few.

    If it seems too "wide", it could be configurable similar to how Jackson does it.

  3. added a commit that references this issue on Jul 28, 2017
    72e6389
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions