Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursively create dir #364

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rotten-pugs-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@0no-co/graphqlsp': patch
---

Recursively create directories if the target does not exist
4 changes: 0 additions & 4 deletions packages/graphqlsp/src/fieldUsage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ const crawlChainedExpressions = (
const isChained =
ts.isPropertyAccessExpression(ref.expression) &&
arrayMethods.has(ref.expression.name.text);
console.log('[GRAPHQLSP]: ', isChained, ref.getFullText());
if (isChained) {
const foundRef = ref.expression;
const isReduce = foundRef.name.text === 'reduce';
Expand Down Expand Up @@ -250,7 +249,6 @@ const crawlScope = (
// - const pokemon = result.data.pokemon --> this initiates a new crawl with a renewed scope
// - const { pokemon } = result.data --> this initiates a destructuring traversal which will
// either end up in more destructuring traversals or a scope crawl
console.log('[GRAPHQLSP]: ', foundRef.getFullText());
while (
ts.isIdentifier(foundRef) ||
ts.isPropertyAccessExpression(foundRef) ||
Expand Down Expand Up @@ -301,15 +299,13 @@ const crawlScope = (
const res = [];
const isSomeOrEvery =
foundRef.name.text === 'some' || foundRef.name.text === 'every';
console.log('[GRAPHQLSP]: ', foundRef.name.text);
const chainedResults = crawlChainedExpressions(
callExpression,
pathParts,
allFields,
source,
info
);
console.log('[GRAPHQLSP]: ', chainedResults.length);
if (chainedResults.length) {
res.push(...chainedResults);
}
Expand Down
11 changes: 5 additions & 6 deletions packages/graphqlsp/src/graphql/getSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,13 @@ async function saveTadaIntrospection(
});

let output = tadaOutputLocation;

if (await statFile(output, stat => stat.isDirectory())) {
output = path.join(output, 'introspection.d.ts');
} else if (
!(await statFile(path.dirname(output), stat => stat.isDirectory()))
) {
logger(`Output file is not inside a directory @ ${output}`);
return;
} else if (!(await statFile(output, p => !!p))) {
await fs.mkdir(path.dirname(output), { recursive: true });
if (await statFile(output, stat => stat.isDirectory())) {
output = path.join(output, 'introspection.d.ts');
}
}

try {
Expand Down