-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Before you submit:
- Please read the contributing guidelines
- Please search through the existing issues (both open AND closed) to see if your question has already been discussed. Github issue search can be used for this: https://github.com/imgix/gatsby/issues?utf8=%E2%9C%93&q=is%3Aissue
Question
I have added a field for image URL using Gatsby createResolvers API.
// gatsby-node.js
exports.createResolvers = ({ createResolvers }) => {
createResolvers({
Post: {
imageUrl: {
type: 'String!',
resolve(source) {
const getImageUrl = (text) => {
// The process of extracting the image URL from text
}
return getImageUrl(source.text)
},
},
},
})
}
I can retrieve the value of the field using the following query:
export const query = graphql`
{
allPost {
nodes {
text # Text containing the image URL
imageUrl # https://...
}
}
}
`
I have configured the field, but when I execute the query, an error occurs.
// gatsby-config.js
module.exports = {
//...
plugins: [
//... other plugins
{
resolve: `@imgix/gatsby`,
options: {
defaultImgixParams: { auto: ['compress', 'format'] },
fields: [
{
nodeType: 'Post',
fieldName: 'imgixImage',
rawURLKey: 'imageUrl',
},
],
},
},
],
};
Error:
Error when resolving URL value for node type Post. This probably means that the rawURLKey function in gatsby-config.js is incorrectly set. Please read this project's README for detailed instructions on how to set this correctly.
Is it possible to use customized GraphQL fields?
Metadata
Metadata
Assignees
Labels
No labels