Wp-graphql-woocommerce: Internal server error when query customer meta data

Created on 13 Jan 2021  路  6Comments  路  Source: wp-graphql/wp-graphql-woocommerce

Describe the bug
I'm trying to create an Woocommerce account page with React. I'm using a Woocommerce plugin to add extra fields to the billing and shipping form and it saves the fields into meta data.

I've found a bug when trying to query the meta data of a customer.

To Reproduce
Steps to reproduce the behavior:

  1. Try this query in GraphiQ:
query MyQuery {
  customers {
    edges {
      node {
        metaData {
          key
          value
        }
      }
    }
  }
}
  1. It will return an Internal server error

"errors": [ { "message": "Internal server error", "extensions": { "category": "internal" }, "locations": [ { "line": 7, "column": 11 } ], "path": [ "customers", "edges", 1, "node", "metaData", 1, "value" ],

Expected behavior
The query should return customer's meta data.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
I'm using:

  • WP GraphQL - v 1.0.0
  • WPGraphQL WooCommerce (WooGraphQL) - v 0.7.0
bug

Most helpful comment

@aresrioja10 You're issues related to the Customer meta should be resolved with both #430 and @believelody's #402

@pandabrand We're discussing your issue in the Slack and it appears to be an misunderstand of permission surrounding the root-level orders() query.

@mohaimenmahi Sounds like you may have stumble upon a new bug. Please open a new issue with the query you are attempting to run and any screenshots you can share of your GraphQL client.

All 6 comments

I've found that the internal error occurs when trying to query the meta data of the admin user.

I am getting "internal server error" when I am trying to fetch customer data with customer's orders/lastOrder. If I remove the orders from the query everything works fine. But I need the orders getting fetched by the customer query.

I am also getting an error trying to retrieve an Order, specifically:
Call to undefined method Automattic\WooCommerce\Admin\Overrides\Order::is_private()

_ok, for me this was an issue about calling the wrong Order class. I'm having an different issue which I'll take up else where._

totally, lying still getting this, its from trying to pass an Order back from a custom mutation, I think I'm not creating the right Order class.

@aresrioja10 You're issues related to the Customer meta should be resolved with both #430 and @believelody's #402

@pandabrand We're discussing your issue in the Slack and it appears to be an misunderstand of permission surrounding the root-level orders() query.

@mohaimenmahi Sounds like you may have stumble upon a new bug. Please open a new issue with the query you are attempting to run and any screenshots you can share of your GraphQL client.

I'm not having an error. but After the update, the metadata update is not working on the customer:

mutation MyMutation {
  updateCustomer(input: {billing: {state: "NJ"}, metaData: {key: "test_key", value: "value test"}}) {
    customer {
      email
      lastName
      metaData {
        key
        value
        id
      }
    }
  }
}

Mutation Response

{
            "key": "test_key",
            "value": "value test",
            "id": null
          }

Notice the id is null after performing the mutation.

After using the query to fetch current customer the new metaData is not present.

Tested on

WPGraphQL WooCommerce (WooGraphQL): Version 0.8.1
WP GraphQL: Version 1.3.9
WP: Version 5.7.2

** UPDATE****

After I pass the customer id on the mutation, the metaData gets save correctly..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jake-101 picture jake-101  路  7Comments

hwsiew picture hwsiew  路  6Comments

craigwilcox picture craigwilcox  路  4Comments

ricokahler picture ricokahler  路  5Comments

paplco picture paplco  路  4Comments