We don't have a method to serialize a graphics layer to JSON. Instead, you have to call toJson() on each graphic.
Feature layers, OTOH, have a toJson() method which generates a feature collection. Once you have a JSON object that represents a feature collection, you can stringify it with dojo.toJson(). You can then store the string in your DB and retrieve it to re-create your feature layer later.