Comments (10)
I would have never thought of that
We didn't either -- until we found that issue and then it actually makes perfect sense.
Under the covers RedwoodJS replies on https://www.apollographql.com/docs/react/data/fragments/#usefragment and we think that needs to know the type to properly match up data with the fragment in the query.
from redwood.
Okay it's working!, closing this know. Great work the RedwoodJS team is amazing
from redwood.
Hi @irg1008 thanks to @arimendelow we think we figured it out. Ignore the updates I made to your reproduction repo as having the two cells with the two queries can confuse the issue. but try using:
// Define your own mock data here:
export const standard = (/* vars, { ctx, req } */) => ({
chatMessages: Array.from({ length: 20 }, (_, index) => ({
__typename: 'ChatMessage',
body: `Message${index + 1}`,
createdAt: '2021-07-01T00:00:00.000Z',
id: index + 1,
user: {
__typename: 'ChatUser',
displayName: `User ${(index % 5) + 1}`, // Cycle through 5 different users
id: (index % 5) + 1,
},
chatRoomId: '42',
})) satisfies ChatMessage[],
})
in ChatCell.mock.ts
.
Notice the __typename
in the data to note what the GraphQL types are. This appears to be needed so that Apollo can understand have to use the fragments and map the data coming back.
Some more info in: mswjs/msw#630
Can you see if that works for you?
We'll update the Fragment docs (or if you feel like making a docs PR, that'd be amazing) and then think about how this might be done more transparently. But it is good practice I guess to include the typenames since that in fact does come back in real-world cases from Yoga.
from redwood.
Oh my god I would have never thought of that, will try it tomorrow and let you know. And will happily make the PR to the fragment docs. Thanks!
from redwood.
Hi @irg1008 and thanks for writing up this issue — I’ll have to recreate it with. Small reproduction.
One question: for the log output of your mock is that from running a test or using storybook?
from redwood.
Sorry should have said. It's Storybook. If need me to create a small repo please say so
from redwood.
If need me to create a small repo please say so
If you could, that would be really helpful for me to reproduce and know we are seeing the same thing.
Thanks!
from redwood.
Okay there you go: https://github.com/irg1008/issue-redwood-fragments-storybook.git
- Install (yarn install, etc)
yarn rw dev
yarn rw storybook
- Open storybook > Components > Chat: See that IS WORKING
- Go to
ChatCell.tsx
- Uncomment and comment to swap to using fragment
- Open storybook > Components > Chat: NOT WORKING
from redwood.
Hi @irg1008 I forked and made PR on your demo repo here: irg1008/issue-redwood-fragments-storybook#1
The cells themselves appear to mock ok, but when the cell is then used in a component (or maybe even a page) and that story then doesn't appear to "pass along" the mocked data so to speak. Am investigating still.
from redwood.
I just merged it. If you need any help I am starting to learn the redwood repo I can help
from redwood.
Related Issues (20)
- [Bug?]: graphiql authImpersonation breaking on windows HOT 3
- [Bug?]: Flight control deployment not working HOT 2
- [Bug?]: yarn scaffold script shows 404 when fetching packages HOT 9
- [Bug]: CLI commands fail due to unawaited promise (JS projects)
- [Bug?]: baremetal production HOT 5
- [Bug] Doubled up title when no explicit <title> set
- [Docs]: Outdated / incomplete doc regarding async directive testing HOT 3
- [Bug?]: Upgrading Redwood to Canary causes "unmountComponentAtNode is not a function" in Storybook
- [Bug?]: When using Trusted Documents and Auth, the Current User query is not permitted preventing authentication to work properly
- [Bug?]: `yarn rw dev` doesn't work because of fsevents dep HOT 4
- chore(deps): update dependency @supabase/supabase-js to v2.43.5
- [Bug?]: Can't configure Jest/Vitest to run tests inside of scripts dir
- [Bug?]: `web/src/auto-imports.d.ts` file generated after running `yarn rw storybook-vite` HOT 4
- [Bug?]: Pre-render does not work HOT 7
- [Bug?]: Flaky Testing with Prisma migrations failing HOT 5
- [Bug]: Docs search is broken HOT 3
- [Bug?]: yarn rw upgrade for 7.7.1 error HOT 6
- [Bug]: Scenario files in a __tests__ directory throws error in Jest HOT 3
- [Bug?]: Docker compose errors with graphql fragments HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redwood.