create valid relay schema.json

This commit is contained in:
Eric Hulburd
2016-01-31 17:18:27 -06:00
parent 2c42090cd9
commit c0efde030d
20 changed files with 90004 additions and 266 deletions

View File

@@ -1,26 +0,0 @@
/**
* We get the node interface and field from the Relay library.
*
* The first method defines the way we resolve an ID to its object.
* The second defines the way we resolve an object to its GraphQL type.
*/
import {
nodeDefinitions,
} from 'graphql-relay';
var {nodeInterface, nodeField} = nodeDefinitions(
(globalId) => {
var {type, id} = fromGlobalId(globalId);
return null;
},
(obj) => {
if (obj instanceof Array) {
return Array;
} else {
return null;
}
}
);
export {nodeInterface, nodeField};

View File

@@ -9,7 +9,7 @@ export class PowerDataSeed {
static saveCsv(opts, done){
opts = extend({
path: __dirname + "/../../data/example/power_data.csv"
path: __dirname + "/../../data/power_data.csv"
}, opts || {});
var stream = fs.createReadStream(opts.path),
csvStream = csv.fromStream(stream, {headers: ['house_id', 'time', 'power']}),
@@ -38,7 +38,7 @@ export class PowerDataSeed {
end_date: moment().unix(),
interval: 180, // every 3 minutes (in s)
average: 1400, // Wh
path: __dirname + "/../../data/example/power_data.csv"
path: __dirname + "/../../data/power_data.csv"
}, opts || {});
var row_date = opts.start_date,
@@ -65,7 +65,7 @@ export class PowerDataSeed {
export class HouseSeed {
static saveCsv(opts, done){
opts = extend({
path: __dirname + "/../../data/example/houses.csv"
path: __dirname + "/../../data/houses.csv"
}, opts || {});
var stream = fs.createReadStream(opts.path),
csvStream = csv.fromStream(stream, {headers: ['id', 'name']}),
@@ -85,3 +85,25 @@ export class HouseSeed {
}
}
export class UserSeed {
static saveCsv(opts, done){
opts = extend({
path: __dirname + "/../../data/users.csv"
}, opts || {});
var stream = fs.createReadStream(opts.path),
csvStream = csv.fromStream(stream, {headers: ['username', 'house_id']}),
rows = [];
csvStream.on("data", function(data){
console.log(JSON.stringify(data))
rows.push(data);
});
csvStream.on("end", function(){
console.log(rows);
DB.User.bulkCreate(rows, {validate: true}).then(()=>{
console.log("DONE!")
done();
});
});
}
}