Skip to content

Error when querying products that are ACF relationship field itemsย #253

Closed
@jholman101

Description

@jholman101

The relationship field in ACF establishes connections to other Post Types. Product is a Post Type, but WooGraphQL resolves Products differently than WPGraphQL resolves any other type of Post Type, so fields like this that expect a Post model to be returned don't get a Post model returned, but instead a Product.

To Reproduce

  1. Have wp-graphql, wp-graphql-woocommerce, wp-graphql-acf and wp-graphiql installed.

  2. Add an ACF Field group to posts, example field group export below:
    [ { "key": "group_5e85643c0cc84", "title": "Testing Product Relationship issue", "fields": [ { "key": "field_5e85644be0a13", "label": "Post Products", "name": "post_products", "type": "relationship", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "show_in_graphql": 1, "post_type": [ "product" ], "taxonomy": "", "filters": [ "search", "post_type", "taxonomy" ], "elements": "", "min": "", "max": "", "return_format": "object" } ], "location": [ [ { "param": "post_type", "operator": "==", "value": "post" } ] ], "menu_order": 0, "position": "normal", "style": "default", "label_placement": "top", "instruction_placement": "label", "hide_on_screen": "", "active": true, "description": "", "show_in_graphql": 1, "graphql_field_name": "TestingProductRelationshipIssue" } ]

  3. Run query in wp-graphiql. Sample query below:
    query SampleQuery { __typename posts(first: 10) { edges { node { title TestingProductRelationshipIssue { postProducts { ... on SimpleProduct { id name sku } } } } } } }

Expected behavior
Should return results without errors

Screenshots
https://slack-files.com/T3PDM1KRC-F0118V1GM0D-eab1d0676d

Additional context
Slack message thread about the issue:
https://wp-graphql.slack.com/archives/CCYJRDN4A/p1585794638031200

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions