Skip to content

Commit

Permalink
Merge pull request #571 from aws-amplify/main
Browse files Browse the repository at this point in the history
Release Amplify Codegen 3.4.2
  • Loading branch information
AaronZyLee authored Apr 12, 2023
2 parents 234698c + 63183c5 commit 75219ac
Show file tree
Hide file tree
Showing 8 changed files with 1,074 additions and 1,042 deletions.
46 changes: 40 additions & 6 deletions .circleci/config.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ machine:
executors:
w: &windows-e2e-executor
machine:
image: 'windows-server-2019-vs2019:stable'
image: 'windows-server-2022-gui:current'
resource_class: 'windows.medium'
shell: bash.exe
working_directory: ~/repo
Expand All @@ -19,7 +19,7 @@ executors:

l: &linux-e2e-executor
docker:
- image: public.ecr.aws/j4f5f3h7/amplify-cli-e2e-base-image-repo-public:latest
- image: public.ecr.aws/j4f5f3h7/amplify-cli-e2e-base-image-repo-public:node18
working_directory: ~/repo
resource_class: large
environment:
Expand All @@ -38,7 +38,7 @@ executors:

a: &android-e2e-executor
docker:
- image: cimg/android:2022.09
- image: cimg/android:2023.03
working_directory: ~/repo
resource_class: large
environment:
Expand Down Expand Up @@ -78,6 +78,25 @@ jobs:
executor: << parameters.os >>
steps:
- checkout
- when:
condition:
equal: [*windows-e2e-executor, << parameters.os >>]
steps:
- run:
name: Install Node 18
command: |
nvm version
nvm install 18.15.0
nvm use 18.15.0
nvm ls
- run:
name: Install Yarn
command: |
npm install -g yarn
yarn --version
- run:
name: Check node version
command: node -v
- run: yarn config set workspaces-experimental true
- run: yarn cache clean --force
- run: yarn run production-build
Expand All @@ -103,8 +122,21 @@ jobs:
- equal: [*windows-e2e-executor, << parameters.os >>]
steps:
- checkout
- run: nvm install 12.22.7
- run: nvm alias default 12.22.7
- run:
name: Install Node 18
command: |
nvm version
nvm install 18.15.0
nvm use 18.15.0
nvm ls
- run:
name: Install Yarn
command: |
npm install -g yarn
yarn --version
- run:
name: Check node version
command: node -v
- run: yarn config set workspaces-experimental true
- run: yarn cache clean --force
- run: yarn run production-build
Expand Down Expand Up @@ -234,7 +266,9 @@ jobs:
key: amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }}
- node/install:
install-yarn: true
node-version: '16.13'
node-version: '18.15'
- run: yarn config set workspaces-experimental true
- run: yarn cache clean --force
- run: yarn run production-build
- run: *install_cli
- run:
Expand Down
48 changes: 42 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ machine:
executors:
w: &ref_1
machine:
image: windows-server-2019-vs2019:stable
image: windows-server-2022-gui:current
resource_class: windows.medium
shell: bash.exe
working_directory: ~/repo
Expand All @@ -19,7 +19,7 @@ executors:
AMPLIFY_PATH: C:/home/circleci/repo/out/amplify.exe
l: &ref_2
docker:
- image: public.ecr.aws/j4f5f3h7/amplify-cli-e2e-base-image-repo-public:latest
- image: public.ecr.aws/j4f5f3h7/amplify-cli-e2e-base-image-repo-public:node18
working_directory: ~/repo
resource_class: large
environment:
Expand All @@ -36,7 +36,7 @@ executors:
AMPLIFY_PATH: /home/circleci/repo/out/amplify-pkg-linux-x64
a:
docker:
- image: cimg/android:2022.09
- image: cimg/android:2023.03
working_directory: ~/repo
resource_class: large
environment:
Expand Down Expand Up @@ -73,6 +73,27 @@ jobs:
executor: << parameters.os >>
steps:
- checkout
- when:
condition:
equal:
- *ref_1
- << parameters.os >>
steps:
- run:
name: Install Node 18
command: |
nvm version
nvm install 18.15.0
nvm use 18.15.0
nvm ls
- run:
name: Install Yarn
command: |
npm install -g yarn
yarn --version
- run:
name: Check node version
command: node -v
- run: yarn config set workspaces-experimental true
- run: yarn cache clean --force
- run: yarn run production-build
Expand Down Expand Up @@ -100,8 +121,21 @@ jobs:
- << parameters.os >>
steps:
- checkout
- run: nvm install 12.22.7
- run: nvm alias default 12.22.7
- run:
name: Install Node 18
command: |
nvm version
nvm install 18.15.0
nvm use 18.15.0
nvm ls
- run:
name: Install Yarn
command: |
npm install -g yarn
yarn --version
- run:
name: Check node version
command: node -v
- run: yarn config set workspaces-experimental true
- run: yarn cache clean --force
- run: yarn run production-build
Expand Down Expand Up @@ -235,7 +269,9 @@ jobs:
key: amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }}
- node/install:
install-yarn: true
node-version: '16.13'
node-version: '18.15'
- run: yarn config set workspaces-experimental true
- run: yarn cache clean --force
- run: yarn run production-build
- run: *ref_3
- run:
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-codegen-e2e-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"fs-extra": "^8.1.0",
"jest-environment-node": "^26.6.2",
"lodash": "^4.17.19",
"node-pty-prebuilt-multiarch": "^0.9.0",
"node-pty": "beta",
"retimer": "2.0.0",
"rimraf": "^3.0.0",
"strip-ansi": "^6.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as pty from 'node-pty-prebuilt-multiarch';
import * as pty from 'node-pty';
import chalk from 'chalk';

export type RecordingHeader = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2173,3 +2173,150 @@ exports[`Primary Key Info tests should generate correct primary key info for mod
\\"nonModels\\": {}
}"
`;

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`] = `
"{
\\"version\\": 1,
\\"models\\": {
\\"Post\\": {
\\"name\\": \\"Post\\",
\\"fields\\": {
\\"postId\\": {
\\"name\\": \\"postId\\",
\\"isArray\\": false,
\\"type\\": \\"ID\\",
\\"isRequired\\": true,
\\"attributes\\": []
},
\\"node\\": {
\\"name\\": \\"node\\",
\\"isArray\\": false,
\\"type\\": {
\\"model\\": \\"PostNode\\"
},
\\"isRequired\\": true,
\\"attributes\\": [],
\\"association\\": {
\\"connectionType\\": \\"BELONGS_TO\\",
\\"targetNames\\": [
\\"postId\\"
]
}
},
\\"title\\": {
\\"name\\": \\"title\\",
\\"isArray\\": false,
\\"type\\": \\"String\\",
\\"isRequired\\": true,
\\"attributes\\": []
},
\\"createdAt\\": {
\\"name\\": \\"createdAt\\",
\\"isArray\\": false,
\\"type\\": \\"AWSDateTime\\",
\\"isRequired\\": false,
\\"attributes\\": [],
\\"isReadOnly\\": true
},
\\"updatedAt\\": {
\\"name\\": \\"updatedAt\\",
\\"isArray\\": false,
\\"type\\": \\"AWSDateTime\\",
\\"isRequired\\": false,
\\"attributes\\": [],
\\"isReadOnly\\": true
}
},
\\"syncable\\": true,
\\"pluralName\\": \\"Posts\\",
\\"attributes\\": [
{
\\"type\\": \\"model\\",
\\"properties\\": {}
},
{
\\"type\\": \\"key\\",
\\"properties\\": {
\\"fields\\": [
\\"postId\\"
]
}
}
],
\\"primaryKeyInfo\\": {
\\"isCustomPrimaryKey\\": true,
\\"primaryKeyFieldName\\": \\"postId\\",
\\"sortKeyFieldNames\\": []
}
},
\\"PostNode\\": {
\\"name\\": \\"PostNode\\",
\\"fields\\": {
\\"id\\": {
\\"name\\": \\"id\\",
\\"isArray\\": false,
\\"type\\": \\"ID\\",
\\"isRequired\\": true,
\\"attributes\\": []
},
\\"post\\": {
\\"name\\": \\"post\\",
\\"isArray\\": false,
\\"type\\": {
\\"model\\": \\"Post\\"
},
\\"isRequired\\": true,
\\"attributes\\": [],
\\"association\\": {
\\"connectionType\\": \\"HAS_ONE\\",
\\"associatedWith\\": [
\\"node\\"
],
\\"targetNames\\": [
\\"postNodePostId\\"
]
}
},
\\"createdAt\\": {
\\"name\\": \\"createdAt\\",
\\"isArray\\": false,
\\"type\\": \\"AWSDateTime\\",
\\"isRequired\\": false,
\\"attributes\\": [],
\\"isReadOnly\\": true
},
\\"updatedAt\\": {
\\"name\\": \\"updatedAt\\",
\\"isArray\\": false,
\\"type\\": \\"AWSDateTime\\",
\\"isRequired\\": false,
\\"attributes\\": [],
\\"isReadOnly\\": true
},
\\"postNodePostId\\": {
\\"name\\": \\"postNodePostId\\",
\\"isArray\\": false,
\\"type\\": \\"ID\\",
\\"isRequired\\": true,
\\"attributes\\": []
}
},
\\"syncable\\": true,
\\"pluralName\\": \\"PostNodes\\",
\\"attributes\\": [
{
\\"type\\": \\"model\\",
\\"properties\\": {}
}
],
\\"primaryKeyInfo\\": {
\\"isCustomPrimaryKey\\": false,
\\"primaryKeyFieldName\\": \\"id\\",
\\"sortKeyFieldNames\\": []
}
}
},
\\"enums\\": {},
\\"nonModels\\": {}
}"
`;
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { buildSchema, GraphQLSchema, parse, visit } from 'graphql';
import { METADATA_SCALAR_MAP } from '../../scalars';
import { directives, scalars } from '../../scalars/supported-directives';
import {
CodeGenConnectionType,
CodeGenFieldConnectionBelongsTo,
CodeGenFieldConnectionHasMany,
CodeGenFieldConnectionHasOne,
} from '../../utils/process-connections';
import { AppSyncModelIntrospectionVisitor } from '../../visitors/appsync-model-introspection-visitor';
import { CodeGenEnum, CodeGenField, CodeGenModel } from '../../visitors/appsync-visitor';

const defaultModelIntropectionVisitorSettings = {
isTimestampFieldsAdded: true,
Expand Down Expand Up @@ -217,4 +210,22 @@ describe('Primary Key Info tests', () => {
const visitor: AppSyncModelIntrospectionVisitor = getVisitor(schema);
expect(visitor.generate()).toMatchSnapshot();
});
});

describe('Primary key info within a belongsTo model tests', () => {
const schema = /* GraphQL */ `
type Post @model {
postId: ID! @primaryKey
node: PostNode! @belongsTo(fields: ["postId"])
title: String!
}
type PostNode @model {
id: ID!
post: Post! @hasOne
}
`;
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', () => {
const visitor: AppSyncModelIntrospectionVisitor = getVisitor(schema, { respectPrimaryKeyAttributesOnConnectionField: false });
expect(visitor.generate()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,9 @@ export class AppSyncModelVisitor<
connectionInfo &&
connectionInfo.kind !== CodeGenConnectionType.HAS_MANY &&
connectionInfo.kind !== CodeGenConnectionType.HAS_ONE &&
connectionInfo.targetName !== 'id'
connectionInfo.targetName !== 'id' &&
!(this.config.target === 'introspection' &&
this.getFieldName(getModelPrimaryKeyComponentFields(model)[0]) === connectionInfo.targetName)
) {
// Need to remove the field that is targetName
removeFieldFromModel(model, connectionInfo.targetName);
Expand Down
Loading

0 comments on commit 75219ac

Please sign in to comment.