Tuesday, 25 April 2017

How to require from required file?

I need to require bar from bar.js and foo from foo.js in each file.

How I can do it?

foo.js

const bar = require('./bar');
const foo = 'Hello';
console.log(`${foo} ${bar}!`);
module.exports = foo;

bar.js

const foo = require('./foo');
const bar = 'World';
console.log(`${foo} ${bar}!`);
module.exports = bar;

Main purpose is for have many to many GraphQL connection.

I want to require in rootQuery separate files with lets say postType.js and tagType.js. And I need to query posts from tags, and tags from posts.

Is it possible?



via Vadim Shvetsov

No comments:

Post a Comment