-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[Demo] Migrate from fetch-mock
to msw
#10844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
const data = generateData(); | ||
const restServer = JsonGraphqlServer({ data }); | ||
const handler = restServer.getHandler(); | ||
const handlerWithLogs = (url: string, opts: any) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to keep it. If we don't pass quiet: true
to worker.start
, it will automatically displays us the right logs 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work, except you probably didn't test the graphql demo which is broken
examples/simple/package.json
Outdated
}, | ||
"msw": { | ||
"workerDirectory": [ | ||
"assets", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why assets
? mockServiceWorker.js
is in public
directory, not assets
.
needs rebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The e-commerce demo doesn't work (either with REST or GraphQL). I get this error in the SAP when running make run-demo
:
error loading dynamically imported module: http://localhost:8000/src/dashboard/OrderChart.tsx
}); | ||
export const worker = setupWorker(http.all(/http:\/\/localhost:4000/, handler)); | ||
|
||
export default () => worker; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this export? I don't see it imported anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's imported from the projet root index: https://github.com/marmelab/react-admin/pull/10844/files#diff-90bd1ee22f91d95ef929650cdc5d138faa08887243bdbc5167f2671ed876196dR5
@@ -7361,6 +7496,13 @@ __metadata: | |||
languageName: node | |||
linkType: hard | |||
|
|||
"cli-width@npm:^4.1.0": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is duplicated (albeit in a different major version). Can we avoid it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't deduplicate different major versions
@@ -7734,6 +7876,13 @@ __metadata: | |||
languageName: node | |||
linkType: hard | |||
|
|||
"cookie@npm:^0.7.2": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also duplicated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with an additional note: before 1.0.0
, all versions can have breaking changes
yarn.lock
Outdated
@@ -9862,6 +10003,15 @@ __metadata: | |||
languageName: node | |||
linkType: hard | |||
|
|||
"fakerest@npm:4.1.3, fakerest@npm:^4.1.3": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also duplicated
yarn.lock
Outdated
version: 4.3.2 | ||
resolution: "linkifyjs@npm:4.3.2" | ||
checksum: 1a85e6b368304a4417567fe5e38651681e3e82465590836942d1b4f3c834cc35532898eb1e2479f6337d9144b297d418eb708b6be8ed0b3dc3954a3588e07971 | ||
version: 4.1.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert this one, linkify < 4.3.2 has a security vulnerability
yarn.lock
Outdated
@@ -18802,6 +18992,18 @@ __metadata: | |||
languageName: node | |||
linkType: hard | |||
|
|||
"tough-cookie@npm:^4.1.4": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate package
examples/simple/package.json
Outdated
@@ -14,6 +14,7 @@ | |||
"@mui/material": "^5.16.12", | |||
"@tanstack/react-query": "^5.83.0", | |||
"@tanstack/react-query-devtools": "^5.83.0", | |||
"fakerest": "^4.1.3", | |||
"jsonexport": "^3.2.0", | |||
"lodash": "~4.17.5", | |||
"ra-data-fakerest": "^5.10.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no longer needed. Also, missing ra-data-simple-rest.
I can't reproduce this. Can you try resetting your |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error was caused by Firefox being Firefox. Rebooting it fixed it.
Problem
fetch-mock
brings us back some vulnerabilities.Solution
Change it for MSW
To Do
Additional Checks
master
for a bugfix or a documentation fix, ornext
for a feature