Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.

Recursively create dir (#364)

Changed files
+10 -10
.changeset
packages
graphqlsp
+5
.changeset/rotten-pugs-begin.md
···
+
---
+
'@0no-co/graphqlsp': patch
+
---
+
+
Recursively create directories if the target does not exist
-4
packages/graphqlsp/src/fieldUsage.ts
···
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';
···
// - 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) ||
···
const res = [];
const isSomeOrEvery =
foundRef.name.text === 'some' || foundRef.name.text === 'every';
-
console.log('[GRAPHQLSP]: ', foundRef.name.text);
const chainedResults = crawlChainedExpressions(
callExpression,
pathParts,
···
source,
info
);
-
console.log('[GRAPHQLSP]: ', chainedResults.length);
if (chainedResults.length) {
res.push(...chainedResults);
}
+5 -6
packages/graphqlsp/src/graphql/getSchema.ts
···
});
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 {