Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Field is not defined by type #8

Open
kailoon opened this issue Mar 31, 2020 · 2 comments
Open

Field is not defined by type #8

kailoon opened this issue Mar 31, 2020 · 2 comments

Comments

@kailoon
Copy link

kailoon commented Mar 31, 2020

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 field StrapiArticle.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:

  • If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
  • The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
  • You want to optionally use your field "categories" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add a least one entry with that field ("dummy content")

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
Copy link
Contributor

Hello @kailoon,

Can you confirm that you still face this issue?

@MrAcalf
Copy link

MrAcalf commented Sep 12, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants