Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

kitten
Copy link
Member

@kitten kitten commented May 4, 2024

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

  • DANGER: The loadFromSDL config signature has changed to accept a rootPath
  • loadFromSDL now uses ts.sys.readDirectory to discover multiple schema files
  • When loadFromSDL is used with a single JSON file nothing changes, otherwise, if multiple files are discovered and one is a JSON file, an error is thrown
  • generate-schema command now accepts multiple input strings

@kitten kitten requested a review from JoviDeCroock May 4, 2024 23:12
Copy link

changeset-bot bot commented May 4, 2024

🦋 Changeset detected

Latest commit: fd4e02f

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant