menu
announcement

Spectrum is now read-only. Learn more about the decision in our official announcement.

Gatsby

Fast in every way that matters. Gatsby is a free and open source framework based on React that helps developers build blazing fast websites and apps.

Channels
Team

Help with `createSchemaCustomization` for WordPress media details

November 8, 2019 at 1:57pm

Help with `createSchemaCustomization` for WordPress media details

November 8, 2019 at 1:57pm (Edited 2 years ago)
I have a number of fields WordPress returns back where the data type differs each time. I need to set the correct types using (https://www.gatsbyjs.org/docs/actions/#createTypes), but I can't figure out how to do it.
Some examples below of invalid fields are below:
wordpress__wp_media.media_details.image_meta.aperture:
- type: number
value: 0
- type: string
value: '0'
wordpress__wp_media.media_details.image_meta.created_timestamp:
- type: number
value: 0
- type: string
value: '0'
I've tried:
exports.createSchemaCustomization = ({ actions, schema }) => {
const { createTypes } = actions;
const typeDefs = [
schema.buildObjectType({
name: 'wordpress__wp_mediaMedia_detailsImage_meta',
fields: {
apperture: 'Int',
},
interfaces: ['Node'],
extensions: {
infer: false,
}
}),
];
createTypes(typeDefs);
}
And:
exports.createSchemaCustomization = ({ actions, schema }) => {
const { createTypes } = actions;
const typeDefs = [
schema.buildObjectType({
name: 'wordpress__wp_media',
fields: {
media_details: {
image_meta: {
apperture: 'Int',
}
}
},
interfaces: ['Node'],
extensions: {
infer: false,
}
}),
];
createTypes(typeDefs);
}
Anyone able to help me with this?

November 12, 2019 at 10:49am

July 6, 2021 at 9:08pm
(crgeary) not sure if this would fix it but I noticed you have a spelling error 'aperture'

July 21, 2021 at 3:45pm
NVM, I tested it out with spelling correction and it didn't work.
I have tried so many things.
Anyone have any luck just deleting image_meta?
Tried to change image_meta to null, String, something other than an node object. I wish there was some good examples of deleteNode(node). I have not been able to get it to work.
(sidhartha) Any suggestions?