Skip to content

Instantly share code, notes, and snippets.

@darylenriquez
Created January 4, 2024 07:35
Show Gist options
  • Save darylenriquez/ae836fcebd140011541393b828e47f01 to your computer and use it in GitHub Desktop.
Save darylenriquez/ae836fcebd140011541393b828e47f01 to your computer and use it in GitHub Desktop.
moving graphql out of the monorepo
#################################################
# 1. clone the target repo into a new place
➜ experiments git clone git@github.com:aqua/my-frontend.git web-funnel-graphql-test
Cloning into 'web-funnel-graphql-test'...
remote: Enumerating objects: 43838, done.
remote: Counting objects: 100% (7457/7457), done.
remote: Compressing objects: 100% (1987/1987), done.
remote: Total 43838 (delta 5662), reused 6889 (delta 5269), pack-reused 36381
Receiving objects: 100% (43838/43838), 34.35 MiB | 3.33 MiB/s, done.
Resolving deltas: 100% (30657/30657), done.
➜ experiments cd web-funnel-graphql-test
➜ web-funnel-graphql-test git:(master) ll
total 1968
-rw-r--r-- 1 dary.lenriquez staff 12K Jan 4 13:33 Makefile
-rw-r--r-- 1 dary.lenriquez staff 11K Jan 4 13:33 README.md
drwxr-xr-x 9 dary.lenriquez staff 288B Jan 4 13:33 apps
-rw-r--r-- 1 dary.lenriquez staff 650B Jan 4 13:33 babel.config.js
drwxr-xr-x 5 dary.lenriquez staff 160B Jan 4 13:33 design-system
-rw-r--r-- 1 dary.lenriquez staff 243B Jan 4 13:33 docker-compose.yml
-rw-r--r-- 1 dary.lenriquez staff 4.0K Jan 4 13:33 env.template
-rw-r--r-- 1 dary.lenriquez staff 204B Jan 4 13:33 netlify.toml
-rw-r--r-- 1 dary.lenriquez staff 3.3K Jan 4 13:33 package.json
drwxr-xr-x 4 dary.lenriquez staff 128B Jan 4 13:33 packages
-rw-r--r-- 1 dary.lenriquez staff 9.3K Jan 4 13:33 pipeline.app.authorization-options.gocd.yml
-rw-r--r-- 1 dary.lenriquez staff 7.8K Jan 4 13:33 pipeline.app.authorization.gocd.yml
-rw-r--r-- 1 dary.lenriquez staff 7.2K Jan 4 13:33 pipeline.app.friend-referral.gocd.yml
-rw-r--r-- 1 dary.lenriquez staff 8.4K Jan 4 13:33 pipeline.app.payment-method-callback.gocd.yml
-rw-r--r-- 1 dary.lenriquez staff 13K Jan 4 13:33 pipeline.app.product-selector.gocd.yml
-rw-r--r-- 1 dary.lenriquez staff 9.5K Jan 4 13:33 pipeline.app.stripe-payment.gocd.yml
-rw-r--r-- 1 dary.lenriquez staff 30K Jan 4 13:33 pipeline.gocd.yml
drwxr-xr-x 3 dary.lenriquez staff 96B Jan 4 13:33 services
-rw-r--r-- 1 dary.lenriquez staff 1.2K Jan 4 13:33 tsconfig.json
-rw-r--r-- 1 dary.lenriquez staff 836K Jan 4 13:33 yarn.lock
➜ web-funnel-graphql-test git:(master) git log
#################################################
# 2. use git filter-repo to remove the unwanted folders
# use --path to specify the folder we wanted to remove
# use --invert-paths to tell the command the paths specified are the paths to be removed
➜ web-funnel-graphql-test git:(master) git filter-repo --invert-paths --path apps --path design-system --path packages
Parsed 4655 commits
New history written in 0.50 seconds; now repacking/cleaning...
Repacking your repo and cleaning out old unneeded objects
HEAD is now at ee40785f Merge pull request #1948 from aqua/feature/AC-2207
Enumerating objects: 13147, done.
Counting objects: 100% (13147/13147), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4037/4037), done.
Writing objects: 100% (13147/13147), done.
Total 13147 (delta 8728), reused 13100 (delta 8688), pack-reused 0
Completely finished after 1.44 seconds.
➜ web-funnel-graphql-test git:(master) git status
On branch master
nothing to commit, working tree clean
➜ web-funnel-graphql-test git:(master) ll
total 1968
-rw-r--r-- 1 dary.lenriquez staff 12K Jan 4 13:33 Makefile
-rw-r--r-- 1 dary.lenriquez staff 11K Jan 4 13:33 README.md
-rw-r--r-- 1 dary.lenriquez staff 650B Jan 4 13:33 babel.config.js
-rw-r--r-- 1 dary.lenriquez staff 243B Jan 4 13:33 docker-compose.yml
-rw-r--r-- 1 dary.lenriquez staff 4.0K Jan 4 13:33 env.template
-rw-r--r-- 1 dary.lenriquez staff 204B Jan 4 13:33 netlify.toml
-rw-r--r-- 1 dary.lenriquez staff 3.3K Jan 4 13:33 package.json
-rw-r--r-- 1 dary.lenriquez staff 9.3K Jan 4 13:33 pipeline.app.authorization-options.gocd.yml
-rw-r--r-- 1 dary.lenriquez staff 7.8K Jan 4 13:33 pipeline.app.authorization.gocd.yml
-rw-r--r-- 1 dary.lenriquez staff 7.2K Jan 4 13:33 pipeline.app.friend-referral.gocd.yml
-rw-r--r-- 1 dary.lenriquez staff 8.4K Jan 4 13:33 pipeline.app.payment-method-callback.gocd.yml
-rw-r--r-- 1 dary.lenriquez staff 13K Jan 4 13:33 pipeline.app.product-selector.gocd.yml
-rw-r--r-- 1 dary.lenriquez staff 9.5K Jan 4 13:33 pipeline.app.stripe-payment.gocd.yml
-rw-r--r-- 1 dary.lenriquez staff 30K Jan 4 13:33 pipeline.gocd.yml
drwxr-xr-x 3 dary.lenriquez staff 96B Jan 4 13:33 services
-rw-r--r-- 1 dary.lenriquez staff 1.2K Jan 4 13:33 tsconfig.json
-rw-r--r-- 1 dary.lenriquez staff 836K Jan 4 13:33 yarn.lock
➜ web-funnel-graphql-test git:(master) git log
#################################################
# 3. Test that the application works locally
# add the necessary env files and use make deps to install dependencies
# start the application and test that it works
➜ web-funnel-graphql-test git:(master) make deps
docker-compose run --rm serverless make _deps
echo "//registry.npmjs.org/:_authToken=7fc9af1b-af50-4d15-aa53-624d899b9a7e" >> .npmrc
yarn config set registry http://registry.npmjs.org
yarn config v1.22.17
success Set "registry" to "http://registry.npmjs.org".
Done in 0.18s.
yarn
yarn install v1.22.17
[1/4] Resolving packages...
warning Resolution field "crc32-stream@4.0.2" is incompatible with requested version "crc32-stream@^3.0.1"
warning Resolution field "crc32-stream@4.0.2" is incompatible with requested version "crc32-stream@^3.0.1"
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > eslint-config-react-app@5.2.0" has incorrect peer dependency "@typescript-eslint/eslint-plugin@2.x".
warning " > eslint-config-react-app@5.2.0" has incorrect peer dependency "@typescript-eslint/parser@2.x".
warning " > eslint-config-react-app@5.2.0" has incorrect peer dependency "eslint-plugin-flowtype@3.x".
warning " > eslint-config-react-app@5.2.0" has incorrect peer dependency "eslint-plugin-react-hooks@1.x".
warning "workspace-aggregator-07dbac1d-51c2-417b-ad7a-f0670c4fd588 > service-graphql > eslint-plugin-unicorn@22.0.0" has incorrect peer dependency "eslint@>=7.8.0".
warning "workspace-aggregator-07dbac1d-51c2-417b-ad7a-f0670c4fd588 > service-graphql > eslint-plugin-unicorn > eslint-template-visitor@2.2.1" has incorrect peer dependency "eslint@>=7.0.0".
warning "workspace-aggregator-07dbac1d-51c2-417b-ad7a-f0670c4fd588 > service-graphql > serverless > @serverless/components > inquirer-autocomplete-prompt@1.4.0" has unmet peer dependency "inquirer@^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
$ manypkg check && preconstruct dev
☔️ success workspaces valid!
🎁 info project is valid!
🎁 success created links!
Done in 215.81s.
➜ web-funnel-graphql-test git:(master) ✗ cd services/graphql
➜ graphql git:(master) ✗ make startGraphQL
docker-compose down --remove-orphans
[+] Running 2/1
✔ Container graphql-localstack-1 Removed 10.3s
✔ Network graphql_default Removed 0.0s
docker-compose up -d localstack
[+] Running 3/3
✔ Network graphql_default Created 0.0s
✔ Container graphql-localstack-1 Start... 0.2s
! localstack The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s
docker-compose run --rm dockerize -wait tcp://localstack:4566 -timeout 60s
2024/01/04 06:33:51 Waiting for: tcp://localstack:4566
...
Serverless: Bundling with Webpack...
Time: 16903ms
Built at: 01/04/2024 6:34:49 AM
Asset Size Chunks Chunk Names
src/handler.js 1.8 MiB src/handler [emitted] [big] src/handler
src/handler.js.map 1.15 MiB src/handler [emitted] [dev] src/handler
Entrypoint src/handler [big] = src/handler.js src/handler.js.map
[./src/action-tracker/index.ts] 962 bytes {src/handler} [built]
[./src/apollo-server.ts] 3.21 KiB {src/handler} [built]
[./src/data-sources/account-details.ts] 1.23 KiB {src/handler} [built]
[./src/data-sources/address.ts] 1.76 KiB {src/handler} [built]
[./src/data-sources/feature-toggle.ts] 1.76 KiB {src/handler} [built]
[./src/data-sources/idp.ts] 3.36 KiB {src/handler} [built]
[./src/data-sources/mfa.ts] 650 bytes {src/handler} [built]
[./src/data-sources/nbn-services.ts] 640 bytes {src/handler} [built]
[./src/data-sources/orders.ts] 2.15 KiB {src/handler} [built]
[./src/data-sources/payments.ts] 17.1 KiB {src/handler} [built]
[./src/data-sources/phone-numbers.ts] 1.45 KiB {src/handler} [built]
[./src/data-sources/porting.ts] 1.06 KiB {src/handler} [built]
[./src/data-sources/product-catalog.ts] 11.6 KiB {src/handler} [built]
[./src/handler.ts] 432 bytes {src/handler} [built]
[newrelic] external "newrelic" 42 bytes {src/handler} [built]
+ 741 hidden modules
Serverless: Watching for changes...
Serverless: Skipping start: DynamoDB Local is not available for stage: Dev
offline: Starting Offline: Dev ap-southeast-2.
offline: Offline [http for lambda] listening on http://0.0.0.0:3002
offline: Function names exposed for local invocation by aws-sdk:
* graphql: MV-NonProd-Acquisition-GraphQL-Dev-graphql
┌─────────────────────────────────────────────────────────────────────────┐
│ │
│ ANY | http://0.0.0.0:3000/graphql/graphql │
│ POST | http://0.0.0.0:3000/2015-03-31/functions/graphql/invocations │
│ │
└─────────────────────────────────────────────────────────────────────────┘
offline: [HTTP] server ready: http://0.0.0.0:3000 🚀
offline:
offline: Enter "rp" to replay the last request
#################################################
# 4. Push to the new repo
# Point the origin to the new repo
# change master to main branch
# push all the changes (tags, commits) to the new repo
➜ web-funnel-graphql-test git:(master) ✗ git remote rm origin
➜ web-funnel-graphql-test git:(master) ✗ git remote add origin git@github.com:aqua/web-funnel-graphql-test.git
➜ web-funnel-graphql-test git:(master) ✗ git branch -m master main
➜ web-funnel-graphql-test git:(main) ✗ git fetch -p origin
remote: Enumerating objects: 5470, done.
remote: Counting objects: 100% (5470/5470), done.
remote: Compressing objects: 100% (1457/1457), done.
remote: Total 5470 (delta 3891), reused 5465 (delta 3887), pack-reused 0
Receiving objects: 100% (5470/5470), 1.13 MiB | 1.19 MiB/s, done.
Resolving deltas: 100% (3891/3891), done.
From github.com:aqua/web-funnel-graphql-test
* [new branch] dependabot/npm_and_yarn/axios-1.6.0 -> origin/dependabot/npm_and_yarn/axios-1.6.0
* [new branch] main -> origin/main
➜ web-funnel-graphql-test git:(main) ✗ git branch -u origin/main main
branch 'main' set up to track 'origin/main'.
➜ web-funnel-graphql-test git:(main) ✗ git remote set-head origin -a
origin/HEAD set to main
➜ web-funnel-graphql-test git:(main) ✗ git push origin :master --force
remote:
remote: GitHub found 5 vulnerabilities on aqua/web-funnel-graphql-test's default branch (3 high, 2 moderate). To find out more, visit:
remote: https://github.com/aqua/web-funnel-graphql-test/security/dependabot
remote:
To github.com:aqua/web-funnel-graphql-test.git
- [deleted] master
➜ web-funnel-graphql-test git:(master) ✗ git push origin --all --force
Enumerating objects: 13146, done.
Counting objects: 100% (13146/13146), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3996/3996), done.
Writing objects: 100% (13146/13146), 5.84 MiB | 1.18 MiB/s, done.
Total 13146 (delta 8728), reused 13146 (delta 8728), pack-reused 0
remote: Resolving deltas: 100% (8728/8728), done.
remote:
remote: GitHub found 5 vulnerabilities on aqua/web-funnel-graphql-test's default branch (3 high, 2 moderate). To find out more, visit:
remote: https://github.com/aqua/web-funnel-graphql-test/security/dependabot
remote:
To github.com:aqua/web-funnel-graphql-test.git
➜ web-funnel-graphql-test git:(master) ✗ git push --tags
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 177 bytes | 177.00 KiB/s, done.
Total 1 (delta 0), reused 1 (delta 0), pack-reused 0
To github.com:aqua/web-funnel-graphql-test.git
* [new tag] v.0.0.1 -> v.0.0.1
#################################################
# 5. Deploy to pipeline and test
# Pipeline should be green and resources deployed correctly
# Application works as expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment