Skip to content

Updated query {} example to include the selector key#64402

Open
dan-long-dev wants to merge 1 commit intoWordPress:trunkfrom
dan-long-dev:patch-1
Open

Updated query {} example to include the selector key#64402
dan-long-dev wants to merge 1 commit intoWordPress:trunkfrom
dan-long-dev:patch-1

Conversation

@dan-long-dev
Copy link
Copy Markdown

What?

Adding the 'selector' key into the query {} source definition.

Why?

Following the example directly from the current documentation (saved content and attribute definition), the data returned is null when using GraphQL queries for block data. Adding in the selector key fixes the issue.

How?

N/A

Testing Instructions

  • Create a new block (my use case is ACF blocks).
  • Within the block, add the "Saved content:" code into the PHP file.
  • Copy the "Attribute definition:" into an 'attributes' node within the block.json file.
  • Add the block to a page.
  • Query the page using GraphQL (plugins needed WPGraphQL, WPGraphQL for ACF & WPGraphQL Content Blocks) and add in the attributes to query for the block.
  • Returned data will be null.
  • Add in the 'selector: [src]' and 'selector: [alt]' to the relevant parts of block.json.
  • Query the page again, see the returned data.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 9, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @danclong.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: danclong.


To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Aug 9, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 9, 2024

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @danclong! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@akasunil akasunil added the [Type] Developer Documentation Documentation for developers label Aug 9, 2024
@Mamaduka Mamaduka added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants