New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gastby-source-wordpress, ACF Flexible content, schemaCustomization issue #16809
Comments
@tol-is i don't have experience with the wordpress plugin, and i find those types with underscores and upper/lowercase wordpress/wordPress/WordPress names super confusing -- but if i understand the issue, you can create a union field linking to nodes with different content types like this (the exports.sourceNodes = ({ actions }) => {
const nodes = [
{
id: `help`,
internal: {
type: `Help`,
contentDigest: `help`,
},
contents: [`union1`, `union2`],
},
{
id: `union1`,
internal: {
type: `IntContent`,
contentDigest: `union1`,
},
int: 1,
},
{
id: `union2`,
internal: {
type: `StringContent`,
contentDigest: `union2`,
},
str: `One`,
},
]
nodes.forEach(node => actions.createNode(node))
}
exports.createSchemaCustomization = ({ actions }) => {
actions.createTypes(`
type Help implements Node @dontInfer {
contents: [Content] @link
}
type IntContent implements Node @dontInfer {
int: Int
}
type StringContent implements Node @dontInfer {
str: String
}
union Content = IntContent | StringContent
`)
} The |
thanks @stefanprobst, I really appreciate your time. My code was very close to your directions, though I didn't know about the @link directive. To be honest I don't quite understand it yet but I've tried everything I could think of and a dozen shots in the dark and i can't find my way through. The schema declaration seems to work fine for some node types, but as soon as touch the specific node that contains the content union, it's complaining. There's a lot going on under the hood in gastby-source-wordpress, so I can't really tell if what I'm trying to do needs a different approach, it's a bug or just not possible. Also updated the demo repo (just in case) |
so this is working: exports.createSchemaCustomization = ({ actions }) => {
const { createTypes } = actions
const typeDefs = `
union AcfFlexContentUnion =
WordPressAcf_typeOne
| WordPressAcf_typeTwo
| WordPressAcf_typePotato
type wordpress__wp_help implements Node {
acf: wordpress__wp_helpAcf
}
type wordpress__wp_helpAcf {
flexContent_help: [AcfFlexContentUnion] @link(from: "flexContent_help___NODE")
}
type WordPressAcf_typeOne implements Node {
flexText: String
}
type WordPressAcf_typeTwo implements Node {
flexInt: String
}
type WordPressAcf_typePotato implements Node {
flexTomato: String
}
`
createTypes(typeDefs)
} Three things to note:
|
Indeed that's working! @stefanprobst you're a legend and a hero! |
Hi, I'm trying to hook into the createSchemaCustomization and create some custom types for an some acf flexible content data. The reason is some node types will not exist at any given time. So i can't rely on the data to infer the types.
Something is not working for me and I'm not sure if I'm missing something or if this is a bug.
The query i'm trying to run
Half of it seems to be working well, meaning I can declare a node field and a type that don't exist in the cms, using the @dontInfer directive, and in graphiql I can successfully see both
The problem
As soon as I'm trying to customize the schema for the node containing the flexible content union I get an error Error: Schema must contain uniquely named types but contains multiple types named "wordpress__wp_helpAcf".
Another attempt
I also tried to customize the schema from one level up, and its not complaining anymore but now the flexContent_help value returns null.
Reproduction
I prepared a repository to reproduce the issue with all three attempts in gastby-node.js
https://github.com/tol-is/gastby-wordpress-help
The text was updated successfully, but these errors were encountered: