January 2019
Intermediate to advanced
460 pages
10h 33m
English
To pass the database down to our GraphQL resolvers, we create a new object in the server index.js file:
import db from './database';const utils = { db,};
We create a utils object directly under the import statement of the database folder.
The utils object holds all of the utilities that our services might need access to. This can be anything, from third-party tools, to our MySQL, or any other database, such as in the preceding code.
Replace the line where we import the services folder, as follows:
import servicesLoader from './services';const services = servicesLoader(utils);
The preceding code might look weird to you, but what we are doing here is executing the function that is the result of the import statement, ...
Read now
Unlock full access