Skip to content

Commit 75219ac

Browse files
authored
Merge pull request #571 from aws-amplify/main
Release Amplify Codegen 3.4.2
2 parents 234698c + 63183c5 commit 75219ac

File tree

8 files changed

+1074
-1042
lines changed

8 files changed

+1074
-1042
lines changed

.circleci/config.base.yml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ machine:
99
executors:
1010
w: &windows-e2e-executor
1111
machine:
12-
image: 'windows-server-2019-vs2019:stable'
12+
image: 'windows-server-2022-gui:current'
1313
resource_class: 'windows.medium'
1414
shell: bash.exe
1515
working_directory: ~/repo
@@ -19,7 +19,7 @@ executors:
1919

2020
l: &linux-e2e-executor
2121
docker:
22-
- image: public.ecr.aws/j4f5f3h7/amplify-cli-e2e-base-image-repo-public:latest
22+
- image: public.ecr.aws/j4f5f3h7/amplify-cli-e2e-base-image-repo-public:node18
2323
working_directory: ~/repo
2424
resource_class: large
2525
environment:
@@ -38,7 +38,7 @@ executors:
3838

3939
a: &android-e2e-executor
4040
docker:
41-
- image: cimg/android:2022.09
41+
- image: cimg/android:2023.03
4242
working_directory: ~/repo
4343
resource_class: large
4444
environment:
@@ -78,6 +78,25 @@ jobs:
7878
executor: << parameters.os >>
7979
steps:
8080
- checkout
81+
- when:
82+
condition:
83+
equal: [*windows-e2e-executor, << parameters.os >>]
84+
steps:
85+
- run:
86+
name: Install Node 18
87+
command: |
88+
nvm version
89+
nvm install 18.15.0
90+
nvm use 18.15.0
91+
nvm ls
92+
- run:
93+
name: Install Yarn
94+
command: |
95+
npm install -g yarn
96+
yarn --version
97+
- run:
98+
name: Check node version
99+
command: node -v
81100
- run: yarn config set workspaces-experimental true
82101
- run: yarn cache clean --force
83102
- run: yarn run production-build
@@ -103,8 +122,21 @@ jobs:
103122
- equal: [*windows-e2e-executor, << parameters.os >>]
104123
steps:
105124
- checkout
106-
- run: nvm install 12.22.7
107-
- run: nvm alias default 12.22.7
125+
- run:
126+
name: Install Node 18
127+
command: |
128+
nvm version
129+
nvm install 18.15.0
130+
nvm use 18.15.0
131+
nvm ls
132+
- run:
133+
name: Install Yarn
134+
command: |
135+
npm install -g yarn
136+
yarn --version
137+
- run:
138+
name: Check node version
139+
command: node -v
108140
- run: yarn config set workspaces-experimental true
109141
- run: yarn cache clean --force
110142
- run: yarn run production-build
@@ -234,7 +266,9 @@ jobs:
234266
key: amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }}
235267
- node/install:
236268
install-yarn: true
237-
node-version: '16.13'
269+
node-version: '18.15'
270+
- run: yarn config set workspaces-experimental true
271+
- run: yarn cache clean --force
238272
- run: yarn run production-build
239273
- run: *install_cli
240274
- run:

.circleci/config.yml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ machine:
1010
executors:
1111
w: &ref_1
1212
machine:
13-
image: windows-server-2019-vs2019:stable
13+
image: windows-server-2022-gui:current
1414
resource_class: windows.medium
1515
shell: bash.exe
1616
working_directory: ~/repo
@@ -19,7 +19,7 @@ executors:
1919
AMPLIFY_PATH: C:/home/circleci/repo/out/amplify.exe
2020
l: &ref_2
2121
docker:
22-
- image: public.ecr.aws/j4f5f3h7/amplify-cli-e2e-base-image-repo-public:latest
22+
- image: public.ecr.aws/j4f5f3h7/amplify-cli-e2e-base-image-repo-public:node18
2323
working_directory: ~/repo
2424
resource_class: large
2525
environment:
@@ -36,7 +36,7 @@ executors:
3636
AMPLIFY_PATH: /home/circleci/repo/out/amplify-pkg-linux-x64
3737
a:
3838
docker:
39-
- image: cimg/android:2022.09
39+
- image: cimg/android:2023.03
4040
working_directory: ~/repo
4141
resource_class: large
4242
environment:
@@ -73,6 +73,27 @@ jobs:
7373
executor: << parameters.os >>
7474
steps:
7575
- checkout
76+
- when:
77+
condition:
78+
equal:
79+
- *ref_1
80+
- << parameters.os >>
81+
steps:
82+
- run:
83+
name: Install Node 18
84+
command: |
85+
nvm version
86+
nvm install 18.15.0
87+
nvm use 18.15.0
88+
nvm ls
89+
- run:
90+
name: Install Yarn
91+
command: |
92+
npm install -g yarn
93+
yarn --version
94+
- run:
95+
name: Check node version
96+
command: node -v
7697
- run: yarn config set workspaces-experimental true
7798
- run: yarn cache clean --force
7899
- run: yarn run production-build
@@ -100,8 +121,21 @@ jobs:
100121
- << parameters.os >>
101122
steps:
102123
- checkout
103-
- run: nvm install 12.22.7
104-
- run: nvm alias default 12.22.7
124+
- run:
125+
name: Install Node 18
126+
command: |
127+
nvm version
128+
nvm install 18.15.0
129+
nvm use 18.15.0
130+
nvm ls
131+
- run:
132+
name: Install Yarn
133+
command: |
134+
npm install -g yarn
135+
yarn --version
136+
- run:
137+
name: Check node version
138+
command: node -v
105139
- run: yarn config set workspaces-experimental true
106140
- run: yarn cache clean --force
107141
- run: yarn run production-build
@@ -235,7 +269,9 @@ jobs:
235269
key: amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }}
236270
- node/install:
237271
install-yarn: true
238-
node-version: '16.13'
272+
node-version: '18.15'
273+
- run: yarn config set workspaces-experimental true
274+
- run: yarn cache clean --force
239275
- run: yarn run production-build
240276
- run: *ref_3
241277
- run:

packages/amplify-codegen-e2e-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"fs-extra": "^8.1.0",
2828
"jest-environment-node": "^26.6.2",
2929
"lodash": "^4.17.19",
30-
"node-pty-prebuilt-multiarch": "^0.9.0",
30+
"node-pty": "beta",
3131
"retimer": "2.0.0",
3232
"rimraf": "^3.0.0",
3333
"strip-ansi": "^6.0.0",

packages/amplify-codegen-e2e-core/src/asciinema-recorder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as pty from 'node-pty-prebuilt-multiarch';
1+
import * as pty from 'node-pty';
22
import chalk from 'chalk';
33

44
export type RecordingHeader = {

packages/appsync-modelgen-plugin/src/__tests__/visitors/__snapshots__/appsync-model-introspection-visitor.test.ts.snap

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,3 +2173,150 @@ exports[`Primary Key Info tests should generate correct primary key info for mod
21732173
\\"nonModels\\": {}
21742174
}"
21752175
`;
2176+
2177+
exports[`Primary key info within a belongsTo model tests should generate correct primary key info for model when the primary key field is part of belongsTo connection field and custom PK is disabled 1`] = `
2178+
"{
2179+
\\"version\\": 1,
2180+
\\"models\\": {
2181+
\\"Post\\": {
2182+
\\"name\\": \\"Post\\",
2183+
\\"fields\\": {
2184+
\\"postId\\": {
2185+
\\"name\\": \\"postId\\",
2186+
\\"isArray\\": false,
2187+
\\"type\\": \\"ID\\",
2188+
\\"isRequired\\": true,
2189+
\\"attributes\\": []
2190+
},
2191+
\\"node\\": {
2192+
\\"name\\": \\"node\\",
2193+
\\"isArray\\": false,
2194+
\\"type\\": {
2195+
\\"model\\": \\"PostNode\\"
2196+
},
2197+
\\"isRequired\\": true,
2198+
\\"attributes\\": [],
2199+
\\"association\\": {
2200+
\\"connectionType\\": \\"BELONGS_TO\\",
2201+
\\"targetNames\\": [
2202+
\\"postId\\"
2203+
]
2204+
}
2205+
},
2206+
\\"title\\": {
2207+
\\"name\\": \\"title\\",
2208+
\\"isArray\\": false,
2209+
\\"type\\": \\"String\\",
2210+
\\"isRequired\\": true,
2211+
\\"attributes\\": []
2212+
},
2213+
\\"createdAt\\": {
2214+
\\"name\\": \\"createdAt\\",
2215+
\\"isArray\\": false,
2216+
\\"type\\": \\"AWSDateTime\\",
2217+
\\"isRequired\\": false,
2218+
\\"attributes\\": [],
2219+
\\"isReadOnly\\": true
2220+
},
2221+
\\"updatedAt\\": {
2222+
\\"name\\": \\"updatedAt\\",
2223+
\\"isArray\\": false,
2224+
\\"type\\": \\"AWSDateTime\\",
2225+
\\"isRequired\\": false,
2226+
\\"attributes\\": [],
2227+
\\"isReadOnly\\": true
2228+
}
2229+
},
2230+
\\"syncable\\": true,
2231+
\\"pluralName\\": \\"Posts\\",
2232+
\\"attributes\\": [
2233+
{
2234+
\\"type\\": \\"model\\",
2235+
\\"properties\\": {}
2236+
},
2237+
{
2238+
\\"type\\": \\"key\\",
2239+
\\"properties\\": {
2240+
\\"fields\\": [
2241+
\\"postId\\"
2242+
]
2243+
}
2244+
}
2245+
],
2246+
\\"primaryKeyInfo\\": {
2247+
\\"isCustomPrimaryKey\\": true,
2248+
\\"primaryKeyFieldName\\": \\"postId\\",
2249+
\\"sortKeyFieldNames\\": []
2250+
}
2251+
},
2252+
\\"PostNode\\": {
2253+
\\"name\\": \\"PostNode\\",
2254+
\\"fields\\": {
2255+
\\"id\\": {
2256+
\\"name\\": \\"id\\",
2257+
\\"isArray\\": false,
2258+
\\"type\\": \\"ID\\",
2259+
\\"isRequired\\": true,
2260+
\\"attributes\\": []
2261+
},
2262+
\\"post\\": {
2263+
\\"name\\": \\"post\\",
2264+
\\"isArray\\": false,
2265+
\\"type\\": {
2266+
\\"model\\": \\"Post\\"
2267+
},
2268+
\\"isRequired\\": true,
2269+
\\"attributes\\": [],
2270+
\\"association\\": {
2271+
\\"connectionType\\": \\"HAS_ONE\\",
2272+
\\"associatedWith\\": [
2273+
\\"node\\"
2274+
],
2275+
\\"targetNames\\": [
2276+
\\"postNodePostId\\"
2277+
]
2278+
}
2279+
},
2280+
\\"createdAt\\": {
2281+
\\"name\\": \\"createdAt\\",
2282+
\\"isArray\\": false,
2283+
\\"type\\": \\"AWSDateTime\\",
2284+
\\"isRequired\\": false,
2285+
\\"attributes\\": [],
2286+
\\"isReadOnly\\": true
2287+
},
2288+
\\"updatedAt\\": {
2289+
\\"name\\": \\"updatedAt\\",
2290+
\\"isArray\\": false,
2291+
\\"type\\": \\"AWSDateTime\\",
2292+
\\"isRequired\\": false,
2293+
\\"attributes\\": [],
2294+
\\"isReadOnly\\": true
2295+
},
2296+
\\"postNodePostId\\": {
2297+
\\"name\\": \\"postNodePostId\\",
2298+
\\"isArray\\": false,
2299+
\\"type\\": \\"ID\\",
2300+
\\"isRequired\\": true,
2301+
\\"attributes\\": []
2302+
}
2303+
},
2304+
\\"syncable\\": true,
2305+
\\"pluralName\\": \\"PostNodes\\",
2306+
\\"attributes\\": [
2307+
{
2308+
\\"type\\": \\"model\\",
2309+
\\"properties\\": {}
2310+
}
2311+
],
2312+
\\"primaryKeyInfo\\": {
2313+
\\"isCustomPrimaryKey\\": false,
2314+
\\"primaryKeyFieldName\\": \\"id\\",
2315+
\\"sortKeyFieldNames\\": []
2316+
}
2317+
}
2318+
},
2319+
\\"enums\\": {},
2320+
\\"nonModels\\": {}
2321+
}"
2322+
`;

packages/appsync-modelgen-plugin/src/__tests__/visitors/appsync-model-introspection-visitor.test.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import { buildSchema, GraphQLSchema, parse, visit } from 'graphql';
22
import { METADATA_SCALAR_MAP } from '../../scalars';
33
import { directives, scalars } from '../../scalars/supported-directives';
4-
import {
5-
CodeGenConnectionType,
6-
CodeGenFieldConnectionBelongsTo,
7-
CodeGenFieldConnectionHasMany,
8-
CodeGenFieldConnectionHasOne,
9-
} from '../../utils/process-connections';
104
import { AppSyncModelIntrospectionVisitor } from '../../visitors/appsync-model-introspection-visitor';
11-
import { CodeGenEnum, CodeGenField, CodeGenModel } from '../../visitors/appsync-visitor';
125

136
const defaultModelIntropectionVisitorSettings = {
147
isTimestampFieldsAdded: true,
@@ -217,4 +210,22 @@ describe('Primary Key Info tests', () => {
217210
const visitor: AppSyncModelIntrospectionVisitor = getVisitor(schema);
218211
expect(visitor.generate()).toMatchSnapshot();
219212
});
213+
});
214+
215+
describe('Primary key info within a belongsTo model tests', () => {
216+
const schema = /* GraphQL */ `
217+
type Post @model {
218+
postId: ID! @primaryKey
219+
node: PostNode! @belongsTo(fields: ["postId"])
220+
title: String!
221+
}
222+
type PostNode @model {
223+
id: ID!
224+
post: Post! @hasOne
225+
}
226+
`;
227+
it('should generate correct primary key info for model when the primary key field is part of belongsTo connection field and custom PK is disabled', () => {
228+
const visitor: AppSyncModelIntrospectionVisitor = getVisitor(schema, { respectPrimaryKeyAttributesOnConnectionField: false });
229+
expect(visitor.generate()).toMatchSnapshot();
230+
});
220231
});

packages/appsync-modelgen-plugin/src/visitors/appsync-visitor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,9 @@ export class AppSyncModelVisitor<
10281028
connectionInfo &&
10291029
connectionInfo.kind !== CodeGenConnectionType.HAS_MANY &&
10301030
connectionInfo.kind !== CodeGenConnectionType.HAS_ONE &&
1031-
connectionInfo.targetName !== 'id'
1031+
connectionInfo.targetName !== 'id' &&
1032+
!(this.config.target === 'introspection' &&
1033+
this.getFieldName(getModelPrimaryKeyComponentFields(model)[0]) === connectionInfo.targetName)
10321034
) {
10331035
// Need to remove the field that is targetName
10341036
removeFieldFromModel(model, connectionInfo.targetName);

0 commit comments

Comments
 (0)