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

Failed to compile with 2 errors #24

Open
sajjadalis opened this issue Dec 17, 2019 · 4 comments
Open

Failed to compile with 2 errors #24

sajjadalis opened this issue Dec 17, 2019 · 4 comments

Comments

@sajjadalis
Copy link

sajjadalis commented Dec 17, 2019

First time using Gridsome.. Tried with both WordPress starters. This one and other bootstrap.. Same error on both. What i'm doing wrong?

ERROR  Failed to compile with 2 errors                                                                       2:57:01 AM

 error  in ./src/templates/WordPressPost.vue?vue&type=custom&index=0&blockType=page-query

Module build failed (from ./node_modules/gridsome/lib/plugins/vue-components/lib/loaders/page-query.js):
Error: Cannot query field "mediaDetails" on type "WordPressAttachment". Did you mean "mediaType"?

GraphQL request:44:7
43 |       altText
44 |       mediaDetails {
   |       ^
45 |         width
    at Object.module.exports (D:\Apps\gridsome-wp\node_modules\gridsome\lib\plugins\vue-components\lib\loaders\page-query.js:28:21)

 @ ./src/templates/WordPressPost.vue?vue&type=custom&index=0&blockType=page-query 1:0-339 1:355-358 1:360-696 1:360-696
 @ ./src/templates/WordPressPost.vue
 @ ./src/.temp/routes.js
 @ ./node_modules/gridsome/app/router.js
 @ ./node_modules/gridsome/app/entry.sockjs.js
 @ multi webpack/hot/dev-server webpack-hot-middleware/client?name=app&reload=true ./node_modules/gridsome/app/entry.client.js ./node_modules/gridsome/app/entry.sockjs.js

 error  in ./src/components/TagsWidget.vue?vue&type=custom&index=0&blockType=static-query

Module build failed (from ./node_modules/gridsome/lib/plugins/vue-components/lib/loaders/static-query.js):
Error: Cannot query field "title" on type "WordPressPostTag".

GraphQL request:22:9
21 |       node {
22 |         title
   |         ^
23 |         slug
    at Object.module.exports (D:\Apps\gridsome-wp\node_modules\gridsome\lib\plugins\vue-components\lib\loaders\static-query.js:34:14)

 @ ./src/components/TagsWidget.vue?vue&type=custom&index=0&blockType=static-query 1:0-340 1:356-359 1:361-698 1:361-698
 @ ./src/components/TagsWidget.vue
 @ ./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/babel-loader/lib??ref--1-1!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/SiteSidebar.vue?vue&type=script&lang=js&
 @ ./src/components/SiteSidebar.vue?vue&type=script&lang=js&
 @ ./src/components/SiteSidebar.vue
 @ ./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/babel-loader/lib??ref--1-1!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/layouts/Default.vue?vue&type=script&lang=js&
 @ ./src/layouts/Default.vue?vue&type=script&lang=js&
 @ ./src/layouts/Default.vue
 @ ./src/main.js
 @ ./node_modules/gridsome/app/main.js
 @ ./node_modules/gridsome/app/app.js
 @ ./node_modules/gridsome/app/entry.client.js
 @ multi webpack/hot/dev-server webpack-hot-middleware/client?name=app&reload=true ./node_modules/gridsome/app/entry.client.js ./node_modules/gridsome/app/entry.sockjs.js

In gridsome.config.js

module.exports = {
  siteName: 'Gridsome',
  siteDescription: 'A WordPress starter for Gridsome',

  templates: {
    WordPressCategory: '/category/:slug', // adds route for "category" post type (Optional)
    WordPressPost: '/:year/:month/:day/:slug', //adds route for "post" post type (Optional)
    WordPressPostTag: '/tag/:slug' // adds route for "post_tag" post type (Optional)
  },

  plugins: [
    {
      use: '@gridsome/source-wordpress',
      options: {
        baseUrl: 'http://words.test/', // process.env.WORDPRESS_URL, // required
        typeName: 'WordPress', // GraphQL schema name (Optional)
      }
    }
  ]
}
@choyan
Copy link

choyan commented Dec 25, 2019

Same problem here. Working 10 days ago. Suddenly stopped working.

@sebtiz13
Copy link

Have same problem, even with fresh install of wordpress

@sebtiz13
Copy link

Ok these errors occur when no media has been created and no one post has tags.

For tags :
I think is due to this part https://github.com/gridsome/gridsome/blob/master/packages/source-wordpress/index.js#L152

Because use map on empty array if no post contains tags the createReference function is never called and graphql does not add the tags property in the type WordPressPost.

If you don't use tags on wordpress you can remove

On template

<template v-if="$page.wordPressPost.tags.length">
  <h4>Tags</h4>
  <ul class="list tags">
    <li v-for="tag in $page.wordPressPost.tags" :key="tag.id" >
      <g-link :to="tag.path">{{ tag.title }}</g-link>
    </li>
  </ul>
</template>

and on page-query

tags {
  id
  title
  path
}

To remove errors in the generations

@rasult22
Copy link

I've got the same problem, because I didn't create posts and didn't link to one of them the tagname

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

4 participants