feat: Support globs and arrays of paths/globs for the schema
option and generate-schema
command arguments
#287
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thegenerate-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
loadFromSDL
config signature has changed to accept arootPath
loadFromSDL
now usests.sys.readDirectory
to discover multiple schema filesloadFromSDL
is used with a single JSON file nothing changes, otherwise, if multiple files are discovered and one is a JSON file, an error is throwngenerate-schema
command now accepts multiple input strings