0

I have a mutation which accepts WorkspaceDTO(POJO):

public WorkspaceDTO createWorkspace(WorkspaceDTO workspaceDTO) {
        Workspace workspace = workspaceMapper.toEntity(workspaceDTO);
        Workspace newWorkspace = workspaceService.save(workspace);
        return workspaceMapper.toDTO(newWorkspace);
}

WorkspaceDTO

public class WorkspaceDTO implements Serializable {

    private String key;
    private Map<DomainDTO, Map<String, Map<String, EntityDTO>>> entities;

}
public enum DomainDTO {

    DOMAIN_BUILDER
}
public class EntityDTO {
    
    private String key;
    private String id;
    private EntityNumberDTO entityNumber;
    private String defPackageKey;

}
public enum EntityNumberDTO {

    Entity(243L),
    Entity_VERSION(244L);

    private final Long id;

}

GraphQLSchema

 createWorkspace(newWorkspace: WorkspaceInput!): Workspace!

input WorkspaceInput{
    key: String
    ### How to add Map<Domain, Map<String, Map<String, Entity>>>
}

How to generate graphql schema (Map<DomainDTO, Map<String, Map<String, EntityDTO>>> entities) in Workspace Input so that client can make the request.

Raushan-cs
  • 39
  • 6
  • 1
    Does this answer your question? [Return HashMap from GraphQL-Java](https://stackoverflow.com/questions/47674558/return-hashmapstring-object-from-graphql-java) – Herku Jul 31 '21 at 17:22
  • No, i got this class graphql.kickstart.tools.util.ParameterizedTypeImpl cannot be cast to class java.lang.Class (graphql.kickstart.tools.util.ParameterizedTypeImpl is in unnamed module of loader 'app'; java.lang.Class is in module java.base of loader 'bootstrap') – Raushan-cs Aug 02 '21 at 17:10
  • input WorkspaceInput{ key: String entities: [Entities!]} input Entities { key: String! value: Entity! } input Entity { key: String } – Raushan-cs Aug 02 '21 at 17:11
  • I think what is being discussed in the linked question is, that maps in general are not supported by GraphQL. They are not very typeable. The first thing you should think about is what the key really represents. Is it an ID, a url, name, etc. I for myself have never felt the need for a map. As the issue on the GraphQL repo discusses, maps are interesting runtime datastructures, but are not very useful for domain modeling. You might find a suitable type that can be returned as a list. – Herku Aug 02 '21 at 21:19
  • Your EntityDTO seems to have a püroperty "key" already, have you thought about simply dropping the hash map and making it a list? – Herku Aug 02 '21 at 21:21

0 Answers0