directus / gatsby-source-directus

Source plugin for pulling data into Gatsby from a Directus API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gatsby-source-directus 9.14.4 returns null imageFile data for videos

cdanny358 opened this issue · comments

I have an mp4 video stored in the file library. In gatsby-source-directus v9.14.1 I can make this call in graphiQL:

query MyQuery {
  directus {
    home {
      marquee_video {
        id
        imageFile {
          id
        }
      }
    }
  }
}

and it returns this:

{
  "data": {
    "directus": {
      "home": {
        "marquee_video": {
          "id": "44e55b25-ce2c-49cd-bf41-362f16d55f62",
          "imageFile": {
            "id": "6a9b883e-80c5-5e1c-a8d5-ebe154e03790"
          }
        }
      }
    }
  },
  "extensions": {
    "enableRefresh": "true"
  }
}

however, in v9.14.3 or 9.14.4 it returns this:

{
  "data": {
    "directus": {
      "home": {
        "marquee_video": {
          "id": "44e55b25-ce2c-49cd-bf41-362f16d55f62",
          "imageFile": null
        }
      }
    }
  },
  "extensions": {
    "enableRefresh": "true"
  }
}

imageFile always returns null for videos, at least mp4 videos. Doing a build exhibits the same behavior. Directus itself is at version 9.20.4.

I'm no gatsby user myself, but out of context, this bit sounds like it makes sense to me:

imageFile always returns null for videos

a video isn't an image, so i'm wondering if the gatsby-image-plugin would even take that 🤔

Again, this worked properly in v9.14.1 of the plugin. It's a new issue in 9.14.3 or 4.

Yeah i saw that, just saying that videos not having an "imageFile" makes theoretical sense to me

In theory I agree with you, but in practice you need the publicURL of the video in order to display it, and that info lives only inside imageFile.

I'm pretty sure this broke with this commit: ff89be3 .

gatsby-node.js , line 220 explicitly filters out videos where the previous version did not:
const imageFiles = files.data.filter(file => file.type.indexOf('image') > -1);

FYI, I have the exact same problem if I set up the video as a File rather than an Image in the database: no way to access its target location, which in Gatsby is in imageFile -> publicURL, and is generally of the form /static/2153df92e4f49d6203f61ffcda2ffb48/video.mp4. Plus I can't retrieve the video's dimensions either.