You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run gatsby build/develop, everything works fine, but this plugin causes my console to throw GraphQLError: String cannot represent an array value: [] for every single node in my app, for some nodes it posts a wall of the error repeating itself. This doesn't necessarily cause any issues, as I can still use the search once the site is built, but I'd still like to get to the bottom of this if possible, in case it is the cause of another error down the line.
gatsby-config
module.exports = {
pathPrefix: `/ctc`,
siteMetadata: {
title: `Gatsby Default Starter`,
},
plugins: [
{
resolve: `@andrew-codes/gatsby-plugin-elasticlunr-search`,
options: {
// Fields to index
fields: [
'title'
],
// How to resolve each field's value for a supported node type
resolvers: {
// For any node of type MarkdownRemark, list how to resolve the fields' values
BookJson: {
title: node => node.title,
gatsby_slug: node => node.gatsby_slug,
image: node => node.image
},
AuthorJson: {
title: node => node.title,
gatsby_slug: node => node.gatsby_slug,
image: node => node.image
}
},
},
},
`gatsby-transformer-json`,
`gatsby-plugin-react-helmet`,
`gatsby-plugin-sass`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `src`,
path: `${__dirname}/src/data/final`
}
},
],
}
gatsby-node
const path = require(`path`);
const { createFilePath } = require(`gatsby-source-filesystem`)
const slugify = require('slugify')
const request = require('request-promise-native')
const crypto = require('crypto');
const fs = require('fs')
//create pages from OutputJson nodes, using id field as path
exports.createPages = ({ graphql, boundActionCreators }) => {
const { createPage } = boundActionCreators
return new Promise((resolve, reject) => {
graphql(`
{
allGenreJson {
edges {
node {
slug
gatsby_slug
id
title
type
}
}
}
allClipJson {
edges {
node {
slug
gatsby_slug
id
title
type
}
}
}
allReadingAgeJson {
edges {
node {
slug
gatsby_slug
id
title
type
}
}
}
allNarratorJson {
edges {
node {
slug
gatsby_slug
id
title
type
}
}
}
allSeriesJson {
edges {
node {
slug
gatsby_slug
id
title
type
}
}
}
allPublisherJson {
edges {
node {
slug
gatsby_slug
id
title
type
}
}
}
allAuthorJson {
edges {
node {
slug
gatsby_slug
id
title
type
}
}
}
allBookJson {
edges {
node {
slug
gatsby_slug
id
title
}
}
}
}`
).then(result => {
result.data.allBookJson.edges.forEach(({node}) => {
createPage({
path: `${node.gatsby_slug}`,
component: path.resolve('./src/templates/book.js'),
context: {
id: node.id,
type: node.type,
title: node.title
},
})
})
var apiEnds = ['Genre','Author','ReadingAge','Narrator','Series','Publisher']
apiEnds.forEach((endpoint) => {
result.data[`all${endpoint}Json`].edges.forEach(({ node}) => {
createPage({
path: `${node.gatsby_slug}`,
component: path.resolve('./src/templates/category.js'),
context: {
id: node.id,
type: node.type,
title: node.title,
},
})
})
})
resolve()
})
})
}
The text was updated successfully, but these errors were encountered:
When I run
gatsby build/develop
, everything works fine, but this plugin causes my console to throwGraphQLError: String cannot represent an array value: []
for every single node in my app, for some nodes it posts a wall of the error repeating itself. This doesn't necessarily cause any issues, as I can still use the search once the site is built, but I'd still like to get to the bottom of this if possible, in case it is the cause of another error down the line.gatsby-config
gatsby-node
The text was updated successfully, but these errors were encountered: