Skip to content

Commit 066615e

Browse files
author
Dane Pilcher
authored
feat: add __typename to selection set (#575)
BREAKING CHANGE: typename introspection with __typename meta field enabled by default
1 parent 1c34ac5 commit 066615e

File tree

8 files changed

+485
-24
lines changed

8 files changed

+485
-24
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const Ora = require('ora');
55
const loadConfig = require('../codegen-config');
66
const constants = require('../constants');
77
const { ensureIntrospectionSchema, getFrontEndHandler, getAppSyncAPIDetails } = require('../utils');
8-
const { generate } = require('@aws-amplify/graphql-docs-generator')
8+
const { generate } = require('@aws-amplify/graphql-docs-generator');
99

1010
async function generateStatements(context, forceDownloadSchema, maxDepth, withoutInit = false, decoupleFrontend = '') {
1111
try {
@@ -59,6 +59,9 @@ async function generateStatements(context, forceDownloadSchema, maxDepth, withou
5959
separateFiles: true,
6060
language,
6161
maxDepth: maxDepth || cfg.amplifyExtension.maxDepth,
62+
// default typenameIntrospection to true when not set
63+
typenameIntrospection:
64+
cfg.amplifyExtension.typenameIntrospection === undefined ? true : !!cfg.amplifyExtension.typenameIntrospection,
6265
});
6366
opsGenSpinner.succeed(constants.INFO_MESSAGE_OPS_GEN_SUCCESS + path.relative(path.resolve('.'), opsGenDirectory));
6467
} finally {

packages/amplify-codegen/tests/commands/statements.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ describe('command - statements', () => {
7171
expect(generate).toHaveBeenCalledWith(path.join(MOCK_PROJECT_ROOT, MOCK_SCHEMA), path.join(MOCK_PROJECT_ROOT, MOCK_STATEMENTS_PATH), {
7272
separateFiles: true,
7373
language: MOCK_TARGET_LANGUAGE,
74+
typenameIntrospection: true,
7475
});
7576
});
7677

@@ -81,6 +82,7 @@ describe('command - statements', () => {
8182
expect(generate).toHaveBeenCalledWith(path.join(MOCK_PROJECT_ROOT, MOCK_SCHEMA), path.join(MOCK_PROJECT_ROOT, MOCK_STATEMENTS_PATH), {
8283
separateFiles: true,
8384
language: 'graphql',
85+
typenameIntrospection: true,
8486
});
8587
});
8688

@@ -92,7 +94,7 @@ describe('command - statements', () => {
9294
path.join(MOCK_PROJECT_ROOT, MOCK_SCHEMA),
9395
MOCK_APIS[0],
9496
MOCK_REGION,
95-
forceDownload
97+
forceDownload,
9698
);
9799
});
98100

@@ -105,7 +107,7 @@ describe('command - statements', () => {
105107
path.join(MOCK_PROJECT_ROOT, MOCK_SCHEMA),
106108
MOCK_APIS[0],
107109
MOCK_REGION,
108-
forceDownload
110+
forceDownload,
109111
);
110112
});
111113

0 commit comments

Comments
 (0)