• Stars
    star
    637
  • Rank 70,348 (Top 2 %)
  • Language
    PHP
  • License
    GNU General Publi...
  • Created over 5 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Add WooCommerce support and functionality to your WPGraphQL server

WPGraphQL WooCommerce (WooGraphQL)

Docs β€’ AxisTaylor β€’Β Join Slack

Automated-Testing Coding-Standards Coverage Status Financial Contributors on Open Collective

Install

Installing manually

  1. Install and activate WPGraphQL and WooCommerce
  2. Download wp-graphql-woocommerce.zip file under the Assets section for the most stable release from the repository into your WordPress plugin directory & activate the plugin.
  3. Set your GraphQL client endpoint to the GraphQL endpoint of your site. Typically, this is your-store.domain/graphql.

Installing w/ Composer

This is the recommend way for users using unique installations like WP Bedrock or SpinupWP.

  1. Install WordPress and WooCommerce.
  2. Install WPGraphQL and WooGraphQL by running composer require wp-graphql/wp-graphql wp-graphql/wp-graphql-woocommerce
  3. Set your GraphQL client endpoint to the GraphQL endpoint of your site. Typically, this is your-store.domain/graphql. _NOTE: for typically Bedrock or SpinupWP setups it'll be your-store.domain/wp/graphql by default.

Optional extras

  • Install & activate WPGraphQL-JWT-Authentication to add a login mutation that returns a JSON Web Token.
  • Install & activate WPGraphQL-CORS to add an extra layer of security using HTTP CORS and some of WPGraphQL advanced functionality.

What can you do with this extension?

  • Query your shops products and variations with complex filtering options.
  • Query customers, orders, coupons, and refunds (*).
  • Manage a customer's session with JWTs and cart/customer queries and mutations(*).
  • Create orders manually (*), automatically with the checkout mutation, or pass a customer's session to the WooCommerce checkout page in your theme for complete payment gateway support (#).

(*) These operations have user restrictions. Please read up on authenticating an user with here, then view this React/Apollo example with the added on usage of customer session Token.

(#) This is the recommended method on checkout. You can read it's usage in this excellent write-up by @jacobarriola

Why don't the WooCommerce CPT GraphQL types support all the same features as most WordPress CPTs that WPGraphQL exposes?

The CPTs as well as most of the data objects that WooCommerce defines are wrapped in a object managers distributed by a data store system.

This data store system allows for each individual data object to be defined however needed. What this means is, although by out of the box objects like products, orders, and coupons are defined as WordPress CPTs they don't have to be.

This is what also enables WooCommerce to store most meta connected to these CPTs in separate tables. The object data doesn't even have to be in the same database if the object's data store designed to manage somewhere else, but we are getting out of the scope of this question.

What does all this ☝️ have to do with WooCommerce's CPTs' functionality? Well, the object managers distributed by the data store are WooGraphQL first point of contact for pretty much everything. Unlike the most common CPTs which use a WP_Post object as their data source and a WPGraphQL\Model\Post object as their model, WooGraphQL uses object managers as the data source for the CPTs and each individual has it's own model with it's own set of permissions and restrictions.

This has led to some friction is certain areas of the schema where WooGraphQL support is lacking. I'm sorry for the inconvience, myself and whole WPGraphQL org are working to reduce this friction and WooGraphQL properly integrated with all WPGraphQL + WPGraphQL ACF features.

Thank you for your patience @kidunot89

Future Features

  • Product CRUD mutations.
  • And some other stuff I'm sure :thinking_face:

Playground

Feel free to test out the extension using this GraphiQL Playground. The playground allows you to execute queries and mutations, as well as view the schema (*).

(*) I have a tendency to forget to update the playground between releases πŸ˜…, so if you believe this to be the case look me up somewhere on this page and lemme know πŸ€·β€β™‚οΈ

Wanna help support WooGraphQL's future

Follow alt textalt text

Demo/Examples

Who using WooGraphQL

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

More Repositories

1

wp-graphql

πŸš€ GraphQL API for WordPress
PHP
3,634
star
2

wp-graphql-acf

WPGraphQL for Advanced Custom Fields
PHP
626
star
3

wp-graphql-jwt-authentication

Authentication for WPGraphQL using JWT (JSON Web Tokens)
PHP
334
star
4

wp-graphiql

GraphiQL IDE, fine tuned for use with WPGraphQL
JavaScript
289
star
5

gatsby-wpgraphql-blog-example

Demo showing how to use WPGraphQL as the source for Gatsby Sites
JavaScript
147
star
6

wp-graphql-custom-post-type-ui

Adds Settings to the Custom Post Type UI plugin to show Post Types in WPGraphQL
PHP
82
star
7

wpgraphql-acf

Re-architecture of WPGraphQL for ACF
PHP
79
star
8

wp-graphql-smart-cache

Smart Caching & Cache Invalidation for WPGraphQL
PHP
60
star
9

wp-graphql-meta-query

WPGraphQL Extension: Adds "meta_query" support to postObject connection queries using WP_Query
PHP
51
star
10

wp-graphql-tax-query

Adds `tax_query` support to postObject connection queries using WP_Query
PHP
46
star
11

wpgraphql.com

The main website for WPGraphQL.com. This is a NextJS site pulling data from WordPress + WPGraphQL.
JavaScript
36
star
12

wp-graphql-block-editor

EXPERIMENTAL plugin extending WPGraphQL to support querying (Gutenberg) Blocks as data, using Server Side Block registries to map Blocks to the GraphQL Schema.
PHP
32
star
13

wordflix-single-page-app

This is a Single Page App that was created for use in a workshop showing how to build Single Page Apps using WordPress, React and GraphQL.
HTML
26
star
14

docs.wpgraphql.com

DEPRECATED. The docs now exist within the WPGraphQL repo:
JavaScript
21
star
15

graphql-gutenblock-example

Example Gutenberg Block using WPGraphQL to populate the data
JavaScript
18
star
16

wpgraphql-gatsby-kanban

Kanban board created with WPGraphQL and Gatsby, for demo at WordCamp US
JavaScript
17
star
17

woographql-subscriptions

Adds WooCommerce Subscriptions types and functionality to your WPGraphQL API.
PHP
14
star
18

wp-graphql-insights

Insights and Logging for WPGraphQL
PHP
12
star
19

examples

JavaScript
11
star
20

wp-graphql-dad-jokes

Get a random Dad Joke returned via GraphQL query using the WPGraphQL WordPress plugin (https://github.com/wp-graphql/wp-graphql)
Shell
11
star
21

wpgraphql-ide

A next-gen query editor for WPGraphQL πŸš€
JavaScript
10
star
22

playground.wpgraphql.com

GraphiQL playground, specifically for WPGraphQL and it's extensions
JavaScript
10
star
23

wp-graphql-subscriptions

Subscriptions for WPGraphQL
10
star
24

wp-graphiql-2

Temporary home of v2.0 of WPGraphiQL, the GraphiQL IDE that ships with WPGraphQL
CSS
8
star
25

wp-graphql-testcase

WPGraphQL API Unit Testing Library supports WP-PHPUnit(PHPUnit) and WPBrowser(Codeception)
PHP
7
star
26

wp-graphql-notifications-connection-example

This is an example plugin showing how to register custom connections to WPGraphQL, pulling data from custom SQL tables.
PHP
7
star
27

wp-graphql-fieldmanager

GraphQL bindings for WordPress Fieldmanager, by Alley Interactive
PHP
6
star
28

wp-graphql-react-native-example

This is a repository showing a basic example of using React Native to interact with WPGraphQL. NOTE: This is an example project and should not necessarily be considered a guide for best practices.
Java
5
star
29

wp-graphql-federation

Extension to WPGraphQL, providing support for Apollo Federation
PHP
4
star
30

wp-graphql-theme

WordPress Theme for wpgraphql.com
CSS
4
star
31

wp-settings-api

API for building setting pages in WordPress.
3
star
32

wp-graphql-blue-guitar

Example plugin showing how to register a GraphQL field to the WPGraphQL Schema
PHP
3
star
33

wp-graphql-api-docs

WPGraphQL API Docs generated using ApiGen
HTML
2
star
34

wp-graphql-e2e-tests-example

An example plugin showing how to add End to End tests to a WordPress plugin
JavaScript
2
star
35

wp-graphql-docs

Documentation for your WP GraphQL Schema
HTML
2
star
36

acf.wpgraphql.com

JavaScript
1
star
37

dashboard.wpgraphql.com

Prototype of a WordPress Dashboard built on Gatsby, using WPGraphQL and Ant Design
1
star
38

wp-graphiql-desktop

GraphiQL, tailored specifically for working with WPGraphQL as a Desktop App.
JavaScript
1
star
39

wp-graphql-co-authors-plus

Adds Co Authors Plus support to WPGraphQL
1
star