craftcms / gatsby-source-craft

Gatsby source plugin for Craft CMS.
MIT License
54 stars 13 forks source link

Asset does not have an id #47

Open richardfrankza opened 3 years ago

richardfrankza commented 3 years ago

On some builds I get this error. I'm not sure how this is possible.

The field "CraftuploadsAsset.id." was explicitly defined as non-nullable via the schema customization API (by yourself or a plugin/theme). This means that this field is not optional and you have to define a value. If this is not your desired behavior and you defined the schema yourself, go to "createTypes" in gatsby-node.js. If you're using a plugin/theme, you can learn more here on how to fix field types:
  361 | fragment AssetFragment on Craft_uploads_Asset {
> 362 |   id
      |   ^
  363 |   focalPoint
  364 |   url
  365 |   height
  366 |   width
  367 |   title
  368 |   caption
  369 |   assetLinkUrl
  370 |   attribution
  371 | }

How is this even possible that an Asset does not have an id?

The error appears on random entries which do have assets.

I'm using:

"gatsby-source-craft": "2.0.2",

Has anyone seen this before. How can I mitigate this?

andris-sevcenko commented 3 years ago

@richardfrankza is this still a relevant issue?

richardfrankza commented 3 years ago

I still get it sometimes - could you point me in the right direction?

andris-sevcenko commented 3 years ago

Hmm, maybe it is something similar to https://github.com/craftcms/gatsby-source-craft/issues/21?

Can you, perhaps, try adding ordering to the Asset queries?

webrgp commented 3 years ago

If you are looking for Craft's Asset id, use remoteId or id: remoteId instead. I personally use uid instead everywhere.