Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use Deferred Static Generation with the Gatsby Source Kontent Plugin #197

Closed
bwlng opened this issue Nov 15, 2021 · 4 comments
Closed
Assignees

Comments

@bwlng
Copy link

bwlng commented Nov 15, 2021

Brief bug description

Gatsby builds using the new defer argument for the createPage action in gatsby-node.js to exclude the page from the build step and instead generate it during the first HTTP request result in an error during the build process.

During the Validating Rendering Engines portion of the build process, the following error is thrown:

Gatsby kontent source plugin resulted to error in `createSchemaCustomization` method ENOENT: no such file or directory, open '.cache/query-engine/template.items.schema.gql'

Error: ENOENT: no such file or directory, open '.cache/query-engine/template.items.schema.gql'

Repro steps

  1. Add the defer argument to a createPage action in gatsby-node.js
  2. Run npm run build
  3. See error

Expected behavior

The site should build. Remove the defer argument from the createPage action then run npm run build and the site will build as expected.

Test environment

  • Gatsby 4.1.5
  • Gatsby Source Kontent 8.0.0-beta.1

Additional context

A repo with reproducible steps in the README is available here: https://github.com/bwlng/gatsby-kontent-dsg-issue

@bwlng
Copy link
Author

bwlng commented Nov 15, 2021

A member of the Gatsby team mentioned the fix may be similar to this issue on gatsby-plugin-loadable-components-ssr: graysonhicks/gatsby-plugin-loadable-components-ssr#46

@Simply007
Copy link
Contributor

A member of the Gatsby team mentioned the fix may be similar to this issue on gatsby-plugin-loadable-components-ssr: graysonhicks/gatsby-plugin-loadable-components-ssr#46

The cause is similar

To identify a file, I am using __dirnane to get current folder for the loading the file content - and in build the __dirname is being set to .cache/query-engine

I have placed the debugger to the file loading place in ~\.cache\query-engine\index.js and when the debugger was hit I haven't found template.items.schema.gql file in the issue .cache folder.


I have reached out to Gatsby devs to get the best practice for the fix.

@Simply007 Simply007 mentioned this issue Nov 22, 2021
6 tasks
@Simply007
Copy link
Contributor

@bwlng

Gatsby did not respond yet, but I have tried to rewrite templated files to TS modules and tested it and it looks it works fine.

I have also tried it on your repo and seems fine.

https://www.npmjs.com/package/@kentico/gatsby-source-kontent/v/8.0.0-beta.2

If it is fixed, please close this issue.

@Simply007 Simply007 self-assigned this Nov 29, 2021
@Simply007
Copy link
Contributor

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

No branches or pull requests

2 participants