This document will be most useful for developers that want to contribute to WPGraphQL and want to run the docker container locally as well as utilize xdebug for debugging and tracing.
In order to continue, you should follow steps to setup Docker running on your machine.
app docker image starts a running WordPress site with the local wp-graphql directory installed and activated. Local changes to the source code is immediately reflects in the app.
First step, clone the source for wp-graphql from github.
Build the plugin and dependencies:
Or if you don't have composer installed or prefer building it in a docker instance:
Build the app and testing docker images:
In one terminal window, start the WordPress app:
Use the environment variable USING_XDEBUG to start the docker image and WordPress with xdebug configured to use port 9003 to communicated with your IDE.
You should see output in the terminal like the following examples that indicate xdebug is indeed enabled and running in the app:
Start your IDE, like VSCode. Enable xdebug and set breakpoints. Load pages in your browsers and you should experience the IDE pausing the page load and showing the breakpoint.
See the testing page on running the unit test suite. These instructions show how to enable xdebug for those unit tests and allow debugging in an IDE.
Use the environment variable USING_XDEBUG to run tests with xdebug configured to use port 9003 to communicated with your IDE.
Use the environment variable SUITES to specify individual test files for quicker runs.
Create or add the following configuration to your .vscode/launch.json in the root directory. Restart VSCode. Start the debug listener before running the app or testing images.
If you have WordPress core files in a directory for local development, you can add the location to the
pathMappings for debug step through.