Graphql-yoga: Array syntax for typeDefs argument not supported

Created on 21 Feb 2018  路  9Comments  路  Source: dotansimha/graphql-yoga

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')) {
image

Is there a way to modularize typeDefs without instantiating GraphQLSchema and passing it to GraphQLServer?

statupr-welcome

Most helpful comment

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

All 9 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kv-pawar picture kv-pawar  路  3Comments

CaptainChemist picture CaptainChemist  路  4Comments

frederikhors picture frederikhors  路  4Comments

2wce picture 2wce  路  4Comments

SebastianEdwards picture SebastianEdwards  路  4Comments