GraphQL WordPress featured_media fail

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):

  1. Add featured images to all posts (that’s what I’m going to do for the interim)
  2. Add a fallback image in the WP API
  3. Use GraphQL fragments? I don’t know how this exactly works but think this is the correct / best way.

What y’all thought

Have something to say?