Error trying to generate datocms types

While generating types for datocms I’m finding this weird issue.

Where the type that shows in datoCMS is FileField.

Where is this type ImageFileField coming from?

Hello @dev14 and welcome to the community!

Can you send us at the URL of the project where you are receiving that error on codegen? Thank you!


We have exactly the same issue. After having changed FileField to ImageFileField the codegen stopped throwing errors on images we load from DatoCMS.

This field type is nowhere documented, not even under the API Explorer within DatoCMS.

This case has been resolved, but it would be great to log the resolution or root cause here.

Best regards,

1 Like

Hello @ivar.van.der.burg can you send us the body of the graphql query you are trying to generate the types from as well as any possible fragments you may have inside of it?

Thank you!

Seeing a similar issue:

The query

fragment ImageVariants on FileField {
  default: responsiveImage(imgixParams: { fit: crop, w: 1440, auto: format }) {
  landscape: responsiveImage(
    imgixParams: { fit: crop, w: 1440, ar: "16:9", auto: format }
  ) {
  portrait: responsiveImage(
    imgixParams: { fit: crop, w: 768, ar: "9:16", auto: format }
  ) {

fragment Image on ImageRecord {
  image {

Now if I run my generator I get the following:

Fragment "ImageVariants" cannot be spread here as objects of type "AltFileField" can never be of type "FileField".
      at /Users/herge/Fully/projects/folkteatern-web/src/graphql/fragments/blocks/Image.graphql:26:5

Which doesn’t happen if I switch to “AltFileField” as the error suggests - but that type doesn’t exist in the API.

Any help would be much appreciated!

@emil.hernqvist, sorry for the late reply here, I missed this when you first posted it.

Could you please try fragment ImageVariants on FileFieldInterface instead of FileField? That may or may not work.

If it doesn’t, could you please share your project URL with us (either here or via email at so I can take a look at your schema?

Hey @roger, thanks for the response. That does seem to work! Sneaky.

1 Like