Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query products by status not working properly #624

Closed
victormattosvm opened this issue May 18, 2022 · 0 comments · Fixed by #651
Closed

Query products by status not working properly #624

victormattosvm opened this issue May 18, 2022 · 0 comments · Fixed by #651
Labels
bug Something isn't working
Milestone

Comments

@victormattosvm
Copy link
Contributor

victormattosvm commented May 18, 2022

Describe the bug
When trying to query products by status (draft, trash...), I'm only receiving products that I'm the author of. Considering I'm testing as an admin, all products with this status should be returned. I'm using the last versions of wpgraphql and wpgraphql-woo

To Reproduce
Steps to reproduce the behavior:

  1. Logged as admin, go to GraphQL IDE
  2. Put the code below
query GetProducts {
  products(where: {status: "DRAFT"}) {
    nodes {
      databaseId
      status
    }
  }
}

Expected behavior
It will only return the products that you're author of.

Possible solution
I studied the code and found an incompatibility between wp-graphql and wp-graphql-woocommerce. Product and all Woocommerce post types have the 'skip_graphql_type_registry' option. This way, all Woocommerce post types are being ignored and are seen as "private" instead of "public" on this line

What I made to fix it: used this filter to return false. That way the code will follow the native flow and check whether or not the user is able to see.

@kidunot89 kidunot89 added the bug Something isn't working label Aug 25, 2022
@kidunot89 kidunot89 added this to the v0.11.2 milestone Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants