Code splitting GraphQL types causing issues on require

Code splitting GraphQL types causing issues on require


0

I’m going through a graphql & node tutorial and I’m trying to do a bit of code splitting on the various aspects of the repo, splitting the Types, mock data and schema out into their own respective directories.

It seems that the schema and the mock data are playing ball, but the types are proving problematic…

File structure:

└── server/
    ├── mockData/
    │   └── ...
    ├── schema/
    │   └── schema.js
    └── types/
        ├── author.js
        ├── book.js
        └── index.js

index.js

module.exports = {
    BookType: require('./book'),
    AuthorType: require('./author');
};

I know that the Author and Book types work perfectly when both are included within the schema.js file, but split out like this, they are throwing an error…

Expected undefined to be a GraphQL type.

I did see this answer but it left me a bit more confused than when I arrived…

Can somebody help explain in a clearer manner than the question mentioned, and possibly show me the error of my ways?


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *