HOME > 問題解決一覧 > [Gatsby.js]gatsby develop時にField "xxxx" must not have a selection since type "String" has no subfields.のエラーがでる

事象

gastby develop実行時に次のように「Field "xxxx" must not have a selection since type "String" has no subfields.」エラーが出てしまいます。

gatsby type string has no subfields 01

% npm run develop

> my-gatsby-site@1.0.0 develop
> gatsby develop

success compile gatsby files - 0.361s
success load gatsby config - 0.048s
success load plugins - 0.830s
success onPreInit - 0.003s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's no stale data.
success initialize cache - 0.105s
success copy gatsby files - 0.139s
success Compiling Gatsby Functions - 0.133s
success onPreBootstrap - 0.148s
success createSchemaCustomization - 0.011s
success Checking for changed pages - 0.003s
success source and transform nodes - 5.791s
success building schema - 0.220s

 ERROR #85922  GRAPHQL

There was an error in your GraphQL query:

      Field "icon" must not have a selection since type "String" has no subfields.

      This can happen if you e.g. accidentally added { } to the field "icon". If you didn't expect "icon" to be of type "String" make sure that your input source and/or plugin is
correct.
      However, if you expect "value" to exist, the field might be accessible in another subfield. Please try your query in GraphiQL.

      It is recommended to explicitly type your GraphQL schema if you want to use optional fields.

File: node_modules/gatsby-plugin-local-search/src/gatsby-node.ts:95:5

See our docs page for more info on this error: https://gatsby.dev/creating-type-definitions


 ERROR 

gatsby-plugin-local-search - The provided GraphQL query contains errors. The index will not be created. Field "icon" must not have a selection since type "String" has no subfields.

  GraphQLError: Field "icon" must not have a selection since type "String" has no subfields.

解決方法

次のようにGraphQLで取得するデータの画像のパスを指定している箇所などでパスの指定が間違っている場合にこのエラーが発生します

パスの指定を修正すればエラーは解消されるはずです。

gatsby type string has no subfields 02

コメント

この記事に関する質問やご意見・ご感想がありましたら、下記よりコメントください。
Githubアカウントでログインしていれば誰でも投稿できます。