gatsby-source-sanity icon indicating copy to clipboard operation
gatsby-source-sanity copied to clipboard

References are not resolved correctly in `7.4.2`

Open marijoo opened this issue 3 years ago • 4 comments
trafficstars

After upgrading to gatsby-source-sanity to 7.4.2 references are not resolved correctly anymore. We have a BlockContent that accepts the following schema type:

name: 'pageLinks',
  title: 'Page Links',
  type: 'object',
  fields: [
    {
      name: 'pages',
      title: 'Pages',
      type: 'array',
      of: [{ type: 'documentReference' }],
    },
  ]
  ...

Where documentReference contains a reference to some document types:

name: 'documentReference',
  type: 'object',
  fields: [
    {
      name: 'reference',
      type: 'reference',
      title: 'Document',
      to: [{ type: 'division' }, { type: 'page' }],
    },
   ...

The problem is that querying for _rawBody(resolveReferences: {maxDepth: 10}) does not resolve all fields that used to be resolved. For example the referenced document will not include internal.type. After downgrading to 7.3.2 everything works fine again and internal.type contains SanityPage or SanityDivision as expected.

marijoo avatar May 06 '22 12:05 marijoo

Any update?

zanedev avatar Jun 29 '22 14:06 zanedev

The internal data on nodes gets deleted as of Pull Request #147, might be the root cause of this.

raae avatar Jun 29 '22 16:06 raae

Folks with resolveReferences issues... be sure to run gatsby clean to clear your cache! https://github.com/sanity-io/gatsby-source-sanity/issues/152

I was convinced references weren't working in my PortableText blocks nested in an array field.

doublejosh avatar Mar 22 '23 21:03 doublejosh

Folks with resolveReferences issues... be sure to run gatsby clean to clear your cache! #152

I was convinced references weren't working in my PortableText blocks nested in an array field.

Not really a solution as it causes longer build times and unnecessary usage of external API's etc.

intelligence avatar Apr 23 '23 14:04 intelligence