Don't query the database schema when calling `serialize`

We need to decorate the types lazily. This is extracted to a separate
API, as there are other refactorings that will be able to make use of
it, and to allow unit testing the finer points more granularly.
Merge pull request #15546 from sgrif/sg-lazy-decorators

Don't query the database schema when calling `serialize`