From 34d1614d67e97d9885681cae767506f0ab8fca5a Mon Sep 17 00:00:00 2001 From: Jason Lengstorf Date: Sun, 17 Dec 2017 17:29:47 -0600 Subject: [PATCH] feat: check data sources for required properties --- lib/data-sources.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/data-sources.js b/lib/data-sources.js index 09215f4..3b3411b 100644 --- a/lib/data-sources.js +++ b/lib/data-sources.js @@ -66,7 +66,14 @@ const loadDataSourceFromPath = dataSourcePath => { const src = require(dataSourcePath); const dataSource = src.default || src; - // TODO check for required properties. + if (!dataSource.namespace || !dataSource.context || !dataSource.typeDefs) { + error([ + `Error: this data source is missing required properties:`, + dataSourcePath, + ]); + + throw new Error('Invalid data source.'); + } log(` -> successfully loaded ${dataSource.namespace}`);