styxlab / gatsby-theme-try-ghost

A Gatsby theme to build flaring fast blogs from headless Ghost CMS
MIT License
135 stars 56 forks source link

Fix ghost images plugin #234

Closed illogic-al closed 3 years ago

illogic-al commented 3 years ago

Using gatsby-plugin-ghost-images outside of this project (with a self-hosted ghost blog) was not generating the proper GraphQL nodes. Took me all day, but this commit fixes this problem.

styxlab commented 3 years ago

Thanks a lot for this PR, but I doubt that I can approve it. Let me explain...

An earlier version of this project had the same code for foreign key linking that you are suggesting. The benefit of this variant is that it works without explicit GraphQL types.

In the meantime, we introduced explicit GraphQL custom types, and for that the old way of linking does not work anymore - hence it was changed to the newer variant that you will also find in the more recent Gatsby examples.

I suspect that the plugin works as desired for you as well when you use GraphQL custom types.

illogic-al commented 3 years ago

Hey, thanks for the explanation. I don’t see the code for these custom types in the project though. Can you point me to the file so I can test it out. I found custom types for ImageMeta, but not the rest image. Also, I’m not very familiar with GraphQl yet. I was just reading through the gatsby docs and saw that that was needed for foreign key linking. Feel free to point me to any docs you think might be helpful. 😉

styxlab commented 3 years ago

GraphQL type definitions come from the source plugin, you can take that as a starting point for your own custom types. Custom types are thoroughly documented in the Gatsby docs. I am closing this PR for now. If you fell this topic should be further discussed, please open a new issue.

illogic-al commented 3 years ago

Awesome, thanks for the info!