Using Gatsby's Schema Customization APIs with @gatsby-contrib/gatsby-plugin-elasticlunr-search and resolving references in

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
reference on it. A category simply has a
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
doesn’t work, either
May 1, 2020, 1:37 PM
May 1, 2020, 1:40 PM
Figured it out:
May 1, 2020, 2:21 PM

Sanity– build remarkable experiences at scale

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

Was this answer helpful?