I have a custom api endpoint that i'm accessing with gatsby-source-apiserver. I have images in my database that aren't transforming into image nodes - i.e. allowing childimagesharp
In my graphql i have this structure:
query MyQuery {
allSubmissions {
edges {
node {
works {
mediaItems {
sourceFilename
}
}
}
}
}
}
the sourceFilename is a string, like 'thisisanimage.jpg' - if i append a url onto it like "http://example.com/media" the image works fine. I'm not sure how to proceed, i've looked at createResolvers but dont fully understand how to implement it.
This is what i've tried so far - not seeming to do much (aside from getting the 'anything happening' comment in my terminal, but not the next one...
exports.createResolvers = ({
actions,
cache,
createNodeId,
createResolvers,
store,
reporter,
}) => {
const { createNode } = actions
reporter.info(anything happening?)
createResolvers({
submissions: {
works: {
mediaItems: {
type: File,
resolve(sourceFilename, args, context, info) {
reporter.info(
Resolving source: ${sourceFilename} ${args} ${context} ${info}
)
return createRemoteFileNode({
url:
"https://example.com/media/" +
sourceFilename.sourceFilename,
store,
cache,
createNode,
createNodeId,
reporter,
})
},
},
},
},
})
}
Its probably important to mention that works is an array of mediaItems, which itself is an array of fields, of which sourceFilename is one. See the attached screenshot