Comments (6)
I agree 😊
from gatsby-source-graphcms.
I faced the same issue when trying to map my modular content to react components. I ended up writing a custom resolver, it adds the remoteTypeName as a "component" field on my the contents types I add it to. Its exported from gatsby-node.ts
export const createResolvers: GatsbyNode["createResolvers"] = ({
createResolvers,
}) => {
const addComponentResolver = {
component: {
type: "String",
resolve: (source: { remoteTypeName: any }) => {
return source.remoteTypeName;
},
},
};
createResolvers({
HygraphCMS_Block: addComponentResolver,
HygraphCMS_Grid: addComponentResolver,
HygraphCMS_GridColumn: addComponentResolver,
HygraphCMS_Link: addComponentResolver,
HygraphCMS_ButtonLink: addComponentResolver,
...any other type that needs the component field
});
};
from gatsby-source-graphcms.
This is probably because of a do not infer policy set by GraphCMS on the node's schema.
from gatsby-source-graphcms.
Seems this is done by gatsby-graphql-source-toolkit
that is used: https://www.npmjs.com/package/gatsby-graphql-source-toolkit#5-add-explicit-types-to-the-gatsby-schema
from gatsby-source-graphcms.
Hi raae,
Thank you for your reply and useful insights.
That however does not solve my problem.
Let me elaborate a bit more, I have a Page in GraphCMS that has multiple types of modular components I can add:
When I source this into Gatsby, I see this in GraphiQL:
There is no way for me to identify which type of page section I'm dealing with:
And right now it's just two, but I'll be adding a lot more of them.
So either I find a way to add the internal content type of the referred component myself, or the the source plugin is updated to remediate this issue that others must also face someday or have faced already. I like GraphCMS just a bit too much right now to go find another CMS to do this with.
Many thanks for any help on this!
from gatsby-source-graphcms.
Hi @karlwir,
Thank you for your response!
Works like a charm, but I would expect this type of behaviour to be built into the core of this module.
It's a good workaround for now, but every new component that is added to HyGraph would need a code update, which is not ideal.
from gatsby-source-graphcms.
Related Issues (20)
- Assets and localizations HOT 2
- Previous and next navigation for posts filtered by Category in Gatsby project not working HOT 3
- [gatsby-source-graphcms]: Problem building GraphCMS nodes // Error: Bad Request HOT 1
- Dependency Dashboard
- on upgrading to Gatsby 4 return null on build HOT 9
- When build website get the following error "Cannot query field "allGraphCmsPost" on type "Query"" . HOT 2
- Problem building GraphCMS nodes when upgrading to Gatsby v4 HOT 8
- Local images are null on gatsby build, but correct in dev mode (Gatsby v4) HOT 36
- Make a note on Granular Permissions usage
- concurrency error HOT 2
- gatsbyImageData return a wrong structs for some images HOT 1
- Markdown nodes null in production HOT 8
- Add ability to serve images in Webp format HOT 5
- Update baseURI to 'https://media.graphassets.com'
- Gastby build - connect ETIMEDOUT HOT 4
- Gatsby V2 fails to build fragments when model has nested components
- Locales not working through relations HOT 1
- Error: Too Many Requests HOT 11
- Gatsby 5 support? HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gatsby-source-graphcms.