- Install & activate WooCommerce
- Install & activate WPGraphQL
- (Optional) Install & activate WPGraphQL-JWT-Authentication to add a
login
mutation that returns a JSON Web Token. - Clone or download the zip of this repository into your WordPress plugin directory & activate the WP GraphQL WooCommerce plugin
It adds WooCommerce functionality to the WPGraphQL schema using WooCommerce's CRUD objects.
- Query product, customers, coupons, order, refund, product variations.
- Adminstrator mutations. Eg. Creating and deleting products, coupons, orders and refunds
- Public/Customer mutations, Eg. Manipulating the cart and checking out. View Roadmap to see progress...
Feel free to test out the extension using the playground. The playground allows you to execute queries and mutations, as well as view the schema.
Until the documentation is in full effect, it's recommended that a GraphiQL-based tool like WPGraphiQL be used to view the GraphQL schema, an alternative to this is viewing the unit tests located in tests/wpunit
directory. Which are constantly updated along with the project. If you're interested in contributing when I begin accepting contribution or simply want to run the tests. Follow the instruction below.
-
Make sure all dependencies are install by running
composer install
from the CMD/Terminal in the project directory. -
Next the copy 5 distributed files with the
.dist
in there filenames. For instance.env.dist
becomes.env
andwpunit.suite.dist.yml
becomeswpunit.suite.yml
. The distributed files and what their copied names should are as follows.tests/acceptance.suite.dist.yml
=>tests/acceptance.suite.yml
tests/functional.suite.dist.yml
=>tests/functional.suite.yml
tests/wpunit.suite.dist.yml
=>tests/wpunit.suite.yml
codeception.dist.yml
=>codeception.yml
.env.dist
=>.env
-
Next open
.env
and alter to make you usage.# Shared TEST_DB_NAME="wpgraphql_woocommerce_test" TEST_DB_HOST="127.0.0.1" TEST_DB_USER="root" TEST_DB_PASSWORD="" # Install script WP_VERSION=latest SKIP_DB_CREATE=false WP_GRAPHQL_BRANCH=develop # Codeception WP_ROOT_FOLDER="/tmp/wordpress" TEST_SITE_WP_ADMIN_PATH="/wp-admin" TEST_SITE_DB_NAME="wpgraphql_woocommerce_test" TEST_SITE_DB_HOST="127.0.0.1" TEST_SITE_DB_USER="root" TEST_SITE_DB_PASSWORD="" TEST_SITE_TABLE_PREFIX="wp_" TEST_TABLE_PREFIX="wp_" TEST_SITE_WP_URL="http://wp.test" TEST_SITE_WP_DOMAIN="wp.test" TEST_SITE_ADMIN_EMAIL="admin@wp.test" TEST_SITE_ADMIN_USERNAME="admin" TEST_SITE_ADMIN_PASSWORD="password"
Shared
variables are as the comment implies, variables shared in both theinstall-wp-tests
script and the Codeception configuration. The variable names should tell you what they mean.Install script
variables are specified to theinstall-wp-tests
script, and most likely won't changed. I've listed their meaning below.WP_VERSION
WordPress version used for testingSKIP_DB_CREATE
Should database creation be skipped?WP_GRAPHQL_BRANCH
The branch in theWPGraphQL
repository the tests should be run again. Ex.origin/feature/model-layer
Codeception
variables are specified to the Codeception configuration. View the config files and Codeception's Docs for more info on them.
-
Once you have finish modifying the
.env
file. Runcomposer install-wp-tests
from the project directory. -
Upon success you can begin running the tests.
To run test use the command vendor/bin/codecept run [suite [test [:test-function]]]
.
If you use the command with at least a suite
specified, Codeception will run all tests, however this is not recommended. Running a suite vendor/bin/codecept run wpunit
or a test vendor/bin/codecept run CouponQueriesTest
is recommended. Running a single test-function
like vendor/bin/codecept run ProductQueriesTest:testProductsQueryAndWhereArgs
is also possible.
To learn more about the usage of Codeception with WordPress view the Documentation
If you get HTTP 500 error upon activation or accessing the endpoint
and have CMD/Terminal access with Composer installed.
- Try deleting the
vendor
directoryrm -rf vendor
and regenerating the autoloading filescomposer dumpautoload -o
in thewp-graphql-woocommerce
directory in your WordPress installation'splugins
directory. - (Alternative) You can also try delete and cloning the repository again. The latest release should have fixed the issue.
WP-GraphQL WooCommerce π KickStarter
WPGraphQL π OpenCollective
GraphQL-PHP π OpenCollective