Skip to content

How to enable logging of exceptions #130

Open
@lewimuchiri

Description

@lewimuchiri

Certain Exceptions occuring during DataFetching are not logged to the console. i.e. their stack-trace. For example, I have the following code:

@GraphQLApi
public class Test {
    @GraphQLMutation(name = "createTerritories")
    public FastTable<ResponseDto> createTerritories(@GraphQLArgument(name = "territories") FastTable<@Valid CreateTerritoryDto> territories) {
        return territoryService.create(territories);
    }
}

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class CreateTerritoryDto{
    @NotNull
    private AppUser territoryHead;
    ...
}

@Getter
@Setter
@AllArgsConstructor
public class AppUser {
    private String login;
    private String name;
    private String phoneNumber;
}

And I was sending this mutation:

mutation {
  createTerritories(
    territories: [{
      territoryHead: {
        login: "1231rdq3re1d2c",
        name: "User",
        phoneNumber: "12345678"
      },
    ...
    }]
  ) {
    status
}

Upon sending that mutation, no exception log is printed on the console but the GraphQL response is:

Value: [{territoryHead={login=1231rdq3re1d2c, name=User, phoneNumber=12345678}, counterNumber=1, ...}] could not be parsed into an instance of javolution.util.FastTable<CreateTerritoryDto>

Upon further investigation, I discovered that the issue was because the AppUser class did not have a default or no-argument constructor. This took a bit of time to discover and it was very easy to fix (by just adding @NoArgsConstructor lombok anotation on that class). It would have been easier to troubleshoot if the exception stack-trace was being printed on the console.
How can I enable printing of such data fetching exceptions?

I've tried this but it doesn't help:

logging:
  level:
    io.leangen: debug

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