Coder Social home page Coder Social logo

Comments (20)

pablo-tapia avatar pablo-tapia commented on June 17, 2024 2

Hello!

I'm using WPGraphQL 1.0.1, WPGraphQL for Advanced Custom Fields 0.3.4, and WooGraphQL 0.7.0 and it seems this still an issue. I have an ACF Block with a Relationship field that takes Products only and it always returns the message: value \" instance of WPGraphQL\\Model\\Post\", received \"Product\". Either type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function.",.

Anyone has been able to make it work?

from wp-graphql-acf.

jasonbahl avatar jasonbahl commented on June 17, 2024 1

@Nessario I believe @kidunot89 released a new version of WPGraphQL for WooCommerce to play nice with WPGraphQL for ACF v0.3.0. . .perhaps it's a version mis-match issue?

What version of WPGraphQL, WPGraphQL for ACF and WPGraphQL for WooCommerce are you on?

from wp-graphql-acf.

jasonbahl avatar jasonbahl commented on June 17, 2024

@tkorsback hey, how are you registering these relationships? Using a plugin like Posts 2 Posts or something?

from wp-graphql-acf.

tkorsback avatar tkorsback commented on June 17, 2024

@jasonbahl Yeah I use Posts 2 Posts for a few CPT relations and that works. The relation that doesn't work it a regular "post_object" relation with no other relation sharing it's name.

from wp-graphql-acf.

jasonbahl avatar jasonbahl commented on June 17, 2024

Ya, to my knowledge, nobody has written any plugin that converts Post 2 Post relationships to the GraphQL Schema.

I think it would be a super valuable plugin though! But there's for sure work that would need to be done to use the Post 2 Post registry and map it to the WPGraphQL Schema.

from wp-graphql-acf.

tkorsback avatar tkorsback commented on June 17, 2024

@jasonbahl But the Posts 2 Posts relations work and shows up in GraphiQL. It's the acf relation to WooCommerce that doesn't show.

from wp-graphql-acf.

jasonbahl avatar jasonbahl commented on June 17, 2024

πŸ€”I thought your issue above was a snippet of your posts 2 posts registry, and you're asking why it's not working?

I guess I'm not sure what you're asking then.

from wp-graphql-acf.

jasonbahl avatar jasonbahl commented on June 17, 2024

Maybe provide more code snippets and screenshots of GraphiQL or something so I can understand better what you're after.

from wp-graphql-acf.

tkorsback avatar tkorsback commented on June 17, 2024

Sure!

CPT: Membership
ACF relation to CPT Company (working):

[
    'key' => 'field_membership_company_relationship',
    'name' => 'company_membership',
    'label' => __('Company', 'tp-cpt'),
    'type' => 'post_object',
    'post_type' => [
        'tp_company'
    ],
    'show_in_graphql' => true,
]

ACF relation to WooCommerce product (not working)

[
    'key' => 'field_membership_product_relationship',
    'name' => 'product_membership',
    'label' => __('Product', 'tp-cpt'),
    'type' => 'post_object',
    'post_type' => [
        'product'
    ],
    'show_in_graphql' => true,
]

GraphiQL: Expanding Place nodes and then MembershipRelations I only see the Company relation, not the Product relation.

from wp-graphql-acf.

jasonbahl avatar jasonbahl commented on June 17, 2024

Ahhh!

I thought this was Posts 2 Posts code, not ACF code πŸ€¦β€β™‚

Sorry for that confusion!

Yes, this is a known issue right now, because the WPGraphQL for WooCommerce registers the Product post type manually, instead of making use of registering it from the post type registry, so ACF doesn't know that Product is a post type registered to the GraphQL Schema.

@kidunot89 opened a PR over the weekend to address this.

I'm reviewing today and hopefully we can have this resolved here soon.

Sorry again for the confusion πŸ€¦β€β™‚

from wp-graphql-acf.

tkorsback avatar tkorsback commented on June 17, 2024

No worries πŸ™

Ah ok, I understand. Nice work! πŸ‘

from wp-graphql-acf.

Nessario avatar Nessario commented on June 17, 2024

I'm experiencing the same issue here, though by upgrading into the v0.4.0 the fields now show up in GraphiQL. But, those won't return any result πŸ€”

from wp-graphql-acf.

jasonbahl avatar jasonbahl commented on June 17, 2024

@Nessario can you provide more specific details about your scenario so I can replicate and debug?

from wp-graphql-acf.

Nessario avatar Nessario commented on June 17, 2024

@jasonbahl Yeah sure, below is a screenshot of the query.

data

Tested these same fields with other post types, they work fine.

from wp-graphql-acf.

Nessario avatar Nessario commented on June 17, 2024

@jasonbahl I just upgraded to the latest versions of all the mentioned plugins. Now, I'm noticing even the custom taxonomies, registered via CPT UI are missing (WPGraphQL CPT UI is also up to date). I'm experiencing this issue only with the Products post type of Woocommerce, the other post types work perfectly.

from wp-graphql-acf.

zamson avatar zamson commented on June 17, 2024

@kidunot89 did you ever get relationship field to work? I'm getting an internal server error notice when trying to query for ACF relationship fields with post type product. Pages and posts works fine but not WooCommerce products.

https://share.getcloudapp.com/xQugZEXB

I'm on version 0.4.4 of wp-graphql-woocommerce and 0.6.1 of wp-graphql

from wp-graphql-acf.

joshuaiz avatar joshuaiz commented on June 17, 2024

Seeing this same issue. I have a CPT 'Artists' registered via custom plugin and have ACF Relationship field 'Release' that I use to choose what WooCommerce product the Artist is associated with.

(The CPT is artists and the ACF Field Group is also artists).

In GraphiQL, the fields show up but nothing is returned and it generates an error:

Query:

{
  artists { // CPT
    nodes {
      artists { // ACF Field Group
        release {
          ... on SimpleProduct {
            id
            name
          }
        }
      }
    }
  }
}

Result:

"errors": [
    {
      "message": "Internal server error",
      "category": "internal",
      "locations": [
        {
          "line": 5,
          "column": 9
        }
      ],
      "path": [
        "artists",
        "nodes",
        0,
        "artists",
        "release",
        0
      ]
    },
//...

I'll probably end up just using a Select field with all the releases in a drop-down as a workaround since I only really need the slug for the time being but it would be great if this worked.

from wp-graphql-acf.

jasonbahl avatar jasonbahl commented on June 17, 2024

πŸ‘‹πŸ» WPGraphQL for ACF has been re-built over here: https://github.com/wp-graphql/wpgraphql-acf and it has significant improvements to loading data.

I'd be curious to here if anyone that's using WooCommerce + ACF + WPGraphQL has had a chance to use the new version of WPGraphQL for ACF and what your experience has been.

I'm inclined to believe a lot of things are working better, but there's definitely likely edge cases when all the various plugins collide.

from wp-graphql-acf.

Nessario avatar Nessario commented on June 17, 2024

@jasonbahl I've been working on a project with the latest WPGraphQL stack (ACF & WooGraphQL included) and it's been working pretty good so far πŸ‘ŒπŸΌπŸ€žπŸΌ

Thanks for all the work you and the others have put into this πŸ™ŒπŸΌ

from wp-graphql-acf.

jasonbahl avatar jasonbahl commented on June 17, 2024

Based on how old this is and the report above that the latest WPGraphQL for ACF + WooCommerce + WooGraphQL are working together, I'm going to close this.

This repo will be archived in the not-too-distant future in favor of the re-architected version of the plugin: https://github.com/wp-graphql/wpgraphql-acf, so if you have any new issues after updating to the latest WPGraphQL for ACF, please report over there πŸ™πŸ»

from wp-graphql-acf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.