Sto tentando inutilmente di mappare la risposta di una graphql in un oggetto. Questa è la parte del controller incriminata.
String document = """
query {
entries(entry_ids: "12CA") {
rcsb_id
rcsb_accession_info {
initial_release_date
}
audit_author {
name
}
rcsb_primary_citation {
pdbx_database_id_PubMed
pdbx_database_id_DOI
}
}
}""";
String[] pdbId = {"12CA"};
ClientGraphQlResponse response = graphQlClient.document(document).executeSync();
System.out.println("response: " + response);
Map<String, List<HashMap<String, String>>> obj = response.getData();
ClientResponseField field = response.field("data");
System.out.println("field: " + field);
Data data = field.toEntity(Data.class);
System.out.println("data: " + data);
L'output dei vari print è:
response: {data={entries=[{rcsb_id=12CA, rcsb_accession_info={initial_release_date=1992-10-15T00:00:00Z}, audit_author=[{name=Nair, S.K.}, {name=Christianson, D.W.}], rcsb_primary_citation={pdbx_database_id_PubMed=1910042, pdbx_database_id_DOI=null}}]}}
field: org.springframework.graphql.client.DefaultClientResponseField@540b91dc
data: null
I vari data object sono i seguenti:
@lombok.Data
public class Data {
public List<Entries> entries;
}
@Data
public class Entries {
public String rcsb_id;
public RcsbAccessionInfo rcsb_accession_info;
public List<AuditAuthor> audit_author;
public RcsbPrimaryCitation rcsb_primary_citation;
}
@Data
public class AuditAuthor {
public String name;
}
@Data
public class RcsbAccessionInfo {
public String initial_release_date;
}
@Data
public class RcsbPrimaryCitation {
public Integer pdbx_database_id_PubMed;
public String pdbx_database_id_DOI;
}
Dov'è che sbaglio?