File usage with GraphQL API

Is it possible to define a custom GraphQL endpoint/mutation with an argument that contains File or FileRef or javax.servlet.http.Part and mapped to Upload scalar?


public class SomeDto {
private File file;

public class GraphQLService {
public void mutateDto(@GraphQLInputField SomeDto dto) {
/// Some logic…

Hi, @nikolay.khoroshevski

Since version 1.1 files could be uploaded using endpoint /graphql/files.
For example using httpie

http POST http://localhost:8080/graphql/files  @/Pictures/1.png "Authorization: Bearer $AUTH_TOKEN"

Response will looks like

    "fileRef": "fs://2022/02/02/ef12d68f-5a04-f6d2-e3ba-187ffe8b19f5?name=",
    "name": "",
    "size": 7778

at this point the file is already saved on the server.

Response contains FileRef string representation of saved file.

Then file ref could be send on server as part of dto via custom mutation. In custom mutation method on back end string representation could be converted to object of FileRef class using FileRef::fromString method.

@JmixEntity(name = "petclinic_PetDto")
public class PetDto {

    @JmixProperty(mandatory = true)
    private UUID id;

    private String photoFileRef;

    public UUID getId() {
        return id;

    public void setId(UUID id) { = id;

    public String getPhotoFileRef() {
        return photoFileRef;

    public void setPhotoFileRef(String photoFileRef) {
        this.photoFileRef = photoFileRef;
public class PetDtoService {

    public PetDto createPetDto(PetDto petDto) {
        FileRef photoFile = FileRef.fromString(petDto.getPhotoFileRef());
        System.out.println("photoFile = " + photoFile);
        return petDto;


Full example could be found at graphql-file-upload-example branch in jmix-petclinic example app.