-
Preliminary Checks
DescriptionIt seems that Gatsby v4 breaks the As I understand, that is because the mapping between the 2 entities is done by default on the Replacing Reproduction Linkhttps://github.com/no-chris/json-mapping-bug Steps to Reproduce
query MyQuery {
experience: allExperienceJson {
edges {
node {
company
position
from
to
items {
label
description
tech {
icon
color
label
}
}
}
}
}
} Expected Result{
"data": {
"experience": {
"edges": [
{
"node": {
"company": "Company A",
"position": "Unicorn Developer",
"from": "Dec 2016",
"to": "Present",
"items": [
{
"label": "Responsibility",
"description": "Being an unicorn",
"tech": null
},
{
"label": "Hands on",
"description": null,
"tech": [
{
"icon": "facebook",
"color": "teal",
"label": "React"
},
{
"icon": "server",
"color": "green",
"label": "NodeJS"
}
]
}
]
}
}
]
}
},
"extensions": {}
} Actual ResultNotice {
"data": {
"experience": {
"edges": [
{
"node": {
"company": "Company A",
"position": "Unicorn Developer",
"from": "Dec 2016",
"to": "Present",
"items": [
{
"label": "Responsibility",
"description": "Being an unicorn",
"tech": null
},
{
"label": "Hands on",
"description": null,
"tech": []
}
]
}
}
]
}
},
"extensions": {}
} EnvironmentSystem:
OS: macOS 11.4
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.18.0 - ~/.nvm/versions/node/v14.18.0/bin/node
npm: 6.14.15 - ~/.nvm/versions/node/v14.18.0/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 95.0.4638.54
Firefox: 91.0.2
Safari: 14.1.1
npmPackages:
gatsby: ^4.0.2 => 4.0.2
gatsby-source-filesystem: ^4.0.0 => 4.0.0
gatsby-transformer-json: ^4.0.0 => 4.0.0
npmGlobalPackages:
gatsby-cli: 4.0.0 Config FlagsNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi! You'll need to update your usage of mapping: {
'ExperienceJson.items.tech': `TechJson.jsonId`
} I'll update the doc to update that and highlight again that people should use So for your case this would be: exports.createSchemaCustomization = ({ actions }) => {
const { createTypes } = actions
createTypes(`
type ExperienceJsonItems {
tech: [TechJson] @link(by: "jsonId")
}
`)
} You can use PR: #33799 |
Beta Was this translation helpful? Give feedback.
-
That worked like a charm for my use case, thanks a lot! 🙌🏻 |
Beta Was this translation helpful? Give feedback.
Hi!
You'll need to update your usage of
mapping
to make this work: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-fieldsSo for your case this would be:
You can use
__typename
to get the names you need:PR: #33799