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

Internal server error when querying orders #718

Open
wildcant opened this issue Mar 20, 2023 · 1 comment
Open

Internal server error when querying orders #718

wildcant opened this issue Mar 20, 2023 · 1 comment
Labels
awaiting author response Awaiting response from Issue/PR author

Comments

@wildcant
Copy link

wildcant commented Mar 20, 2023

Describe the bug
Hi guys, thanks for all the work you have done here. I'm just starting to use this plugin for a new project and I'm getting Internal server error as response to simple orders query.

To Reproduce
Start a wordpress instance using docker with the command docker compose up -d. This is the docker-compose.yml:

version: '3'

services:
  # Database
  db:
    platform: linux/x86_64
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    networks:
      - wpsite

  # Wordpress
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - '8001:80'
    restart: always
    volumes: ['./src:/var/www/html']
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
    networks:
      - wpsite

networks:
  wpsite:
volumes:
  db_data:

After docker container starts visit http://localhost:8001/ and initialize wordpress. Install most recent version of plugins (see plugins versions section), initialize commerce, add products (I used the sample data from wp-content/plugins/woocommerce/sample-data/sample_products.csv) and a payment method (I used de default Cash on delivery), make an order, try to query to retrieve said order, see error. Is this a regression or maybe I'm missing a configuration step?

This is the internal server error with orders I'm not able to retrieve a single order neither

Screenshot 2023-03-20 at 4 27 56 PM

Screenshot 2023-03-20 at 4 24 40 PM

Expected behavior
queries should return the orders data similar to rest api
Screenshot 2023-03-20 at 4 12 08 PM

Plugin Versions
WordPress 6.1.1
Screenshot 2023-03-20 at 4 01 45 PM

@kidunot89
Copy link
Member

@wildcant the orders query is restricted to admin/users with shop manager caps only for security measures. The recommend way to retrieve user orders is by using the orders connection under the Customer type using the customer query.

query {
  customer {
    orders {
      nodes {
        id
      }
    }
  }
}

Note: By not providing params to the customer you tell WooGraphQL to return the Customer data for the current session user. To learn more handling the user session see this

@kidunot89 kidunot89 added the awaiting author response Awaiting response from Issue/PR author label May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting author response Awaiting response from Issue/PR author
Projects
None yet
Development

No branches or pull requests

2 participants