Download the PHP package thefold/graphql-wp without Composer
On this page you can find all versions of the php package thefold/graphql-wp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thefold/graphql-wp
More information about thefold/graphql-wp
Files in thefold/graphql-wp
Package graphql-wp
Short Description A GraphQL endpoint for WordPress
License GPL-2.0-or-later
Informations about the package graphql-wp
graphql-wp
A GraphQL endpoint for WordPress that's easy to customize.
This is a WordPress Plugin that exposes a GraphQL endpoint at /graphql.
Uses this excellent graphql-php library.
Supports Relay Connections.
Install
composer require mohiohio/graphql-wp
If your aren't familiar with using composer with WordPress I'd recommend using a setup like bedrock. Otherwise you will at the least need to require autoload.php for this to work.
Using
The best way to explore / develop with this is by visiting /graphiql
after installation. This will show you the endpoints and arguments that are available. Note this will only work if you are a logged in admin user.
wp_query
This is designed to follow WordPress' existing WP Query functions. So as a rule you can pass the same parameters as your can to WP Query*.
*_In reality there are a lot of params you can pass to WP_Query, and I've only implemented the ones that I've needed so far. But adding more is trivial as the arguments are just passed directly to the getposts function, so its just a matter of defining them in the schema.
Will give you
Post
And of course you can get an individual post
Custom Fields
Any meta fields are available like so
If you want to define your own resolver / type you can extend the field schema for a post type like so.
Custom Post Types
This is how you can add custom post types ( which have custom fields ) to a client specific plugin.
graphql-wp/get_post_types is a good hook for this.
Where $types
is a hash of the schema we are working with, so just add new items into this and you are good to go.
In the wild
All versions of graphql-wp with dependencies
mohiohio/wordpress-lib Version 0.1.5
webonyx/graphql-php Version 0.13.8
ivome/graphql-relay-php Version 0.5.0
danielstjules/stringy Version 2.4.0
rbdwllr/reallysimplejwt Version 3.0.2
ramsey/uuid Version 4.0.1