strapi / strapi-legacy-gatsby-blog

Strapi Starter Gatsby Blog
MIT License
102 stars 86 forks source link

Field is not defined by type #8

Open kailoon opened 4 years ago

kailoon commented 4 years ago

The error: success open and validate gatsby-configs - 0.038s success load plugins - 1.128s success onPreInit - 0.006s success initialize cache - 0.016s success copy gatsby files - 0.139s success onPreBootstrap - 0.019s success createSchemaCustomization - 0.015s info Starting to fetch data from Strapi - http://localhost:1337/articles info Starting to fetch data from Strapi - http://localhost:1337/categories success Fetched Strapi Data - 0.086s success source and transform nodes - 0.169s warn Multiple node fields resolve to the same GraphQL fieldStrapiArticle.image- [image,image___NODE`]. success building schema - 0.542s success createPages - 0.045s success createPagesStatefully - 0.095s success onPreExtractQueries - 0.002s success update schema - 0.048s

ERROR #85901 GRAPHQL

There was an error in your GraphQL query:

Field "category" is not defined by type StrapiArticleFilterInput.

File: src/templates/category.js:9:42

ERROR #85923 GRAPHQL

There was an error in your GraphQL query:

Cannot query field "categories" on type "StrapiArticle".

If you don't expect "categories" to exist on the type "StrapiArticle" it is most likely a typo. However, if you expect "categories" to exist there are a couple of solutions to common problems:

It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "StrapiArticle": https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: src/pages/index.js:19:17

failed extract queries from components - 0.572s success write out requires - 0.051s success write out redirect data - 0.003s success Build manifest and related icons - 0.187s success onPostBootstrap - 0.197s ⠀ info bootstrap finished - 8.018 s ⠀ success run queries - 0.054s - 6/6 111.07/s

ERROR #98123 WEBPACK

Generating development JavaScript bundle failed

/Users/kailoon/Sites/strapi-gatsby/frontend/src/pages/index.js 19:17 error Cannot query field "categories" on type "StrapiArticle" graphql/template-strings

✖ 1 problem (1 error, 0 warnings)

File: src/pages/index.js

ERROR #98123 WEBPACK

Generating development JavaScript bundle failed

/Users/kailoon/Sites/strapi-gatsby/frontend/src/templates/category.js 9:42 error Field "category" is not defined by type StrapiArticleFilterInput graphql/template-strings

✖ 1 problem (1 error, 0 warnings)

File: src/templates/category.js

failed Building development bundle - 5.902s`

There is no category filter https://envato.d.pr/PtqQ57

Been following the whole tutorial do some debugging, but no success. Any help will be great!

Mcastres commented 4 years ago

Hello @kailoon,

Can you confirm that you still face this issue?

MrAcalf commented 4 years ago

GraphQL Error Field "category" is not defined by type StrapiArticleFilterInput; Did you mean categories or created_by?

file: /mnt/c/Projects/strapi-gatsby-typescript-blog/frontend/src/templates/Category.tsx

1 | 2 | query Category($id: Int!) {

3 | articles: allStrapiArticle(filter: { category: { id: { eq: $id } } }) { ^

I am facing same error