How to use graphql-iso-date in makeExecutableSchema?
Like this, just like you would use any other scalar type package: https://www.apollographql.com/docs/graphql-tools/scalars.html#Using-a-package
Let me know if that helps!
Thanks, the following code can also solve my requirement:
Date.prototype.toString = function() {
return this.toISOString();
};
Do I still need to use graphql-iso-date?
@J-F-Liu : yes, because graphql-iso-date support parses Date from the formated string.
Yep - you will get native Date objects in your resolver arguments with the custom scalar, so it is definitely nice!
Would someone like to send a PR to the docs here to add a date example? https://www.apollographql.com/docs/graphql-tools/scalars.html
You want to update https://www.apollographql.com/docs/graphql-tools/scalars.html#Date-as-a-scalar to use graphql-iso-date? Because otherwise, there is already an example there...
Oh, right I forgot there's a date example. Hmmmmmm.... is graphql-iso-date better than the example listed on that page?
Well, for me it is the standard go-to package for using dates, so it might be better than the DIY date example. On the other hand, there is already a JSON example that uses a standard package, so maybe it would be enough to just mention it there?
Yeah for sure. Might be just a small addon with a code snippet. I think we want a DIY example, maybe we can do one for Mongo ObjectIDs or something.