-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Updated] How can I identify a referenced component's type? #246
Comments
This is probably because of a do not infer policy set by GraphCMS on the node's schema. |
Seems this is done by |
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
|
Hi @karlwir, Thank you for your response! |
I agree 😊 |
[Updated] See this comment for the up to date problem.
Reproduction
You can reproduce the issue with my repo https://github.com/SabbeRubbish/graphcms-bug-repro
Used GraphCMS and latest gatsby default starter.
Added to gatsby-config.js:
Expected behaviour
ALL nodes get a
fields
object withBLAH
as key andBLAH
as value.Actual behaviour
ALL nodes except GraphCMS nodes get the extra field:
![image](https://user-images.githubusercontent.com/5593135/195652384-5ff2f8ac-936c-4824-893f-37ff53001367.png)
![image](https://user-images.githubusercontent.com/5593135/195652457-ea1b82bc-9b01-4417-880e-8c42154a6a7d.png)
But not the GraphCMS nodes:
![image](https://user-images.githubusercontent.com/5593135/195652549-66e194bd-5f7a-4460-8a94-2c1b1c1adcc8.png)
![image](https://user-images.githubusercontent.com/5593135/195652802-350ef709-030d-4a2b-a75b-ef2b1c2d4296.png)
Use case
I want to add an extra field "Type" so that I can distinguish on components' types. For example, I have a page with 2 modular components that I can place on them: section with image or testimonials. But in my page template I need to know which one is which, which is why I want to add a _type field to be able to distinguish.
Thanks for any help!
The text was updated successfully, but these errors were encountered: