fix: error when querying post_object, relationship or page_link field nested on a repeater or flexible_content field #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this implement/fix? Explain your changes.
This fixes the field definition and resolver logic for
PageLink,PostObjectandRelationshipfields 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_objectandrelationshipfield 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.
NOTE: Unfortunately the
relationship,post_objectandpage_linkfields 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#2491Does this close any currently open issues?
closes #115
Any relevant logs, error output, GraphiQL screenshots, etc?
Before:
After:
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)