Skip to content

Commit

Permalink
prevent uncaught exception with empty GraphQL files
Browse files Browse the repository at this point in the history
  • Loading branch information
dulnan committed Oct 19, 2024
1 parent 75b2413 commit 0fd2d42
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export async function autoImportDocuments(
if (!patterns.length) {
return Promise.resolve([])
}
console.log({ patterns })
const files = (
await resolveFiles(srcResolver(), patterns, {
followSymbolicLinks: false,
Expand Down Expand Up @@ -189,6 +190,10 @@ export async function buildDocuments(
}
return documents
.map((v) => {
// Ignore empty files.
if (!v.content.trim()) {
return null
}
try {
return {
content: inlineFragments(v.content, resolveAlias),
Expand All @@ -204,6 +209,10 @@ export async function buildDocuments(
})
.filter(falsy)
})
.then((docs) => {
// Ignore empty files.
return docs.filter((v) => v.content.trim())
})

if (!autoInlineFragments) {
return documents
Expand Down

0 comments on commit 0fd2d42

Please sign in to comment.