blog/unleash-the-power-of-fragments-with-graphql-codegen #918
Replies: 13 comments 18 replies
-
I cannot for the life of me figure out how I can do the |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
How do we get syntax highlighting for this API with https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql-syntax&ssr=false#overview ? |
Beta Was this translation helpful? Give feedback.
-
I cannot figure out how to get your eslint rules to work with this setup. Is there a standalone project example I can refer to? |
Beta Was this translation helpful? Give feedback.
-
This has complicated things a lot imo, typing is a hell now once you use fragments. Each time I have to use the FragmentType helper or useFragment or both. Tried to type a state variable with this, wasn't even able to figure it out. In previous versions this was much simpler by just importing the fragment type and you'd be done. |
Beta Was this translation helpful? Give feedback.
-
I wonder if with error paths in GQL responses it would be possible for individual fragment hooks to give an error, for more granular error handling. |
Beta Was this translation helpful? Give feedback.
-
Does |
Beta Was this translation helpful? Give feedback.
-
Thanks for the article! Can you explain the best way to test such components? Currently, I have to put together the input data from a set of fragments which is a little annoying. It would be great if I could define a my mock data as a single object and pass that in instead. For example: // Currently only this works const basicUser: BasicUserFragment = {
id: 'test',
ldap: 'ldap',
firstName: 'First',
fullName: 'First Last',
__typename: 'UserResource',
};
const metricViewMock: MetricBlockFragment = {
id: 'test',
name: 'Metric Name',
userMetricQuery: {
ldap: 'ldap',
},
ownerUser: basicUser,
}; But it would be easier to just do this especially if there are a lot of nested fragments. // One mock data object
const metricViewMock = {
id: 'test',
name: 'Metric Name',
userMetricQuery: {
ldap: 'ldap',
},
ownerUser: {
id: 'test',
ldap: 'ldap',
firstName: 'First',
fullName: 'First Last',
__typename: 'UserResource',
},
}; |
Beta Was this translation helpful? Give feedback.
-
Does this work with Flutter too? |
Beta Was this translation helpful? Give feedback.
-
How to refetch specific fragment? |
Beta Was this translation helpful? Give feedback.
-
Do this pattern pushes the developer to apply prop drilling? |
Beta Was this translation helpful? Give feedback.
-
Also interesting how to access data in deeply nested components using such approach. |
Beta Was this translation helpful? Give feedback.
-
I have a problem with Typescript (and apollo client) and don't know how to solve it. The child component expects the type In the end, everything works, but there is a type error because the result of the apollo hook does not correspond to the FragmentType. Root Component
Child component
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
blog/unleash-the-power-of-fragments-with-graphql-codegen
The most important parts of Relay are the concepts of building and scaling applications, let's show how you can use these patterns in your existing project, no matter what client library you are currently using.
https://the-guild.dev/blog/unleash-the-power-of-fragments-with-graphql-codegen
Beta Was this translation helpful? Give feedback.
All reactions