Currently I am trying to pull some data from a API and add to GraphQL using sourceNode and createNode APIs like that:
exports.sourceNodes = async ({ actions, createNodeId, createContentDigest }) => {
const modules = ['data', 'stuff', 'bananas'];
const modulesResponse = Promise.all(modules.map(async (module) => getModuleData(module)));
const modulesData = await modulesResponse;
const content = Object.fromEntries(modules.map((entries, index) => [entries, modulesData[index]]));
actions.createNode({
id: createNodeId(modules.join(',')),
parent: null,
children: [],
content,
internal: {
type: 'myData',
mediaType: 'text/html',
contentDigest: createContentDigest(content)
}
});
When I try to filter this (using GraphiQL) with arguments it does not appear to work:
{
myData(content: {data: {elemMatch: {filterEntry: {eq: "foo"}}}}) {
content {
data {
filterEntry
}
}
}
}
It results in this:
{
"data": {
"myData": {
"content": {
"data": [
{
"filterEntry": "foo"
},
{
"filterEntry": "bar"
},
{
"filterEntry": "baz"
}
]
}
}
}
}