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
I can't use a query that contains the metadata of my pages, because for the lib it is empty but when I query in the graphql IDE it returns me all the results, does it have something to do with the order of execution? how to fix this?
my config
module.exports = {
// A unique name for the search index. This should be descriptive of
// what the index contains. This is required.
name: 'pages_metadata',
// Set the search engine to create the index. This is required.
// The following engines are supported: flexsearch, lunr
engine: 'flexsearch',
// Provide options to the engine. This is optional and only recommended
// for advanced users.
//
// Note: Only the flexsearch engine supports options.
// engineOptions: 'speed',
// GraphQL query used to fetch all data for the search index. This is
// required.
query: `{
allPagesIndexable {
nodes {
path
metadata {
content
keywords
title
type
}
}
}
}`,
// Field used as the reference value for each document.
// Default: 'id'.
ref: 'path',
// List of keys to index. The values of the keys are taken from the
// normalizer function below.
// Default: all fields
index: ['title', 'keywords', 'content'],
// List of keys to store and make available in your UI. The values of
// the keys are taken from the normalizer function below.
// Default: all fields
// store: ['id', 'path', 'title'],
// Function used to map the result from the GraphQL query. This should
// return an array of items to index in the form of flat objects
// containing properties to index. The objects must contain the `ref`
// field above (default: 'id'). This is required.
normalizer: ({ data }) => {
console.log(data.allPagesIndexable) // return [Object: null prototype] { nodes: [] }
return data.allPagesIndexable.nodes.map(node => ({
path: node.path,
...node.metadata
}))
}
}
I created this separate node because I was having "metadata does not exist in context" problems when the query was executed by this lib
how i create the node:
exports.onCreateNode = ({ node, actions, createNodeId, createContentDigest }) => {
const { createNode } = actions
// Transform the new node here and create a new node or
// create a new node field
if (node.internal.type === "SitePage" && node.context && node.context.metadata) {
const page = {
path: node.path,
metadata: node.context.metadata
}
createNode({
...page,
id: createNodeId(page.path),
internal: {
type: `PagesIndexable`,
contentDigest: createContentDigest(page)
}
})
}
}
The text was updated successfully, but these errors were encountered:
I can't use a query that contains the metadata of my pages, because for the lib it is empty but when I query in the graphql IDE it returns me all the results, does it have something to do with the order of execution? how to fix this?
my config
example of result of my query in IDE:
I created this separate node because I was having "metadata does not exist in context" problems when the query was executed by this lib
how i create the node:
The text was updated successfully, but these errors were encountered: