Skip to content

Commit aa0dbb3

Browse files
authored
fix(appsync-modelgen-plugin): skip query/mutation/sub types (#180)
1 parent 69cd61a commit aa0dbb3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/amplify-codegen/src/commands/models.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async function generateModels(context) {
9393

9494
generateEslintIgnore(context);
9595

96-
context.print.info(`Successfully generated models... Generated models can be found in ${outputPath}`);
96+
context.print.info(`Successfully generated models. Generated models can be found in ${outputPath}`);
9797
}
9898

9999
async function validateSchema(context) {

packages/appsync-modelgen-plugin/src/preset.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,11 @@ const generateDartPreset = (
220220
export const preset: Types.OutputPreset<AppSyncModelCodeGenPresetConfig> = {
221221
buildGeneratesSection: (options: Types.PresetFnArgs<AppSyncModelCodeGenPresetConfig>): Types.GenerateOptions[] => {
222222
const codeGenTarget = options.config.target;
223-
223+
const typesToSkip: string[] = ['Query', 'Mutation', 'Subscription'];
224224
const models: TypeDefinitionNode[] = options.schema.definitions.filter(
225-
t => t.kind === 'ObjectTypeDefinition' || (t.kind === 'EnumTypeDefinition' && !t.name.value.startsWith('__')),
225+
t =>
226+
(t.kind === 'ObjectTypeDefinition' && !typesToSkip.includes(t.name.value)) ||
227+
(t.kind === 'EnumTypeDefinition' && !t.name.value.startsWith('__')),
226228
) as any;
227229

228230
switch (codeGenTarget) {

0 commit comments

Comments
 (0)