Change loadSchema architecture and make it easier to load schemas?
Closed this issue · 0 comments
dotansimha commented
At the moment, we support multiple inputs, and load the schema out of it. But in case of schema that written in .graphql
AND .ts
files, it won't work.
I think we need to have the following:
loadSchema
should accept a string, which is either aglob
expression (for multiple files, or a single file) or a path string, url with AST.- If the
string
is AST, we should build it and returnDocumentNode
. - If the
string
is url, we should introspect it, build it and returnDocumentNode
. - If the
string
is a glob path, we should execute the glob, and then per each found file, we need to apply the chain-of-responsibility to load from it, in that order: first, try to guess the file according to the extension, then try to load is usingrequire
and look for the exportedschema
ordefault
, otherwise, try to load the file as string, and usegraphql-tag-pluck
to extract content out of it. - Then, all the found types from all files should be merged and exported.