nest-ideas-api
nest-ideas-api copied to clipboard
One Graph Principle
Apollo has released their best practices guide for GraphQL based on their work with hundreds of organizations. One of those principles is that we should use one graph. When I asked online about this I was told that all the big kids are using one schema for all queries, types, and mutations. I'm not sure about resolvers yet but my impression is that one page does it all for all modules. So it lives at the root level. Once source of truth.
You are breaking the graph into their relevant modules as we do with everything else including REST. This architecture should probably be re-examined.
Meanwhile, I'm trying to deal with a mental breakdown from trying to get my head around all of GraphQL in one super module. :-)
Can you post a link to what you are referring to. I dont see how this breaks the one Graph principle.
Nest compiles the schema in one root schema. This example is missing a key setup in app.module.ts. Notice the path join to compile one graph from each module's graphs. This gives us the best of both "one graph" and keeping everything in modules. This is Apollo's conceptual framework: https://principledgraphql.com
imports: [
TypeOrmModule.forRoot(),
GraphQLModule.forRoot({
typePaths: ['./**/*.graphql'],
definitions: {
path: join(process.cwd(), 'src/graphql.schema.ts'),
outputAs: 'class',
},
debug: true,
}),```
I get the following error and cannot advance through the series
UnhandledPromiseRejectionWarning: Error: No type definitions were found with the specified file name patterns: "./**/*.graphql". Please make sure there is at least one file that matches the given patterns.
at GraphQLTypesLoader.