0no-co / gql.tada

🪄 Magical GraphQL query engine for TypeScript
https://gql-tada.0no.co
MIT License
2.44k stars 34 forks source link

feat: Support globs and arrays of paths/globs for the `schema` option and `generate-schema` command arguments #287

Open kitten opened 2 months ago

kitten commented 2 months ago

[!NOTE] Marked as draft since it's kind of a proposal, due to it being requested multiple times. Coordination with graphqlsp is also needed. We may also want to use this opportunity to work on error handling (?) The risk of errors increases by a lot when we accept multiple SDL files, that have potentially not been processed by other tools.

Summary

This has been requested multiple times now, and I thought I'd take a stab at implementing it.

When applied, this PR allows the schema option to accept arrays of paths, arrays of globs, and globs. This means that multiple SDL files can now be merged into a single one with the generate-schema command and that the SDL loader will discover multiple files.

This has been implemented using ts.sys.readDirectory, which should already support this pretty comprehensively.

When multiple .json files are discovered, an error is thrown.

The risk of errors increases by a lot when we accept multiple SDL files, that have potentially not been processed by other tools. This is because they might have been hand-written and not validated by any other tool. I haven't figured out yet what to do about this, especially since GraphQLSP/TSServer cannot output global errors. I'm currently thinking, we can only merge this if we have a strategy for surfacing global errors in graphqlsp.

Set of changes

changeset-bot[bot] commented 2 months ago

🦋 Changeset detected

Latest commit: fd4e02f71e3c10232f47184c33e636eae5a34bc4

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR