Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable logging of exceptions #130

Open
lewimuchiri opened this issue Mar 28, 2023 · 0 comments
Open

How to enable logging of exceptions #130

lewimuchiri opened this issue Mar 28, 2023 · 0 comments

Comments

@lewimuchiri
Copy link

lewimuchiri commented Mar 28, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant