-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate all query object types enum
- Loading branch information
Showing
6 changed files
with
36 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/commands/graphql-client/generator/render/renderQueryTypesEnum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { IntrospectionType } from 'graphql' | ||
import capitalizeFirstLetter from '../../utils/capitalizeFirstLetter' | ||
|
||
export default function (types: IntrospectionType[]) { | ||
|
||
if (!types.length) { | ||
return null | ||
} | ||
|
||
const renderedFields = types | ||
.filter(x => !x.name.startsWith('__')) | ||
.map(x => capitalizeFirstLetter(x.name)) | ||
.map(x => ` ${x} = '${x}',`) | ||
.join('\n') | ||
|
||
return ` | ||
export enum QueryObjectTypes { | ||
${renderedFields} | ||
} | ||
` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters