Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One Graph Principle #2

Open
jmpreston opened this issue Feb 19, 2019 · 3 comments
Open

One Graph Principle #2

jmpreston opened this issue Feb 19, 2019 · 3 comments

Comments

@jmpreston
Copy link

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. :-)

@brianschardt
Copy link

Can you post a link to what you are referring to. I dont see how this breaks the one Graph principle.

@jmpreston
Copy link
Author

jmpreston commented Jun 5, 2019

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,
    }),```

@NestorDevs
Copy link

NestorDevs commented Aug 23, 2020

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. (/home/josias/Development/IdeasApp/ideas-api/node_modules/@nestjs/graphql/dist/graphql-types.loader.js:38:23)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants