Problem
You installed WPGraphQL but realized you don´t get all the data you need. Or you don´t get your data at all.
Analysis
You read the documentation and find out that you can only query WordPress defaults (e.g. post types).
You check and try all the available plugins. But none of the allowed you to get the custom data you have saved into your WordPress installation.
So you read the documentation and decided to implement an extension.
Steps
- Create a folder my-extension in wp-content/plugins
- Create a file my-extension.php in wp-content/plugins/my-extension
- Add the minimum for it to be accepted as wordpress plugin
- Activate the plugin
Create a folder my-extension in wp-content/plugins
This is quite self explaining. A WPGraphQL is similar to a WordPress plugin. Therefore you need to create a folder in the wp-content/plugins folder.
For the sake of this example we use my-extension. So wp-content/plugins/my-extension should exist now.
Create a file my-extension.php in wp-content/plugins/my-extension
This is also self explaining. Inside the folder content/plugins/my-extension, create a file my-extension.php.
Add the minimum for it to be accepted as wordpress plugin
For WordPress to accept a plugin and make it useable it needs to have a bare minimum.
Add the following to the
<?php
/**
Plugin Name: My First WPGraphQL Extension
*/
This is all that´s required to make it a plugin and extension for WPGraphlQL
It doesn´t do anything yet, but you can activate it like any regular plugin in WordPress now.
Activate the plugin
To activate your plugin, go to the Installed Plugins view of WordPress.
You should see your plugin, but it is deactivated.
Just click on Activate and boom, it´s running.
This article stops here, but another one will follow to make the plugin do something useful.
Let me know if it helped you.
Best,
Frank
Sources
https://www.wpgraphql.com/docs/build-your-first-wpgraphql-extension/