question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need to add support for GraphQL (Code First) schema generation using @nrwl/node libraries

See original GitHub issue

Description

Trying to achieve the GraphQL code first schema generation using @nrwl/node libraries. Say for example, we want to segregate all the entities in to separate library of its own kind so that the same classes can be used across the projects and at the same time can be decorated with @ObjectType as well as @Entity decorators for graphql and typeorm to coexist.

However as these libraries will not be compiled into the respective js files per entity (or combined for that matter).

autoSchemaFile: '/schema.gql', The above would result into the following error. GraphQLError [Object]: Query root type must be provided.

as the following import { AuthEntity } from '@nx-ws/shared/data-access';

is the classes within the library are not treated same as the class, when they are under the same project. Shouldn’t there be a way to compile these entities prior to the other projects and entities be stitched to one schema.gql !!!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:19

github_iconTop GitHub Comments

1reaction
nbauacommented, Sep 25, 2020

@vespertilian ,

That’s alright, I can understand, we all have some real world projects to work on. Me also kind of tide up with something. BTW, I tried changing (hard-coding) the compilerOptions - Path of out dir etc,last weekend, however still getting same/similar issue. Once I’ll get some handful amount of bandwidth I’ll jump on to it.

Thanks for kicking back on this thread, it makes me feel alive.

-N Baua

0reactions
vespertiliancommented, Jul 26, 2021

@nguyennhattan1398

So I just use GraphQL code-gen to generate the types for my frontend, from my backend code. So they are separate projects and only linked when I rebuild the type definitions via GraphQL Codegen.

Would have been nice to just use the classes directly but this works well enough for now. GraphQL Codegen also will generate types for your queries so you probably want it anyway.

https://github.com/nrwl/nx-apollo-example

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building a schema | Full-Stack Quickstart - Apollo GraphQL
Enforcing a schema's structure is one of the core features of Apollo Server, a production-ready, open-source library that helps you implement your graph's...
Read more >
GraphQL Code Libraries, Tools and Services
GraphQL code generator with flexible support for custom plugins and templates like Typescript (frontend and backend), React Hooks, resolvers signatures and ...
Read more >
graphqlerror: query root type must be provided. nestjs - You.com
Trying to achieve the GraphQL code first schema generation using @nrwl/node libraries. Say for example, we want to segregate all the entities in...
Read more >
Code-first GraphQL Schema with GraphQL.js - Level Up Coding
For example, clients of this API will likely want to query for data about a specific employee given some employee identifier. The GraphQL...
Read more >
Code-first vs. schema-first development in GraphQL
We review and compare the two approaches to creating a GraphQL service — code-first and schema-first — and take a stance on which...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found