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.

Modularising Types in graphql-yoga based server

See original GitHub issue

I am trying to modularise resolvers and typeDefs in separate files using merge-graphql-schemas. They are successfully merged but I am getting the error

Error: Type "Course" not found in document. at ASTDefinitionBuilder._resolveType (/Users/alosiesgeorge/Desktop/vue-code/prisma-tutorial/hello-world/server-graphql/node_modules/graphql/utilities/buildASTSchema.js:134:11)

Folder Structure screen shot 2018-05-22 at 9 50 33 pm

src/graphql/types/courseManagement/courseType.graphql

screen shot 2018-05-22 at 9 58 25 pm

src/graphql/types/courseManagement/sectionType.graphql

screen shot 2018-05-22 at 9 59 34 pm

src/graphql/types/index.js

screen shot 2018-05-22 at 10 00 36 pm

src/index.js screen shot 2018-05-22 at 10 05 02 pm

In Prisma tutorial they say to reference # import User from ‘./generated/prisma.graphql’ on the top of schema.graphql. Where do I reference the same in this modularisation pattern?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

3reactions
lurifaxelcommented, Jun 28, 2018

I’m also curious about how to solve this! Modularizing works just fine for my own .graphql-files but I haven’t been able to incorporate the types defined in the src/generated/prisma.graphql-file. Surely it would be reasonable for the modular-resolvers-example to showcase how to do this?

2reactions
renatocommented, May 27, 2018

I’m having the same issue, even after using the # import directives.

I tried to use importSchema (https://github.com/prismagraphql/graphql-import) directly passing the imported types to mergeTypes, but it failed because of https://github.com/okgrow/merge-graphql-schemas/issues/141 (interfaces don’t get merged, so I get an Error: Type "Node" was defined more than once.).

I think it would help a lot to newcomers if the modular-resolvers example also showed how to import types (I’d try helping if I wasn’t struggling with this myself).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modularising Types in graphql-yoga based server #332 - GitHub
I am trying to modularise resolvers and typeDefs in separate files using merge-graphql-schemas. ... Modularising Types in graphql-yoga based server #332.
Read more >
Getting Started – GraphQL Yoga
How does that help in defining the API for a GraphQL server, though? Every GraphQL schema has three special root types: Query ,...
Read more >
GraphQL Modules tutorial: How to modularize GraphQL schema
In this tutorial, we'll show you how to use GraphQL Modules to break your GraphQL application into simple, reusable, feature-based modules.
Read more >
How To Build a GraphQL Server in Node.js ... - DigitalOcean
We have three types inside our Schema, let's break them down. Using the Query Type. A GraphQL query is for fetching data and...
Read more >
Setting Up A Graphql Server With Node + Graphql-Yoga + ...
resolvers. A resolver is a function that connects schema fields and types to various backends. Resolvers provide the instructions for turning a ...
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