👀 See Sanity in action: Watch product demo now →

Does Sanity Abide by `___NODE` Fieldname Convention Introduced in Schema Customization APIs (Gatsby v2.2)?

4 replies
Last updated: May 1, 2020
Does anyone know if sanity abides by the `___NODE` fieldname convention introduced in the Schema Customization APIs in Gatsby v2.2?
I’m trying to use
@gatsby-contrib/gatsby-plugin-elasticlunr-search and do some simple reference traversal. Consider a blog post that has a
category
reference on it. A category simply has a
title
on it. But when I try to use the following (according to the documentation ), I get nothing:
resolvers: {
  SanityPost: {
    category: (node, getNode) => getNode(node.category___NODE)
  }
}
May 1, 2020, 1:34 PM
If I simply use
category: node => node.category
, I get the category reference. aka
category: {
  _ref: ...
  _type: "reference"
}
but I can’t figure out how to resolve that reference
May 1, 2020, 1:37 PM
getNode(node.category)
doesn’t work, either
May 1, 2020, 1:37 PM
May 1, 2020, 1:40 PM
Figured it out:
getNode(node.category._ref)
May 1, 2020, 2:21 PM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.