nicolasdao / schemaglue

Naturally breaks down your monolithic graphql schema into bits and pieces and then glue them back together.
BSD 3-Clause "New" or "Revised" License
116 stars 13 forks source link

Allow for usage with TypeScript #10

Closed chrismllr closed 6 years ago

nicolasdao commented 6 years ago

Hi @chrismllr ,

Would you mind to share a dummy typescript project on github that would use schemaglue so that I can review your PR against it? I also need to add unit test.

Thanks a lot.

Cheers,

Nic

chrismllr commented 6 years ago

@nicolasdao Sure, I'll try to get one up and running today

ilgooz commented 6 years ago

can we speed things up please? this is a major issue, options should have an "js" option that supports glob.

lurifaxel commented 6 years ago

This may be out of scope for this PR but it looks like related functionality. I would love to be able to set the actual glob-pattern in the options! That way you could use Typescript while also specifying which files to include (I would use ./*/.resolver.ts). I prefer putting the .graphql-files and the schemas in the same folder as the rest of the code, e.g. together with non-GraphQL related utilities etc., and doing it this way would solve both problems.

nicolasdao commented 6 years ago

Hi @chrismllr, @ilgooz and @lurifaxel ,

First and foremost, huge thanks for @ilgooz and @chrismllr for your PR. After checking @ilgooz, I merged his PR. @chrismllr your PR was ok, but it did not contain any unit test. Plus, @ilgooz PR was pretty much doing what you did.

@lurifaxel , thanks for your suggestion. After cleaning all code, I added a slight change to @ilgooz PR.

By default, schemaglue uses .js files to define resolvers and .graphql files to define schemas. If your project uses Typescript, it is possible to change the default behavior to target resolvers that use .ts files:

const { schema, resolver } = glue('src/graphql', { mode: 'ts' })

You can go even further by defining your own custom globbing rule if you want to only include certain resolver files:

const { schema, resolver } = glue('src/graphql', { mode: 'product/*.js' })

The above will only get resolvers defined under the src/graphql/product/ folder.

You can get access to the latest changes in version 4.0.1.

I've also added more doc about Typescript support.

THANK YOU ALL FOR MAKING THIS PROJECT BETTER!

🙌 🙌🙏

Let me know if I can close this issue.

Cheers,

Nic

nicolasdao commented 6 years ago

Latest release (4.0.0) fixes this issue. I'm closing this.