Skip to content

Gatsby v4: jsonId automatic property prevents Json mapping in gatsby-config to be done #33798

Answered by LekoArts
no-chris asked this question in Help
Discussion options

You must be logged in to vote

Hi!

You'll need to update your usage of mapping to make this work:

mapping: {
  'ExperienceJson.items.tech': `TechJson.jsonId`
}

I'll update the doc to update that and highlight again that people should use @link directive via schema customization instead: https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization/#foreign-key-fields

So for your case this would be:

exports.createSchemaCustomization = ({ actions }) => {
  const { createTypes } = actions

  createTypes(`
    type ExperienceJsonItems {
      tech: [TechJson] @link(by: "jsonId")
    }
  `)
}

You can use __typename to get the names you need:


PR: #33799

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by no-chris
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
topic: GraphQL Related to Gatsby's GraphQL layer
2 participants
Converted from issue

This discussion was converted from issue #33746 on November 01, 2021 15:38.