You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to support loading multiple schemas into a single TypeSystem, such as loading the selector schema alongside a custom schema that uses the selector type.
One can do this directly via the schema/dsl and schema/dmt packages, but it would require finding those APIs and figuring out how to string them together, so it's not very nice.
Another option is to concatenate the schema files and load them via LoadSchemaBytes. Certainly doable, but it's still hacky, and means that position information will be mangled.
Going with the flow of go:embed and io/fs, I think the following would be nice:
A slight alternative to this proposed API is to instead tweak LoadSchemaFile to also accept directories, to then walk them and load all schema files within. But that's significantly less powerful: it can't be used with embedded directories nor any other form of in-memory filesystem, nor can one choose what files to walk via e.g. filterfs.
Certainly an option as well :) I think my only minor reservation, beyond that it still doesn't support go:embed, is that the API name would remain singular even though it can take multiple arguments.
BigLep
added
the
P2
Medium: Good to have, but can wait until someone steps up
label
Apr 8, 2022
We currently have these three top-level APIs:
It would be nice to support loading multiple schemas into a single
TypeSystem
, such as loading the selector schema alongside a custom schema that uses the selector type.One can do this directly via the schema/dsl and schema/dmt packages, but it would require finding those APIs and figuring out how to string them together, so it's not very nice.
Another option is to concatenate the schema files and load them via
LoadSchemaBytes
. Certainly doable, but it's still hacky, and means that position information will be mangled.Going with the flow of
go:embed
andio/fs
, I think the following would be nice:Then, for instance:
It would walk the entire filesystem, so it would work with directories too, e.g.
//go:embed schemas
. One could still only parse subsets of directory trees via APIs like https://pkg.go.dev/io/fs#Sub or https://github.com/josharian/filterfs.cc @rvagg @hannahhoward per recent graphsync discussions
The text was updated successfully, but these errors were encountered: