commercetools / commercetools/commercetools-sdk-java-v2

Deserialization to type BaseMoney fails

Open
#498 1 comment 0 reactions 1 assignee Claimed by @jenschude View on GitHub
bug
Dominant language
Java
Stars
47
Forks
21
Avg merge
9d 13h
Merged PRs (30d)
4

Description

**Describe the bug**
Querying price information of a product with the graphql-api results in deserialization errors:

Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class com.commercetools.graphql.api.types.BaseMoney]: missing type id property '__typename' (for POJO property 'value')

**To Reproduce**
```java
public class Reproducer {

public static void main(String[] args) {
final ProjectApiRoot client = createApiClient();
Logger logger = LoggerFactory.getLogger(Reproducer.class.getName());

GraphQLResponse responseEntity =
client
.graphql()
.query(GraphQL.products(q -> q.limit(8))
.projection(p -> p.total().results().id().masterData().current().masterVariant().prices().value().centAmount()))
.executeBlocking()
.getBody();
responseEntity.getData().getResults().forEach(result -> {
logger.info("Id: " + result.getId() + "Name: " + result.getMasterData().getCurrent().getName());
logger.info("Id: " + result.getId() + "Name: " + result.getMasterData().getCurrent().getMasterVariant().getPrices());
});
client.close();
}

public static ProjectApiRoot createApiClient() {
var projectApiRoot = ApiRootBuilder.of()
.defaultClient(
ClientCredentials.of()
.withClientId("")
.withClientSecret("");

return projectApiRoot;
}
}
```
**Expected behavior**
Reproducer code should run and price information should be deserialized without an error.

**Screenshots/Code snippet**
Following error is thrown:
Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class com.commercetools.graphql.api.types.BaseMoney]: missing type id property '__typename' (for POJO property 'value')

**Stack information (please complete the following information):**
- Java: 17
- SDK: 16.3.0

**Additional context**
NA

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.