👋 Next.js Conf 2024: Come build, party, run, and connect with us! See all events

Discussion on async schemas and validation functions in Sanity.io

20 replies
Last updated: May 13, 2020
Can
string
type
list
be a promise?
May 13, 2020, 9:20 AM
Hi User, if I recall correctly async schemas are not supported yet, unfortunately. One workaround would be using a custom input component in this case, but that does involve some extra effort.
May 13, 2020, 9:32 AM
Hi User, if I recall correctly async schemas are not supported yet, unfortunately. One workaround would be using a custom input component in this case, but that does involve some extra effort.
May 13, 2020, 9:32 AM
Now that's a concise description! Yeah, makes sense.
Got a little caught up that we define validations alongside the schema (IN THE SCHEMA FILE) that support Promises...
May 13, 2020, 9:40 AM
Concise but in need of elaboration? 😉
Indeed, Promises are supported in validation functions and a few other places. I can see how that is confusing. Hopefully we can expand support for them across the board soon AND improve our docs in the meantime, so you won’t have to find out by trial and error.
May 13, 2020, 9:46 AM
Never had seen the definition "async schemas are not supported".
May 13, 2020, 9:46 AM
Just that there's not a clear border within the schema files where it's actual schema and where those are studio-only enhancements.
May 13, 2020, 9:47 AM
But the notation of "async schemas are not supported" really answers whole lot more to me.
May 13, 2020, 9:47 AM
Thanks!
May 13, 2020, 9:48 AM
That’s because it’s nowhere right now, I think. Will draft up a ‘Gotcha’ on this to include in the docs. And don’t forget about the option to use a custom input component to achieve the above.
May 13, 2020, 9:55 AM
Yeah, I know about the option. The effort is tenfold though.
May 13, 2020, 9:56 AM
Absolutely. I might work on some recipes for these in the next two weeks to make this easier to just grab and run with.
May 13, 2020, 10:01 AM
I'm mentoring a project currently.Just doing the overall guidance not getting deep down into implementation.

So to speak, I'm puppet-master for now.
Am leading a team with 0 previous experience through an asteroid field of learning React, Next.js, Sanity and other tools along the way while working on a production project. I am doing the absolute practical minimum to get the ship going.

I can steer them, I do lessons in-between the PR's, provide resources, fill holes when they're ready etc.

But we're now only in React shenanigans. It doesn't pay off yet for them to start tinkering with the deep customization options of Sanity. Neither the client is paying for that atm.
May 13, 2020, 10:03 AM
So the effort isn't in the sense of actual implementation details, but in the scalability of where we're currently at with the project. 😉
May 13, 2020, 10:05 AM
Recipe is good, installable plugin would be awesome! (While I understand that it could shard the hell out of the Sanity landscape)
May 13, 2020, 10:05 AM
Whew, that sounds like an intense assignment if it also includes learning React for example - JS as well? 😄 Fun stuff. With regard to the latter, I’ll say this very quietly, but a plugin in this direction might be on its way indeed🤞
May 13, 2020, 10:28 AM
It does pack a transition from jQuery era of JS to this new React/webpack/babel era.
May 13, 2020, 10:35 AM
People were amazed by native promises, let alone async/await.
May 13, 2020, 10:36 AM
Spread operators, destructuring. const/let.
May 13, 2020, 10:36 AM
SSR/SSG... a whole new world for peeps over here! 🙂
But we're doing more than OK, I guess I have a knack for putting people on new tracks.
May 13, 2020, 10:43 AM
Not to take anything away from the peeps - they're good bunch of developers, just that they were stuck in the old days.
May 13, 2020, 10:43 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?