Transcript from the "Dates & Custom Scalars" Lesson
>> Scott Moss: Dates. So, basically, if you don't wanna use ints, floats, or strings for dates then come over to Google, date scalar GQL. And I'm sure there's tons of them so let's see, custom scalars, GraphQL, I bet there's one right here. Data Scalar, yep, there's literally example in the documentation of creating a date scalar that you can use.
[00:00:31] So, basically, what you have to do is just like we create resolvers for queries and types, and fields you have to create a resolver for a scalar. So you can make a new scalar with this syntax like saying scalar date then you just need to make a resolver for it using the new graphqlscolortype from Graph QL.
[00:00:46] And, basically, you just need to describe three functions. What happens when that value is parsed. What happens when that value is serialized, like when it's sent to the client. And what happen when it's literally parse from the AST. So once you define those three functions then you now have a new scalar and this way you can create any scalar you want.
[00:01:06] I mean, you could literally create URL scalar, email scalar, you can do validations in here for [INAUDIBLE], URLs, and emails. You can do whatever you want, you can make whatever scalar you want and then you can use them in your schema like that. So there's tons of packages like that, but a date one is pretty simple, you can even copy and paste that one.