I'm working on migrating an apollo graphql server to graphql-yoga, I'm strugling with modularizing schemas. like described HERE.
I know it's possible to keep using new GraphQLServer passing a GraphQLSchema instead of passing typeDefs and resolvers.
I'm following same approach as above I'm getting this:
if (typeDefs.endsWith('graphql')) {

Is there a way to modularize typeDefs without instantiating GraphQLSchema and passing it to GraphQLServer?
The best way to modularize your schemas is by using graphql-import. You can split your schema into as many different files as you want that way, and import them into your final schema.
Also, you can pass both a string and a filename to typeDefs, so if you are using graphql-import, you can just pass in the filename to that schema file.
While I agree with @kbrandwijk suggestion as the better approach, we should also support the syntax described in the Apollo docs to make the migration easier for people.
Would be great if someone could create a PR for this. 馃檶
Passing in an array of typeDefs and simply concatenating them like graphql-tools does is the worst possible way to combine schema parts. Supporting that greatly undermines the use of graphql-import.
I see what you're saying @kbrandwijk but it still makes it easier for people to incrementally migrate which is very important. However, we just improve documentation around best practices that people see how this would work with graphql-import.
A simple approach such as checking whether the type of typedefs is an array and then reduce it into a single typedef would solve this issue?
I could take a look at this
I think that would be great @eduardomoroni. Can you open a PR for this?
@kbrandwijk
Looking at the code I figured out that we could use graphql-import on the fly, just passing path as typeDefs params.
Is there any example to do so? I think it could be LOT useful having this as part of README.md
I know that using graphql-import is better than using another modularize approach. But if you want to help people to join graphql-yoga things should be more intuitive.
I think that accepting graphql-tools' way of modularizing schema will make yoga friendlier
Most helpful comment
I know that using
graphql-importis better than using another modularize approach. But if you want to help people to joingraphql-yogathings should be more intuitive.I think that accepting
graphql-tools' way of modularizing schema will make yoga friendlier