Skip to content

Commit

Permalink
chore(enum-array): plugin is sync (dotansimha#7917)
Browse files Browse the repository at this point in the history
* chore(enum-array): plugin can be sync

* Update index.ts

* Update index.ts

* add changeset
  • Loading branch information
dimaMachina authored Jun 6, 2022
1 parent 8eb5ad8 commit fe212a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-waves-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-codegen/typescript-enum-array': patch
---

chore: remove async from a plugin, as it's never was async
10 changes: 4 additions & 6 deletions packages/plugins/typescript/enum-array/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@ function buildImportStatement(enums: GraphQLEnumType[], importFrom: string): str
return [`import { ${names.join(', ')} } from "${importFrom}";`];
}

export const plugin: PluginFunction<EnumArrayPluginConfig> = async (
export const plugin: PluginFunction<EnumArrayPluginConfig> = (
schema: GraphQLSchema,
_documents: Types.DocumentFile[],
config: EnumArrayPluginConfig
): Promise<Types.PluginOutput> => {
const importFrom: EnumArrayPluginConfig['importFrom'] = config.importFrom;
): Types.PluginOutput => {
const enums = getEnumTypeMap(schema);
const content = enums.map(buildArrayDefinition).join('\n');

const result: Types.PluginOutput = { content };
if (importFrom) {
result['prepend'] = buildImportStatement(enums, importFrom);
if (config.importFrom) {
result['prepend'] = buildImportStatement(enums, config.importFrom);
}
return result;
};
Expand Down

0 comments on commit fe212a4

Please sign in to comment.