datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 50 forks source link

createResolvers source object with missing properties for media field types #199

Closed JRamos1993 closed 1 year ago

JRamos1993 commented 2 years ago

Hi,

I'm trying to download all the images from datoCMS when building so that I have one less dependency on run-time and so that all my assets point to a local file instead of a remote one with a different domain. I have an article model with Media type on datoCMS, and I can see many of its properties in graphql, such as URL, size, etc.

However, when logging the node object using the createResolvers API, I only see the following:

... "image":{"alt":null,"title":null,"custom_data":{},"focal_point":null,"upload_id":"20946318"} ... The ID is correct, but where is the other information?

Code:

  const { createNode } = actions
  const resolvers = {
    DatoCmsArticle: {
      localImage: {
        type: "File",
        resolve: async (source, args, context, info) => {
          return createRemoteFileNode({
            url: source.entityPayload.attributes.image.url,
            createNode,
            createNodeId,
            reporter,
            cache,
            store,
          })
        },
      },
    },
  }
  createResolvers(resolvers)
}

Am I doing something wrong? Cheers.

matjack1 commented 1 year ago

I think we are going to add support for this natively with this: https://github.com/datocms/gatsby-source-datocms/pull/189