amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Add custom port support for GraphQL mock

Open tkasuz opened this issue 3 years ago • 1 comments
trafficstars

Description of changes

  • Import custom port named graphqlPort from amplify/mock.json, and add capability to run GraphQL mock on the given port.

mock.json

  • port for DynamoDB Local
  • graphqlPort for AppSync Simulator
{
  "port": 8000
  "graphqlPort": 8001
}

Issue #, if available

https://github.com/aws-amplify/amplify-category-api/issues/384

Description of how you validated changes

  • add graphqlPort into amplify/mock.json like below
{
  "graphqlPort": 8001
}
  • graphql mock server successfully ran on the given port
  • also checked mock server running on port 20002 without mock.json

Checklist

  • [x] PR description included
  • [x] yarn test passes
  • [x] Tests are changed or added
  • [ ] Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

tkasuz avatar Sep 07 '22 11:09 tkasuz

Codecov Report

Merging #10978 (4a8305d) into dev (fb2ba7b) will increase coverage by 0.41%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev   #10978      +/-   ##
==========================================
+ Coverage   47.81%   48.22%   +0.41%     
==========================================
  Files         669      669              
  Lines       32671    32673       +2     
  Branches     6600     6600              
==========================================
+ Hits        15621    15757     +136     
+ Misses      15420    15288     -132     
+ Partials     1630     1628       -2     
Impacted Files Coverage Δ
packages/amplify-util-mock/src/api/index.ts 81.81% <100.00%> (+81.81%) :arrow_up:
...es/amplify-util-mock/src/api/resolver-overrides.ts 2.91% <0.00%> (+2.91%) :arrow_up:
...-mock/src/CFNParser/resource-processors/appsync.ts 8.51% <0.00%> (+8.51%) :arrow_up:
...ges/amplify-util-mock/src/CFNParser/stack/index.ts 11.03% <0.00%> (+11.03%) :arrow_up:
...l-mock/src/CFNParser/appsync-resource-processor.ts 11.11% <0.00%> (+11.11%) :arrow_up:
...ges/amplify-util-mock/src/utils/dynamo-db/index.ts 11.53% <0.00%> (+11.53%) :arrow_up:
...ges/amplify-util-mock/src/utils/dynamo-db/utils.ts 11.90% <0.00%> (+11.90%) :arrow_up:
...s/amplify-util-mock/src/utils/dynamo-db/helpers.ts 12.50% <0.00%> (+12.50%) :arrow_up:
...li/src/domain/amplify-usageData/getUsageDataUrl.ts 100.00% <0.00%> (+12.50%) :arrow_up:
packages/amplify-util-mock/src/api/api.ts 12.72% <0.00%> (+12.72%) :arrow_up:
... and 12 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Sep 07 '22 11:09 codecov-commenter

Hey @kopkunka55, would you be interested in continuing to work on this PR? If so, please rebase this onto dev by running git rebase dev. We will help you with getting this PR to the finish line 🏁

aws-eddy avatar May 12 '23 20:05 aws-eddy

rebased

tkasuz avatar May 13 '23 11:05 tkasuz

Hi @kopkunka55 this change looks good to me but it needs a corresponding docs update. Would you be willing to put up a PR documenting this config value here: https://github.com/aws-amplify/docs/blob/f7e87744f26badf5488cbfee4162269582ddf634/src/pages/cli/usage/mock.mdx

edwardfoyle avatar May 23 '23 19:05 edwardfoyle