`fetchLinks` does not work on sub-documents anymore

Hi,

First a little of background informations:
We're using the REST API v2 via @prismicio/client to fetch the documents.

We have two Models (Event & EventCategory).

# Event
- title: StructuredText
- category: Link<EventCategory>

# EventCategory
- name: key StructuredText

In our Page we have a slice, which references to an Event.

The parameter for the query of the page looks like this:
The important part is event_category.name

{
 	client: Client(),
	uid: () => 'home',
	lang: 'de-li',
	params: {
		fetchLinks: [
			'event.title',
			'event.category',
			'event_category.name'
	],
}

and here is the result:

{
	"props": {
		"id": "YLdQjxMAACMAOv1U",
		"uid": "home",
		"url": "/home",
		"type": "page",

		// ...

		"data": {
			// ...

			"body": [
				{
					"slice_type": "event_category_teaser",
					"slice_label": null,
					"version": "sktwi1xtmkfgx8626",
					"variation": "default-slice",
					"primary": {
						"eyebrow": "Test",
						"title": []

						// ...
					},
					"items": [
						{
							"event": {
								"id": "YKPBXxIAACAAiSE8",
								"type": "event",
								"tags": [],
								"slug": "lgt-academy.",
								"lang": "de-li",
								"uid": "lgt-academy",
								"data": {
									"title": [
										{
											"type": "heading1",
											"text": "LGT Academy.",
											"spans": []
										}
									],
									"category": {
										"id": "YKPBdhIAACIAiSGk",
										"type": "event_category",
										"tags": [],
										"slug": "curriculum",
										"lang": "de-li",
										"uid": "curriculum",
										"link_type": "Document",
										"isBroken": false
									}
								},
								"link_type": "Document",
								"isBroken": false
							}
						},
						{
							"event": {
								"id": "YKPYfxIAACEAiWWw",
								"type": "event",
								"tags": [],
								"slug": "drive4impact.",
								"lang": "de-li",
								"uid": "drive4impact",
								"data": {
									"title": [
										{
											"type": "heading1",
											"text": "Drive4Impact.",
											"spans": []
										}
									],
									"category": {
										"id": "YFG8kBIAACQADbd6",
										"type": "event_category",
										"tags": [],
										"slug": "seminar",
										"lang": "de-li",
										"uid": "seminar",
										"link_type": "Document",
										"isBroken": false
									}
								},
								"link_type": "Document",
								"isBroken": false
							}
						}
					]
				}
			]
		},
		"error": null,
		"slices": [
			{
				"slice_type": "event_category_teaser",
				"slice_label": null,
				"version": "sktwi1xtmkfgx8626",
				"variation": "default-slice",
				"primary": {
					"eyebrow": "Test",
					"title": [],
					
                    // ...
				},
				"items": [
					{
						"event": {
							"id": "YKPBXxIAACAAiSE8",
							"type": "event",
							"tags": [],
							"slug": "lgt-academy.",
							"lang": "de-li",
							"uid": "lgt-academy",
							"data": {
								"title": [
									{
										"type": "heading1",
										"text": "LGT Academy.",
										"spans": []
									}
								],
								"category": {
									"id": "YKPBdhIAACIAiSGk",
									"type": "event_category",
									"tags": [],
									"slug": "curriculum",
									"lang": "de-li",
									"uid": "curriculum",
									"link_type": "Document",
									"isBroken": false

                                    // <--- data is missing
								}
							},
							"link_type": "Document",
							"isBroken": false
						}
					},
					{
						"event": {
							"id": "YKPYfxIAACEAiWWw",
							"type": "event",
							"tags": [],
							"slug": "drive4impact.",
							"lang": "de-li",
							"uid": "drive4impact",
							"data": {
								"title": [
									{
										"type": "heading1",
										"text": "Drive4Impact.",
										"spans": []
									}
								],
								"category": {
									"id": "YFG8kBIAACQADbd6",
									"type": "event_category",
									"tags": [],
									"slug": "seminar",
									"lang": "de-li",
									"uid": "seminar",
									"link_type": "Document",
									"isBroken": false

                                    // <--- data is missing
								}
							},
							"link_type": "Document",
							"isBroken": false
						}
					}
				]
			}
		]
	}
}

As we can see, the event in the slice is correctly rendered with his properties title and category, but the category itself does not have the data attribute where we would find the name as we would expect.

We believe it was working a few days ago (We still have a version of the webpage, which includes the category data)

Did anything on the api change?
Is it the expected behaviour? If so, how do we get the properties of the category?

Thanks for your help.

Best
Alex

We are getting a 502 bad gateway error when using the v2 API to query the documents endpoint with fetchLinks included in the query

I've noticed it only fails when including one specific content type, in our cases we have a product content type and are including "product.slices" in the fetchLinks query params.

All was working as of a couple of days ago so I'm unsure why this might be failing now. Has the api changed? This is affecting our ability to preview/publish and any help would be appreciated.

Thanks

Hi Team,

I believe both of these issues are related to a bug a fix a few days ago. I know this might sound weird because it was useful for you, but the fact that you could go 2 levels deep with fetchlinks was a bug that was causing performance issues on some repositories. It wasn't the intentional functionality and was only possible on some repos by chance.

We will update the fetchlinks docs to make it clearer that this is only intended for 1 level deep.

The thing to use if you want to go 2 levels deep is GraphQuery (Fecthlinks V2):

You add this just like the Fetchlinks query option, but the query looks like this:

const mySuperGraphQuery = `{
  blog {
    field1
    field2
    author_link {
      name
    }
  }
}`

api.getByUID('blog', 'example-uid',
  { 'graphQuery': mySuperGraphQuery }
).then(function (document) {
  // document contains the document content
});

Really bad to push this without notifying anyone who was using this. A ton of features are now broken on our website.

@dev13 @diana @software , We are going to roll back. Can you all share with me your repository URLs so I can check this and make sure you repositories are rolled back?

lick.prismic.io please fix ASAP our entire navigation has errored out

Hi,

We are facing the exact same problem, many of our pages are now broken. Our repo is : https://360learning.prismic.io/

I've shared your repo with the team also.

2 Likes

Please in future send us an email asking us to kindly use the GraphQL api so we can plan this change in. A notice within our account would even suffice. E.g when shopify release a breaking change update they send us an email and put a notice on our dashboard with enough time to react and plan the change.

Could we also have access to your public road map?

This is a strange one in this case, because it was meant to be fixing a bug because fetchlinks shouldn't work to this level. We normally always communicate on breaking changes, I believe there was some internal communication misunderstanding on this one. The team are working hard to move any effected repositories.

You can find our roadmap here:
https://prismic.io/progress

Also just to be clear GraphQuery isn't GraphQL, GraphQuery is a query option in the Rest API.

Oure repo is amplify-demo.prismic.io

It is a strange one. I appreciate that, it just sucks that in the last couple of weeks we have had several issues with your releases. We were also impacted by the where GraphQL query bug in which it 500 errored (not sure what exactly the fix was on your end but I had to unpublish and re-publish every affected page)...

What is the timeline on fixing our repo? As you can imagine we are losing significant revenue from customer not being able to correctly navigate the site?

Can you check now? Is the issue still there?

It should be rolled back.

The rollback fixed the issue on our end.

  • Do you recommend that we replace our fetchLinks with graphQuery for the future ?
  • Do you plan on redeploying this fix ?
    • or will the possibility to query second level document stay ?

Working again. I will be spending the weekend and early part of next week moving over to the GraphQL api (we already started on other parts of the site this was the one part we left for now).

Phew.

Yes, if you continue to use the REST API and want to get content from two levels deep then you should replace fetchLinks with graphQuery.

I believe this will be redeployed at some stage because of the performance issues mentioned above.

Sorry again everyone for the issues caused by this.

For anyone else who's experiencing this, drop your repo URL here and will pass it on to the team.

1 Like

Thanks for the rollback.

Our repo ist 'liechtenstein-academy'.

It looks good so far.

So after seeing how everyone is relying on this, we've decided to make it possible for fetchlinks to go 2 levels deep everywhere. I'll update this thread once this is shipped everywhere.

For anyone that can't currently go 2 levels deep with fetchlinks please use the GraphQuery Rest API query option:

Thanks.