I have been working on utilizing the dynamic zone component using graphql fragments. I have been working off the tutorial and after having hit roadblock after roadblock (which forced me to get a better understanding of fragments and unions as im a noob!) i still havent managed to get things working.
Since i couldnt get things to work, i took a test run off the repo provided (which is genius btw!) which works as intended after some package updates.
However, in my own project my fragmentTypes.json seems to render very differently and is subsequently trowing me an error “Cannot read property ‘types’ of undefined”.
Excerpt of the repo’s fragmentTypes.json:
{
"__schema": {
"types": [
{
"kind": "UNION",
"name": "Morph",
"possibleTypes": [
{
"name": "UsersPermissionsMe"
},
{
"name": "UsersPermissionsMeRole"
},
Etcetera
{
"kind": "UNION",
"name": "PagesPageZoneDynamicZone",
"possibleTypes": [
{
"name": "ComponentPostQuote"
},
{
"name": "ComponentPostImage"
},
{
"name": "ComponentPostRichText"
}
]
}
And the fragmentTypes.json rendered in my own project (notice how it is missing the " __schema" & “types” decleration:
{
"possibleTypes": {
"CollectionPageZoneDynamicZone": [
"ComponentDynamicImageAndText",
"ComponentDynamicImageSlider",
"ComponentDynamicRichText"
],
"GqlfragmentPageZoneDynamicZone": [
"ComponentDynamicImageAndText",
"ComponentDynamicImageSlider",
"ComponentDynamicRichText"
],
"Morph": [
"UsersPermissionsMe",
"UsersPermissionsMeRole",
"UsersPermissionsLoginPayload",
"UserPermissionsPasswordPayload",
"Collection",
Etcetera
In my reading up on the topic, i found that since apollo ^3.0 there has been a change in decleration and use of fragments, maybe that has something to do with it?
V2 fragment docs
^V3 fragment docs
Any help would be greatly appreciated!