Skip to content

Commit

Permalink
Update template function to handle formatting
Browse files Browse the repository at this point in the history
Co-authored-by: Benjie <benjie@jemjie.com>
  • Loading branch information
Nols1000 and benjie authored Jan 3, 2025
1 parent 388d405 commit 366de1f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/utilities/getIntrospectionQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,18 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
return optionsWithDefault.inputValueDeprecation ? str : '';
}
const oneOf = optionsWithDefault.oneOf ? 'isOneOf' : '';
function ofType(level = 9): string {
function ofType(level: number, indent: string): string {
if (level <= 0) {
return '';
}
if (level > 100) {
throw new Error("Please set typeDepth to a reasonable value; the default is 9.");

Check failure on line 88 in src/utilities/getIntrospectionQuery.ts

View workflow job for this annotation

GitHub Actions / ci / Lint source files

Strings must use singlequote
}

Check warning on line 89 in src/utilities/getIntrospectionQuery.ts

View check run for this annotation

Codecov / codecov/patch

src/utilities/getIntrospectionQuery.ts#L88-L89

Added lines #L88 - L89 were not covered by tests
return `
ofType {
name
kind
${ofType(level - 1)}
}`;
${indent}ofType {
${indent} name
${indent} kind${ofType(level - 1, indent + " ")}

Check failure on line 93 in src/utilities/getIntrospectionQuery.ts

View workflow job for this annotation

GitHub Actions / ci / Lint source files

Strings must use singlequote
${indent}}`;
}

return `
Expand Down Expand Up @@ -160,8 +162,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
fragment TypeRef on __Type {
kind
name
${ofType(optionsWithDefault.typeDepth)}
name${ofType(optionsWithDefault.typeDepth ?? 9, " ")}

Check failure on line 165 in src/utilities/getIntrospectionQuery.ts

View workflow job for this annotation

GitHub Actions / ci / Lint source files

Strings must use singlequote
}
`;
}
Expand Down

0 comments on commit 366de1f

Please sign in to comment.