GraphQL WordPress featured_media fail
November 09, 2019
success source and transform nodes - 8.360 s
warn Multiple node fields resolve to the same GraphQL field `wordpress__wp_media.guid`
success building schema - 0.523 s
[ { GraphQLError: Unknown fragment "GatsbyImageSharpFluid".
at Object.FragmentSpread (/Development/PHP/Sites/site.local/gatsby/node_modules/graphql/validation/rules/KnownFragmentNames.js:37:29)
So this issue was a real thumper. I’m new to Gatsby, GraphQL and not as clued with the WP Rest API, so debugging this was some journey. Which ended with;
Gatsby will not compile if your try to query featured_media for your posts IF you have any post without a featured image.
Possible solutions (If you have any other ones tweet me @jghazally):
- Add featured images to all posts (that’s what I’m going to do for the interim)
- Add a fallback image in the WP API
- Use GraphQL fragments? I don’t know how this exactly works but think this is the correct / best way.
Chrome bugging you about insecure connections on localhost?
Sick of clicking Trust this site on your own Localhost. Like seriously chrome 🤦🏼♂️
Exclude a folder from your git diff
Need a way to show your git diff in your terminal while excluding a folder from your results? While boy do I have a trick for you!
Get Cloudflare geolocation data client side
Cloudflare provide a very handy HTTP Header called `CF-IPCountry` which you can use to detect your users geolocation but there is another way.
What y’all thought