Skip to content
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

CorePostTerms doesn't expose any way to ask for the terms #180

Open
jasonbahl opened this issue Jan 24, 2024 · 9 comments
Open

CorePostTerms doesn't expose any way to ask for the terms #180

jasonbahl opened this issue Jan 24, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@jasonbahl
Copy link
Contributor

When querying Blocks, if a block is of the CorePostTerms block type, there's no way on the block to fetch the terms.

In the Block Editor I can see the terms:

CleanShot 2024-01-24 at 15 55 40

However when querying for blocks, I cannot find any field in the Schema that would allow me to fetch these terms and make use of them.

I would like to be able to query the terms as a connection.

Something to the tune of:

query WysiwygField($uri: String! = "my-uri") {
  nodeByUri(uri: $uri) {
    id
    uri
    ...on NodeWithEditorBlocks {
      editorBlocks {
        __typename
        ...on CorePostTerms {
          ## There's no way to query the terms here 🤔
          terms { ## Would be great to be able to query like this
            nodes {
              __typename
               id
               name
            }
          }
        }
      }
    }
  }
}
@jasonbahl jasonbahl added the enhancement New feature or request label Jan 24, 2024
@theodesp
Copy link
Member

Hey @jasonbahl is CorePostTerms a Block type or we have to create an artificial type there?

@jasonbahl
Copy link
Contributor Author

@theodesp it's a core block.

You can use it to add terms from a connected taxonomy to the post, but you cannot query those terms as nodes in the graph from the block

@justlevine
Copy link
Contributor

justlevine commented Jan 25, 2024

@jasonbahl afaik no query blocks are currently supported by this plugin. and @theodesp I'd be wary of creating an Artificial type to support it without planning for forward compatibility with the Block Bindings API that we'll hopefully start seeing the impacts of in WP 6.5 (and when completed should provide the missing pieces we need for FSE).

Without that piece, the part to overcome is setting the state for a Query's children in a performant way and without polluting the global context.

@jasonbahl
Copy link
Contributor Author

This is maybe something that should exist in plugin / custom code territory for the moment then 🤔 🤷🏻‍♂️

Right now, the only way to get the terms from the block is by using renderedHtml, but if I want the term nodes as data so my client component can decide how the markup should be output, I cannot do that currently.

I feel like this block has limited utility as-is 🤷🏻‍♂️

But also understand any hesitation to make a decision to support something like a Block->TermNode connection

@theodesp
Copy link
Member

theodesp commented Jan 25, 2024

@jasonbahl is there a way to use the Selector API to define an array attribute for this?

With this PR we support array types

So it works similar with CoreTable block

We could include an extension of this by adding a CorePostTerms block in this list here:

https://github.com/wpengine/wp-graphql-content-blocks/tree/main/includes/Blocks

@jasonbahl
Copy link
Contributor Author

@theodesp not sure, haven't looked into it yet.

Just was trying to use the block and determined it was essentially useless for me at the moment so wanted to open an issue to discuss. I imagine anyone else using blocks in a headless environment might find this block difficult to use as-is. 🤷🏻‍♂️

For the moment, I'm using an ACF Block and an ACF Field on the block to solve my current need of being able to query a list of terms from a block.

@justlevine
Copy link
Contributor

justlevine commented Jan 25, 2024

I imagine anyone else using blocks in a headless environment might find this block difficult to use as-is. 🤷🏻‍♂️

💯
To add for those stumbling across this ticket: none of the "dynamic"* core blocks currently serve any purpose beyond acting as a flag to load a custom Frontend component or to parse their rendered HTML (depending on the block).

  • meaning core blocks that are bound to a WP reference, Gutenberg has a naming problem.

@jasonbahl
Copy link
Contributor Author

Gutenberg has a naming problem

"the block editor" 🤣

@theodesp
Copy link
Member

theodesp commented Feb 2, 2024

@jasonbahl do you think we can include an additional field to resolve the Post Terms similar to the CoreImage block?

https://github.com/wpengine/wp-graphql-content-blocks/blob/main/includes/Blocks/CoreImage.php#L49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants