Skip to content

Conversation

@jasonbahl
Copy link
Contributor

@jasonbahl jasonbahl commented Nov 6, 2023

What does this implement/fix? Explain your changes.

This fixes the field definition and resolver logic for PageLink, PostObject and Relationship fields to better handle resolving when nested in a repeater or flex field. Also better handle different return formats (ID vs Object)

NEW This ALSO adds a new GraphQL Setting for page_link, post_object and relationship field types to be able to select their connection type in the Schema.

Instead of defaulting to a plural one-to-many connection, the connection can be changed to be a one-to-one connection.

CleanShot 2023-11-14 at 15 36 10

NOTE: Unfortunately the relationship, post_object and page_link fields will not resolve archive urls. This is a bug we will be tracking but don't have a fix for at the moment since archive URLs aren't handled well in core WPGraphQL. see: wp-graphql/wp-graphql#2491

Does this close any currently open issues?

closes #115

Any relevant logs, error output, GraphiQL screenshots, etc?

Before:

CleanShot 2023-11-06 at 14 22 58

After:

CleanShot 2023-11-06 at 14 18 36

Any other comments?

NOTE: This is considered breaking because these 3 field types used to conditionally modify the Schema to be a OneToOneConnection or a Connection (plural) if/when the multiple ("Allow Multiple") field was selected.

This is now considered to be bad practice, as "Allow Multiple" is considered a validation rule for editors in the admin and can be changed at any time without impacting the GraphQL Schema in a breaking way.

If multiple values were allowed for the past year, then going forward the rule was changed to not allow multiple, the Schema should not be changed in a breaking way, because there would be a mix of old values with multiple selected and new values with one selected.

So, regardless of the value, the Schema will always represent these field types as a Connection (zeor, one or more items can be returned)

…ect and Relationship fields to better handle resolving when nested in a repeater or flex field. Also better handle different return formats (ID vs Object)
@jasonbahl jasonbahl self-assigned this Nov 6, 2023
@jasonbahl jasonbahl added the compat: breaking change This is a breaking change to existing functionality label Nov 6, 2023
@jasonbahl jasonbahl changed the title fix: fix: error when querying post_object field nested on a repeater Nov 6, 2023
@jasonbahl jasonbahl changed the title fix: error when querying post_object field nested on a repeater fix: error when querying post_object, relationship or page_link field nested on a repeater or flexible_content field Nov 6, 2023
@jasonbahl jasonbahl closed this Nov 6, 2023
@jasonbahl jasonbahl reopened this Nov 6, 2023
…ic (static functions in Relationship.php)

- update WPGraphQLAcfTestCase to cleanup image and file that were created during setUp
@jasonbahl jasonbahl merged commit ee482b7 into main Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compat: breaking change This is a breaking change to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post Object field type isn't resolving correctly when "Return Format" is set to "Post Object" instead of ID

2 participants