If you are using Apollo graphical tools, I have found that the best way to structure your circuit is to use schemaglue.js (disclaimer: I created this):
const { makeExecutableSchema } = require('graphql-tools')
const { glue } = require('schemaglue')
const { schema, resolver } = glue('src/graphql')
const executableSchema = makeExecutableSchema({
typeDefs: schema,
resolvers: resolver
})
And then you can structure your schema and resolvers with something similar to this:
- src/
|__ graphql/
|__ product/
| |__ schema.js
| |__ resolver.js
|
|__ variant/
|__ schema.js
|__ resolver.js
- index.js
- package.json
I wrote a detailed article about this here .
source
share