Description
Is your feature request related to a problem? Please describe.
When using loadFilesSync()
to load GraphQL SDL files (e.g., **/*.graphql
), if no matching files are found (e.g., due to a wrong glob pattern or missing files), the function silently returns an empty array []
without any warning or error.
This becomes problematic when used with buildSchema() or similar utilities.
Functions such as addElementsToSchema will injec
5973
t default federation directives (e.g., version 1) when none are explicitly defined.
This can lead to federation version conflicts when the resulting schema is later merged with another schema that includes a different version of federation directives, and it is not easy to debug to find root cause.
Describe the solution you'd like
Add warning log when result is empty array.
// load-files/src/index.ts
export function loadFilesSync<T = any>(
pattern: string | string[],
options: LoadFilesOptions = LoadFilesDefaultOptions,
): T[] {
// ...
const result = relevantPaths
.map(path => {
...
})
.filter(v => v);
if(result.length === 0) {
console.warn(
'[loadFilesSync] No GraphQL schema files were loaded. Please check your glob pattern or file extensions.'
);
}
return result;
}
Describe alternatives you've considered
Additional context