storyblok / gatsby-source-storyblok

Gatsby source plugin for building websites using the Storyblok headless CMS as a data source.
MIT License
43 stars 35 forks source link

GraphQL schema not present during build #24

Closed wirtsi closed 1 year ago

wirtsi commented 4 years ago

Hello

I have the following gatsby-config.js file

module.exports = {
  siteMetadata: {
    title: "Gatsby Default Starter"
  },
  plugins: [
    "gatsby-transformer-sharp",
    "gatsby-plugin-sharp",
    "gatsby-plugin-react-helmet",
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`
      }
    },
    {
      resolve: "gatsby-source-storyblok",
      options: {
        accessToken: "NoQEMh9zMri0Y1FPBTo5mQtt",
        homeSlug: "home",
        version: process.env.NODE_ENV === "production" ? "published" : "draft"
      }
    }
  ]
};

which works perfectly fine during gatsby developmode.

However when I try to run gatsby build I get this error

success open and validate gatsby-configs - 0.036s
success load plugins - 3.759s
success onPreInit - 0.005s
success delete html and css files from previous builds -
success initialize cache - 0.030s
success copy gatsby files - 0.101s
success onPreBootstrap - 0.014s
success createSchemaCustomization - 0.008s
success source and transform nodes - 0.435s
success building schema - 0.427s

 ERROR #85923  GRAPHQL

There was an error in your GraphQL query:

Cannot query field "allStoryblokEntry" on type "Query".

If you don't expect "allStoryblokEntry" to exist on the type "Query" it is most likely a typo.
However, if you expect "allStoryblokEntry" 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 "allStoryblokEntry" 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 "Query":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: gatsby-node.js:6:10

not finished createPages - 0.038s

Any idea what might be causing this?

johnnywalker commented 4 years ago

Not sure if you figured out the issue, but I wanted to leave a note for anyone that encounters this in the future. This error is thrown when no stories are published in Storyblok.

Patrickodey360coder commented 1 year ago

Hello @wirtsi do you still have an issue with this? If yes, feel free to open this back up.