Hello. Thanks for what looks like an excellent way of hooking up Gatsby and WP!
But. I'm seeing an error after updating npm.
Steps to reproduce:
gatsby new concinity2 https://github.com/GatsbyCentral/gatsby-starter-wordpress
cd concinnity2
Minimal edits to gatsby-config.js:
module.exports = {
siteMetadata: {
title: 'Concinnity website',
},
plugins: [
'gatsby-plugin-react-helmet',
'gatsby-plugin-sass',
{
resolve: 'gatsby-source-wordpress',
options: {
// The base url to your WP site.
baseUrl: 'concinnity-wp.test',
// WP.com sites set to true, WP.org set to false
hostingWPCOM: false,
// The protocol. This can be http or https.
protocol: 'https',
// Use 'Advanced Custom Fields' Wordpress plugin
useACF: false,
auth: {},
// Set to true to debug endpoints on 'gatsby build'
verboseOutput: true,
},
},
'gatsby-plugin-sharp',
'gatsby-transformer-sharp',
'gatsby-plugin-purgecss',
'gatsby-plugin-netlify', // make sure to keep it last in the array
],
}
Edit gatsby-node.js to work with local cert for wordpress. Nothing else is changed:
const _ = require('lodash')
const path = require('path')
const { createFilePath } = require('gatsby-source-filesystem')
const { paginate } = require('gatsby-awesome-pagination')
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
const getOnlyPublished = edges =>
_.filter(edges, ({ node }) => node.status === 'publish')
...
-> % gatsby develop
success open and validate gatsby-config — 0.008 s
success load plugins — 0.205 s
success onPreInit — 0.780 s
success delete html and css files from previous builds — 0.005 s
success initialize cache — 0.006 s
success copy gatsby files — 0.033 s
success onPreBootstrap — 0.003 s
⠁
=START PLUGIN=====================================
Site URL: https://concinnity-wp.test
Site hosted on Wordpress.com: false
Using ACF: false
Auth: false
Verbose output: true
Mama Route URL: https://concinnity-wp.test/wp-json
(node:19464) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
⠄ source and transform nodesRoute discovered : /
Excluded route: blacklisted
Route discovered : /oembed/1.0
Excluded route: blacklisted
Route discovered : /oembed/1.0/embed
Excluded route: blacklisted
Route discovered : /oembed/1.0/proxy
Excluded route: blacklisted
Route discovered : /wp/v2
Valid route found. Will try to fetch.
Route discovered : /wp/v2/posts
Valid route found. Will try to fetch.
Route discovered : /wp/v2/posts/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/posts/(?P<parent>[\d]+)/revisions
Invalid route: detail route
Route discovered : /wp/v2/posts/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/posts/(?P<id>[\d]+)/autosaves
Invalid route: detail route
Route discovered : /wp/v2/posts/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/pages
Valid route found. Will try to fetch.
Route discovered : /wp/v2/pages/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/pages/(?P<parent>[\d]+)/revisions
Invalid route: detail route
Route discovered : /wp/v2/pages/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/pages/(?P<id>[\d]+)/autosaves
Invalid route: detail route
Route discovered : /wp/v2/pages/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/media
Valid route found. Will try to fetch.
Route discovered : /wp/v2/media/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/blocks
Valid route found. Will try to fetch.
Route discovered : /wp/v2/blocks/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/blocks/(?P<id>[\d]+)/autosaves
Invalid route: detail route
Route discovered : /wp/v2/blocks/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/types
Valid route found. Will try to fetch.
Route discovered : /wp/v2/types/(?P<type>[\w-]+)
Invalid route: detail route
Route discovered : /wp/v2/statuses
Valid route found. Will try to fetch.
Route discovered : /wp/v2/statuses/(?P<status>[\w-]+)
Invalid route: detail route
Route discovered : /wp/v2/taxonomies
Valid route found. Will try to fetch.
Route discovered : /wp/v2/taxonomies/(?P<taxonomy>[\w-]+)
Invalid route: detail route
Route discovered : /wp/v2/categories
Valid route found. Will try to fetch.
Route discovered : /wp/v2/categories/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/tags
Valid route found. Will try to fetch.
Route discovered : /wp/v2/tags/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/users
Valid route found. Will try to fetch.
Route discovered : /wp/v2/users/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/users/me
Valid route found. Will try to fetch.
Route discovered : /wp/v2/comments
Valid route found. Will try to fetch.
Route discovered : /wp/v2/comments/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/search
Valid route found. Will try to fetch.
Route discovered : /wp/v2/block-renderer/(?P<name>core/block)
Invalid route: detail route
Route discovered : /wp/v2/block-renderer/(?P<name>core/latest-comments)
Invalid route: detail route
Route discovered : /wp/v2/block-renderer/(?P<name>core/archives)
Invalid route: detail route
Route discovered : /wp/v2/block-renderer/(?P<name>core/categories)
Invalid route: detail route
Route discovered : /wp/v2/block-renderer/(?P<name>core/latest-posts)
Invalid route: detail route
Route discovered : /wp/v2/block-renderer/(?P<name>core/shortcode)
Invalid route: detail route
Route discovered : /wp/v2/settings
Valid route found. Will try to fetch.
Route discovered : /wp/v2/themes
Valid route found. Will try to fetch.
Fetching the JSON data from 16 valid API Routes...
=== [ Fetching wordpress__wp_v2 ] === https://concinnity-wp.test/wp-json/wp/v2
⡀ source and transform nodes -> wordpress__wp_v2 fetched : 1
Fetching the wordpress__wp_v2 took: 30.033ms
=== [ Fetching wordpress__POST ] === https://concinnity-wp.test/wp-json/wp/v2/posts
⢀ source and transform nodes -> wordpress__POST fetched : 1
Fetching the wordpress__POST took: 64.573ms
=== [ Fetching wordpress__PAGE ] === https://concinnity-wp.test/wp-json/wp/v2/pages
-> wordpress__PAGE fetched : 3
Fetching the wordpress__PAGE took: 25.155ms
=== [ Fetching wordpress__wp_media ] === https://concinnity-wp.test/wp-json/wp/v2/media
⠠ source and transform nodes -> wordpress__wp_media fetched : 1
Fetching the wordpress__wp_media took: 21.134ms
=== [ Fetching wordpress__wp_blocks ] === https://concinnity-wp.test/wp-json/wp/v2/blocks
-> wordpress__wp_blocks fetched : 0
Fetching the wordpress__wp_blocks took: 16.688ms
=== [ Fetching wordpress__wp_types ] === https://concinnity-wp.test/wp-json/wp/v2/types
-> wordpress__wp_types fetched : 1
Fetching the wordpress__wp_types took: 13.903ms
=== [ Fetching wordpress__wp_statuses ] === https://concinnity-wp.test/wp-json/wp/v2/statuses
-> wordpress__wp_statuses fetched : 1
Fetching the wordpress__wp_statuses took: 13.006ms
=== [ Fetching wordpress__wp_taxonomies ] === https://concinnity-wp.test/wp-json/wp/v2/taxonomies
⠐ source and transform nodes -> wordpress__wp_taxonomies fetched : 1
Fetching the wordpress__wp_taxonomies took: 14.620ms
=== [ Fetching wordpress__CATEGORY ] === https://concinnity-wp.test/wp-json/wp/v2/categories
-> wordpress__CATEGORY fetched : 1
Fetching the wordpress__CATEGORY took: 16.575ms
=== [ Fetching wordpress__TAG ] === https://concinnity-wp.test/wp-json/wp/v2/tags
-> wordpress__TAG fetched : 1
Fetching the wordpress__TAG took: 14.969ms
=== [ Fetching wordpress__wp_users ] === https://concinnity-wp.test/wp-json/wp/v2/users
-> wordpress__wp_users fetched : 1
Fetching the wordpress__wp_users took: 17.675ms
=== [ Fetching wordpress__wp_me ] === https://concinnity-wp.test/wp-json/wp/v2/users/me
⠈ source and transform nodes
Path: /wp-json/wp/v2/users/me?per_page=100&page=1
The server response was "401 Unauthorized"
Inner exception message: "You are not currently logged in."
Fetching the wordpress__wp_me took: 14.095ms
=== [ Fetching wordpress__wp_comments ] === https://concinnity-wp.test/wp-json/wp/v2/comments
-> wordpress__wp_comments fetched : 1
Fetching the wordpress__wp_comments took: 17.726ms
=== [ Fetching wordpress__wp_search ] === https://concinnity-wp.test/wp-json/wp/v2/search
-> wordpress__wp_search fetched : 4
Fetching the wordpress__wp_search took: 19.711ms
=== [ Fetching wordpress__wp_settings ] === https://concinnity-wp.test/wp-json/wp/v2/settings
⠁ source and transform nodes
Path: /wp-json/wp/v2/settings?per_page=100&page=1
The server response was "401 Unauthorized"
Inner exception message: "Sorry, you are not allowed to do that."
Fetching the wordpress__wp_settings took: 17.266ms
=== [ Fetching wordpress__wp_themes ] === https://concinnity-wp.test/wp-json/wp/v2/themes
Path: /wp-json/wp/v2/themes?per_page=100&page=1
The server response was "400 Bad Request"
Inner exception message: "Missing parameter(s): status"
Fetching the wordpress__wp_themes took: 14.421ms
=END PLUGIN=====================================: 492.892ms
success source and transform nodes — 0.561 s
success building schema — 0.431 s
success createPages — 0.097 s
success createPagesStatefully — 0.024 s
success onPreExtractQueries — 0.003 s
success update schema — 0.247 s
success extract queries from components — 0.156 s
success run graphql queries — 0.080 s — 12/12 153.22 queries/second
success write out page data — 0.005 s
success write out redirect data — 0.001 s
success onPostBootstrap — 0.001 s
info bootstrap finished - 6.392 s
DONE Compiled successfully in 3167ms 9:13:04 AM
You can now view gatsby-starter-wordpress in the browser.
http://localhost:8000/
View GraphiQL, an in-browser IDE, to explore your site's data and schema
http://localhost:8000/___graphql
Note that the development build is not optimized.
To create a production build, use gatsby build
ℹ 「wdm」:
ℹ 「wdm」: Compiled successfully.
ℹ 「wdm」: Compiling...
Works as expected.
Now update npm.
When I now run gatsby develop
I'm seeing this:
-> % gatsby develop
success open and validate gatsby-configs — 0.008 s
success load plugins — 0.203 s
success onPreInit — 0.509 s
success delete html and css files from previous builds — 0.011 s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's not any stale
data
success initialize cache — 0.016 s
success copy gatsby files — 0.042 s
success onPreBootstrap — 0.004 s
⠁
=START PLUGIN=====================================
Site URL: https://concinnity-wp.test
Site hosted on Wordpress.com: false
Using ACF: false
Auth: false
Verbose output: true
Mama Route URL: https://concinnity-wp.test/wp-json
(node:20783) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
⠂ source and transform nodesRoute discovered : /
Excluded route: blacklisted
Route discovered : /oembed/1.0
Excluded route: blacklisted
Route discovered : /oembed/1.0/embed
Excluded route: blacklisted
Route discovered : /oembed/1.0/proxy
Excluded route: blacklisted
Route discovered : /wp/v2
Valid route found. Will try to fetch.
Route discovered : /wp/v2/posts
Valid route found. Will try to fetch.
Route discovered : /wp/v2/posts/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/posts/(?P<parent>[\d]+)/revisions
Invalid route: detail route
Route discovered : /wp/v2/posts/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/posts/(?P<id>[\d]+)/autosaves
Invalid route: detail route
Route discovered : /wp/v2/posts/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/pages
Valid route found. Will try to fetch.
Route discovered : /wp/v2/pages/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/pages/(?P<parent>[\d]+)/revisions
Invalid route: detail route
Route discovered : /wp/v2/pages/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/pages/(?P<id>[\d]+)/autosaves
Invalid route: detail route
Route discovered : /wp/v2/pages/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/media
Valid route found. Will try to fetch.
Route discovered : /wp/v2/media/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/blocks
Valid route found. Will try to fetch.
Route discovered : /wp/v2/blocks/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/blocks/(?P<id>[\d]+)/autosaves
Invalid route: detail route
Route discovered : /wp/v2/blocks/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/types
Valid route found. Will try to fetch.
Route discovered : /wp/v2/types/(?P<type>[\w-]+)
Invalid route: detail route
Route discovered : /wp/v2/statuses
Valid route found. Will try to fetch.
Route discovered : /wp/v2/statuses/(?P<status>[\w-]+)
Invalid route: detail route
Route discovered : /wp/v2/taxonomies
Valid route found. Will try to fetch.
Route discovered : /wp/v2/taxonomies/(?P<taxonomy>[\w-]+)
Invalid route: detail route
Route discovered : /wp/v2/categories
Valid route found. Will try to fetch.
Route discovered : /wp/v2/categories/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/tags
Valid route found. Will try to fetch.
Route discovered : /wp/v2/tags/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/users
Valid route found. Will try to fetch.
Route discovered : /wp/v2/users/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/users/me
Valid route found. Will try to fetch.
Route discovered : /wp/v2/comments
Valid route found. Will try to fetch.
Route discovered : /wp/v2/comments/(?P<id>[\d]+)
Invalid route: detail route
Route discovered : /wp/v2/search
Valid route found. Will try to fetch.
Route discovered : /wp/v2/block-renderer/(?P<name>core/block)
Invalid route: detail route
Route discovered : /wp/v2/block-renderer/(?P<name>core/latest-comments)
Invalid route: detail route
Route discovered : /wp/v2/block-renderer/(?P<name>core/archives)
Invalid route: detail route
Route discovered : /wp/v2/block-renderer/(?P<name>core/categories)
Invalid route: detail route
Route discovered : /wp/v2/block-renderer/(?P<name>core/latest-posts)
Invalid route: detail route
Route discovered : /wp/v2/block-renderer/(?P<name>core/shortcode)
Invalid route: detail route
Route discovered : /wp/v2/settings
Valid route found. Will try to fetch.
Route discovered : /wp/v2/themes
Valid route found. Will try to fetch.
Fetching the JSON data from 16 valid API Routes...
=== [ Fetching wordpress__wp_v2 ] === https://concinnity-wp.test/wp-json/wp/v2
-> wordpress__wp_v2 fetched : 1
Fetching the wordpress__wp_v2 took: 28.816ms
=== [ Fetching wordpress__POST ] === https://concinnity-wp.test/wp-json/wp/v2/posts
⠄ source and transform nodes -> wordpress__POST fetched : 1
Fetching the wordpress__POST took: 31.681ms
=== [ Fetching wordpress__PAGE ] === https://concinnity-wp.test/wp-json/wp/v2/pages
-> wordpress__PAGE fetched : 3
Fetching the wordpress__PAGE took: 27.803ms
=== [ Fetching wordpress__wp_media ] === https://concinnity-wp.test/wp-json/wp/v2/media
⡀ source and transform nodes -> wordpress__wp_media fetched : 1
Fetching the wordpress__wp_media took: 23.028ms
=== [ Fetching wordpress__wp_blocks ] === https://concinnity-wp.test/wp-json/wp/v2/blocks
-> wordpress__wp_blocks fetched : 0
Fetching the wordpress__wp_blocks took: 15.476ms
=== [ Fetching wordpress__wp_types ] === https://concinnity-wp.test/wp-json/wp/v2/types
-> wordpress__wp_types fetched : 1
Fetching the wordpress__wp_types took: 15.701ms
=== [ Fetching wordpress__wp_statuses ] === https://concinnity-wp.test/wp-json/wp/v2/statuses
-> wordpress__wp_statuses fetched : 1
Fetching the wordpress__wp_statuses took: 13.511ms
=== [ Fetching wordpress__wp_taxonomies ] === https://concinnity-wp.test/wp-json/wp/v2/taxonomies
⢀ source and transform nodes -> wordpress__wp_taxonomies fetched : 1
Fetching the wordpress__wp_taxonomies took: 18.135ms
=== [ Fetching wordpress__CATEGORY ] === https://concinnity-wp.test/wp-json/wp/v2/categories
-> wordpress__CATEGORY fetched : 1
Fetching the wordpress__CATEGORY took: 15.344ms
=== [ Fetching wordpress__TAG ] === https://concinnity-wp.test/wp-json/wp/v2/tags
-> wordpress__TAG fetched : 1
Fetching the wordpress__TAG took: 18.444ms
=== [ Fetching wordpress__wp_users ] === https://concinnity-wp.test/wp-json/wp/v2/users
-> wordpress__wp_users fetched : 1
Fetching the wordpress__wp_users took: 15.030ms
=== [ Fetching wordpress__wp_me ] === https://concinnity-wp.test/wp-json/wp/v2/users/me
⠠ source and transform nodes
Path: /wp-json/wp/v2/users/me?per_page=100&page=1
The server response was "401 Unauthorized"
Inner exception message: "You are not currently logged in."
Fetching the wordpress__wp_me took: 20.644ms
=== [ Fetching wordpress__wp_comments ] === https://concinnity-wp.test/wp-json/wp/v2/comments
-> wordpress__wp_comments fetched : 1
Fetching the wordpress__wp_comments took: 16.720ms
=== [ Fetching wordpress__wp_search ] === https://concinnity-wp.test/wp-json/wp/v2/search
-> wordpress__wp_search fetched : 4
Fetching the wordpress__wp_search took: 18.948ms
=== [ Fetching wordpress__wp_settings ] === https://concinnity-wp.test/wp-json/wp/v2/settings
⠐ source and transform nodes
Path: /wp-json/wp/v2/settings?per_page=100&page=1
The server response was "401 Unauthorized"
Inner exception message: "Sorry, you are not allowed to do that."
Fetching the wordpress__wp_settings took: 14.462ms
=== [ Fetching wordpress__wp_themes ] === https://concinnity-wp.test/wp-json/wp/v2/themes
Path: /wp-json/wp/v2/themes?per_page=100&page=1
The server response was "400 Bad Request"
Inner exception message: "Missing parameter(s): status"
Fetching the wordpress__wp_themes took: 16.505ms
=END PLUGIN=====================================: 377.376ms
success source and transform nodes — 0.455 s
success building schema — 0.434 s
success createPages — 0.119 s
success createPagesStatefully — 0.033 s
success onPreExtractQueries — 0.003 s
success update schema — 0.294 s
error GraphQL Error Field "slug" is not defined by type wordpressPostConnectionCategoriesQueryList_2.
file: /Users/gabriel/git/concinnity2/src/templates/category.js
1 |
2 | query CategoryPage($slug: String!) {
3 | site {
4 | siteMetadata {
5 | title
6 | }
7 | }
> 8 | allWordpressPost(filter: { categories: { slug: { eq: $slug } } }) {
| ^
9 | totalCount
10 | edges {
11 | node {
12 | ...PostListFields
13 | }
14 | }
15 | }
16 | }
17 |
success extract queries from components — 0.113 s
⠁ (node:20783) DeprecationWarning: Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.
success run graphql queries — 0.018 s — 11/11 687.56 queries/second
success write out page data — 0.003 s
success write out redirect data — 0.000 s
success onPostBootstrap — 0.001 s
info bootstrap finished - 4.996 s
DONE Compiled successfully in 2976ms 9:15:31 AM
You can now view gatsby-starter-wordpress in the browser.
http://localhost:8000/
View GraphiQL, an in-browser IDE, to explore your site's data and schema
http://localhost:8000/___graphql
Note that the development build is not optimized.
To create a production build, use gatsby build
ℹ 「wdm」:
ℹ 「wdm」: Compiled successfully.
I'm lost! Visiting localhost:8000 renders the following:
Failed to compile
GraphQL Error Field "slug" is not defined by type wordpressPostConnectionCategoriesQueryList_2.
file: /Users/gabriel/git/concinnity2/src/templates/category.js
1 |
2 | query CategoryPage($slug: String!) {
3 | site {
4 | siteMetadata {
5 | title
6 | }
7 | }
> 8 | allWordpressPost(filter: { categories: { slug: { eq: $slug } } }) {
| ^
9 | totalCount
10 | edges {
11 | node {
12 | ...PostListFields
13 | }
14 | }
15 | }
16 | }
17 |
This error occurred during the build time and cannot be dismissed.
For now I can continue working with a non-updated repo, but this will be annoying in the long run and I have no clue to what's wrong. Any ideas?