Error: “Field “image” must not have a selection since type “String” has no subfields."
Tags: gatsby, graphql
Published: 2019-08-09 14:54:59

---
title: Error: “Field “image” must not have a selection since type “String” has no subfields."
published: true
tags: gatsby, graphql,
canonical_url: https://stephencharlesweiss.com//2019-08-08/error-field-image-string-no-subfields/
---

I was trying to query an image I’d placed in the frontmatter of a post, when I got the error:

> Field ‘image’ must not have a selection since type “String” has no subfields

The query _should_ have worked because `image` in my case, was being transformed by Sharp and so _did_ have children. It would turn out that I was right in theory, but in practice needed to reconfigure a few things to get it to work.

How I debugged this error:

1. Reconfigure the `gatsby-config` so that `plugin-sharp` and `transformer-sharp` are first. This should be all you need to do, but if you’re still having issues after rebuilding, keep going.
2. Delete `.cache`, `public` and `node_modules`
3. Re-install (`npm i`) all dependencies
4. Re-build (`npm run develop` if you’re using a Gatsby starter)

After completing all of these steps, my query worked like a charm and I now had access to children properties of my transformed image.

This is what my config file looks like at the moment:

```javascript
module.exports = {
  siteMetadata: {
    title: ‘My site’,
    description: ‘A test site’,
  },
  plugins: [
    'gatsby-plugin-sharp’,
    'gatsby-transformer-sharp',
    'gatsby-plugin-emotion',
    ‘gatsby-plugin-react-helmet’,
    {
      resolve: ‘gatsby-plugin-mdx’,
      options: {
        extensions: [“.mdx”,”.md”],
        defaultLayouts: {
          default: require.resolve(‘./src/components/layout.js’),
        },
        gatsbyRemarkPlugins: [{ resolve: 'gatsby-remark-images' }],
        plugins: [{ resolve: 'gatsby-remark-images' }],
      },
    },
    {
        resolve: 'gatsby-source-filesystem',
        options: {
            name: 'posts',
            path: 'content/posts'
        }
    },
    {
        resolve: 'gatsby-source-filesystem',
        options: {
            name: 'blog',
            path: 'content/blog'
        }
    },
    {
        resolve: 'gatsby-source-filesystem',
        options: {
            name: 'images',
            path: 'content/images'
        }
    },
  ],
};
```

## <svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Resources

These are two resources I found particularly helpful in debugging this error:

1. [“Field “image” must not have a selection since type “String” has no subfields.” · Issue #13469 · gatsbyjs/gatsby · GitHub](https://github.com/gatsbyjs/gatsby/issues/13469)
2. [Problems with Gatsby Image and their workarounds](https://theleakycauldronblog.com/blog/problems-with-gatsby-image-and-their-workarounds/)