Use gatsby-image's GraphQL fragments for blurred-up and traced SVG images

Kyle Gill
InstructorKyle Gill
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 3 years ago

Learn how to simplify the fields you include in your queries for image data by using GraphQL fragments. With this powerful abstraction, changing the fragment will change the behavior of your image, loading it as a minified blurred file or traced svg before loading the full size image when the rest of the content loads.

Instructor: [00:00] With an image where fields are queried in GraphQL, you can use GraphQL fragments provided by Gatsby as a shorthand, instead of writing out all the fields. In the query to get the image's data, instead of typing out each field individually, you can use fragments like GatsbyImageSharpFluid.

[00:14] If you check the data returned by the query, you'll see the same fields returned as before. Different fragments, like tracedSVG, will pull in other fields that will make the gatsby-image component behave in other ways, like adding a traced SVG placeholder, instead of a blurred image.

egghead
egghead
~ 3 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today