Isn’t there a circular reference problem in your schema.js?

Great point about circular dependency! I’ve never tried separating the schema into multiple files for Javascript.

For other languages, e.g., Ruby, it is indeed possible to split the schema into separate files.

Also in languages where your can create a Class from a concatenation of strings, e.g., Ruby has the function ‘constantize’, the nodeInterface can be even simpler without all the “if…else” or “case/switch” statements to return the appropriate Class.

The nodeInterface will return the object’s correct Class with just a single line:

( + ‘Type’).constantize

Like what you read? Give Soon Hin Khor a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.