0
votes

Reading the gatsby-source-contentful docs - https://www.gatsbyjs.org/packages/gatsby-source-contentful/ it claims

"When using reference fields, be aware that this source plugin will automatically create the reverse reference. You do not need to create references on both content types."

My model in contentful has a project, which references a workgroup. If the reverse references are created I should be able to query for all the projects from a workgroup but this capability does not seem to be available to me.

Any help much appreciated.

1

1 Answers

0
votes

Maybe an example would be helpful. I have a content type named blogPost which has a link to many sections. One of them is a "block text" section. I can do this query:

allContentfulSectionBlockText {
    nodes {
      id
      blogpost {
        slug
        sections {
          ... on ContentfulSectionBlockText {
            id
          }
        }
      }
    }
  }

which gets responses like this:

{
  "id": "9dde8955-2c84-53df-abbe-ba39aac081b0",
  "blogpost": [
    {
      "slug": "/10-biblical-principles-for-making-wise-decisions",
      "sections": [
        {
           "id": "9dde8955-2c84-53df-abbe-ba39aac081b0"
        }
      ]
    }
  ]
}

So the reverse reference is the "blogpost" field. You can explore it using the graphiQL in gatsby develop. Navigate via the Document Explorer down to your "workgroup" type and look for the "project" field. This should be a reference to your workgroup.

enter image description here