Skip to content

Support instrumenting source method call #630

@trehak1

Description

@trehak1

We are currently using our custom GraphQL library (https://github.com/agrpdev/graphql) which is very similar to spring-graphql. We would like to switch to spring-graphql for obvious reasons.

Our code depends heavily on aspects provided by custom annotations and their processing that is done on method call, therefore I am very please with PR #325 and looking forward to it.

The only missing part is support for fields with arguments on DTOs:

public class User {  
  
  // `spring-grapqhl` uses PropertyDataFetcher to fetch this field
  public String getId() {
   return id;
  }  

  // this field is ignored by `spring-graphql`
  @SchemaMapping(field = "permissions")
  public List<Permission> getPermissions(final @Argument("authority") String authority) {
     return this.permissions.stream().filter(p -> p.getAuthority().equals("authority")).toList();
  }
}
@Controller
public class UserController {
  @QueryMapping
  public User getUser(@Argument("id") final String id) {
    return userService.getUser(id);
  }
}

I'd like spring-graphql to call DTO method getPermissions using same logic it uses to call controller methods.

Why?

  1. Better encapsulation of data in DTOs
  2. Less verbose Controllers

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions