Incorrect UID/slug with fetchLinks in link resolver

Hi!

I'm using the REST API v2 via prismic-javascript to fetch my documents. I am using fetchLinks to fetch a content relationship field's document data to create a URL in my link resolver.

When I log the value of doc in my link resolver for a document with a parent, I receive the following payload. The content relationship field is named parent.

{
  id: 'DOC_ID_CHILD',
  type: 'page',
  tags: [],
  slug: 'business-savings',
  lang: 'en-us',
  uid: 'business-savings',
  data: {
    parent: {
      type: 'Link.document',
      value: {
        document: {
          id: 'DOC_ID_PARENT',
          type: 'page',
          lang: 'en-us',
          tags: [],
          slug: 'business-banking',
          uid: 'business-savings'
        }
      },
      isBroken: false
    }
  },
  link_type: 'Document',
  isBroken: false
}

I see two possibly related problems with the payload:

  1. There seems to be a mixture of GraphQL and non-GraphQL style link payloads. One uses link_type: Document while the other uses type: 'Link.document'. I don't believe this repo has GraphQL enabled as it was created in 2018.

  2. slug and uid in the parent document are out of sync and incorrect.

UID - It's providing the UID of the child document, not the parent document.

  • Expected: business-banking
  • Actual: business-savings

Slug - This is correct, but slug has been known to be out of sync/outdated.

  • Expected: business-banking
  • Actual: business-banking

I'm aware slug is deprecated, but it currently is the only way I am able to get the correct UID. This causes issues in other parts of the site where the slug is incorrect.

Any ideas? I can provide more detailed, specific information in a private chat if necessary.

Hi @angeloashmore, I’m sorry that you’re having trouble with this. I’d like to take a closer look at this. Can you DM me with links to your Prismic repository so that I can look into this?

Hi @Levi, thanks for the reply. Sorry, I can’t find a way to send a message here. Is there supposed to be a Message button here?

@angeloashmore Sorry about that. I just sent you a DM so that we can move forward with this.

Closing due to inactivity