Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset is sometimes empty in production build #57

Closed
zanedev opened this issue May 19, 2022 · 11 comments
Closed

Asset is sometimes empty in production build #57

zanedev opened this issue May 19, 2022 · 11 comments
Labels

Comments

@zanedev
Copy link

zanedev commented May 19, 2022

For some reason the mux asset in Gatsby is sometimes an empty object in production build with no playbackid. We fixed it by temporarily hard coding the playbackID in the front end.

Is this an issue with the mux sanity input or sanity's api or gatsby somehow?

@jimmi-joensson
Copy link

Believe I just experienced the same. Asset kept returning as null in my Sanity data

@mitch-john
Copy link

mitch-john commented Jul 12, 2022

The issue appears to be that when the video asset ID is set, it does not set "_type" to "reference". I modified the package locally in components/input.js where _ref is set to also set _type: 'reference' and manually readded all the videos.


Experiencing the same with Sanity and Gatsby.

The video asset loads in the GraphQL explorer for Sanity:

image

But not the GraphQL explorer for Gatsby:

image

@palmerama
Copy link

I'm having the same issue. Seems like a quick fix to get done properly. Is it likely to happen soon?

@stipsan
Copy link
Member

stipsan commented Jul 25, 2022

Hey y'all, can you test v1.1.4 and see if it fixes it? 😄

@intelligence
Copy link

I'm still seeing this issue in Gatsby. It will work for some time, then for some reason come back as null. If you do gatsby clean and then run gatsby dev it works again. Ping @stipsan

@palmerama
Copy link

Me too! It does set _type to _reference, but that doesn't fix the issue. I gave up in the end and had to write a hugely convoluted custom publish script to pull all the data I need into fields, so it can't just disappear. Not ideal.

@intelligence
Copy link

Related to this sanity-io/gatsby-source-sanity#154, perhaps?

@intelligence
Copy link

@palmerama Would you be able to share your solution? I'm moving into production with a site soonish and this issue is a blocker at the moment.

@zanedev
Copy link
Author

zanedev commented Mar 16, 2023

@intelligence last resort you could write a build script to use the sanity json api instead of the graphql endpoint to pull the mux data during build time then inject it into your gatsby site using an env variable or a gatsby source plugin to read it from a file

@intelligence
Copy link

I think I may have found the underlying issue for why it turns up empty.

Adding:
sanityDocTypes.push('SanityMuxVideo', 'SanityMuxVideoAsset')

After:
https://github.com/sanity-io/gatsby-source-sanity/blob/main/src/gatsby-node.ts#L301
...seems to do the trick. I have no idea how to achieve this in a cleaner way though. For some reason those doc types are not included when looking through the cache.

@hdoro
Copy link
Collaborator

hdoro commented May 20, 2024

This is now fixed with the upcoming 2.4.0

See: #43 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants