harimau99 / GatoGraphQL

Interact with all your data in WordPress using GraphQL

Home Page:https://gatographql.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unit tests Downgrade PHP tests Scoping tests Generate plugins

Gato GraphQL

Gato GraphQL is a tool for interacting with data in your WordPress site. You can think of it as a Swiss Army knife for dealing with data, as it allows to retrieve, manipulate and store again any piece of data, in any desired way, using the GraphQL language.

With Gato GraphQL, you can:

  • Query data to create headless sites
  • Expose public and private APIs
  • Map JS components to Gutenberg blocks
  • Synchronize content across sites
  • Automate tasks
  • Complement WP-CLI to execute admin tasks
  • Search/replace content for site migrations
  • Send notifications when something happens (new post published, new comment added, etc)
  • Interact with cloud services
  • Convert the data from a 3rd-party API into the required format
  • Translate content in the site
  • Update thousands of posts with a single action
  • Insert or remove Gutenberg blocks in bulk
  • Validate that a new post contains a mandatory block
  • And much more...

Check out the Recipes section in gatographql.com which demonstrates how to implement these use cases using the plugin.

Screenshots

GraphiQL client to execute queries in the wp-admin:

GraphiQL client to execute queries in the wp-admin

Interactively browse the GraphQL schema, exploring all connections among entities:

Interactively browse the GraphQL schema, exploring all connections among entities

The GraphiQL client for the single endpoint is exposed to the Internet:

The GraphiQL client for the single endpoint is exposed to the Internet

Interactively browse the GraphQL schema exposed for the single endpoint:

Interactively browse the GraphQL schema exposed for the single endpoint

Persisted queries are pre-defined and stored in the server:

Persisted queries are pre-defined and stored in the server

Requesting a persisted query URL will retrieve its pre-defined GraphQL response:

Requesting a persisted query URL will retrieve its pre-defined GraphQL response

We can create multiple custom endpoints, each for a different target:

We can create multiple custom endpoints, each for a different target

Endpoints are configured via Schema Configurations:

Endpoints are configured via Schema Configurations

We can create many Schema Configurations, customizing them for different users or applications:

We can create many Schema Configurations, customizing them for different users or applications

Custom endpoints and Persisted queries can be public, private and password-protected:

Custom endpoints and Persisted queries can be public, private and password-protected

Manage custom endpoints and persisted queries by adding categories to them:

Manage custom endpoints and persisted queries by adding categories to them

We can configure exactly what custom post types, options and meta keys can be queried:

We can configure exactly what custom post types, options and meta keys can be queried

Configure every aspect from the plugin via the Settings page:

Configure every aspect from the plugin via the Settings page

Modules with different functionalities and schema extensions can be enabled and disabled:

Modules with different functionalities and schema extensions can be enabled and disabled

Augment the plugin functionality and GraphQL schema via extensions:

Augment the plugin functionality and GraphQL schema via extensions

The Recipes section contains example queries ready to copy/paste and use:

The Recipes section contains example queries ready to copy/paste and use

Installing the Gato GraphQL plugin in WordPress

For alternative installation methods, check Installing Gato GraphQL.

Download the latest release of the plugin as a .zip file.

Then, in the WordPress admin:

  • Go to Plugins => Add New
  • Click on Upload Plugin
  • Select the .zip file
  • Click on Install Now (it may take a few minutes)
  • Once installed, click on Activate

Requirements:

  • WordPress 5.4+
  • PHP 7.2+

Development

Supported PHP features

Check the list of Supported PHP features.

Gutenberg JS builds

Compiled JavaScript code (such as all files under a block's build/ folder) is added to the repo, but only as compiled for production, i.e. after running npm run build.

Code compiled for development, i.e. after running npm start, cannot be commited/pushed to the repo.

Architectural resources

PHP Architecture

Articles explaining how the plugin is "downgraded", using PHP 8.1 for development but deployable to PHP 7.2 for production:

  1. Transpiling PHP code from 8.0 to 7.x via Rector
  2. Coding in PHP 7.4 and deploying to 7.1 via Rector and GitHub Actions
  3. Tips for transpiling code from PHP 8.0 down to 7.1
  4. Including both PHP 7.1 and 8.0 code in the same plugin … or not?

Service container implementation:

Explanation of how the codebase is split into granular packages, to enable CMS-agnosticism:

  1. Abstracting WordPress Code To Reuse With Other CMSs: Concepts (Part 1)
  2. Abstracting WordPress Code To Reuse With Other CMSs: Implementation (Part 2)

Description of how the plugin is scoped:

GraphQL by PoP documentation

Gato GraphQL is powered by the CMS-agnostic GraphQL server GraphQL by PoP.

Technical information on how the GraphQL server works:

Description of how a GraphQL server using server-side components works:

These articles explain the concepts, design and implementation of GraphQL by PoP:

  1. Designing a GraphQL server for optimal performance
  2. Simplifying the GraphQL data model
  3. Schema-first vs code-first development in GraphQL
  4. Speeding-up changes to the GraphQL schema
  5. Versioning fields in GraphQL
  6. GraphQL directives are underrated
  7. Treating GraphQL directives as middleware
  8. Creating an @export GraphQL directive
  9. Adding directives to the schema in code-first GraphQL servers
  10. Coding a GraphQL server in JavaScript vs. WordPress
  11. Supporting opt-in nested mutations in GraphQL
  12. HTTP caching in GraphQL

Gutenberg

These articles explain the integration with Gutenberg (the WordPress editor).

  1. Adding a Custom Welcome Guide to the WordPress Block Editor
  2. Using Markdown and Localization in the WordPress Block Editor

Monorepo documentation

GatoGraphQL/GatoGraphQL is a monorepo containing the several layers required for Gato GraphQL. Check Monorepo_README.md for documentation of the different projects.

Standards

PSR-1, PSR-4 and PSR-12.

To check the coding standards via PHP CodeSniffer, run:

composer check-style

To automatically fix issues, run:

composer fix-style

Release notes

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

To execute PHPUnit, run:

composer test

Static Analysis

To execute PHPStan, run:

composer analyse

Downgrading code

To visualize how Rector will downgrade the code to PHP 7.2:

composer preview-code-downgrade

Report issues

To report a bug or request a new feature please do it on the GatoGraphQL monorepo issue tracker.

Contributing

We welcome contributions for this package on the GatoGraphQL monorepo (where the source code for this package is hosted).

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email leo@getpop.org instead of using the issue tracker.

Credits

License

GPLv2 or later. Please see License File for more information.

About

Interact with all your data in WordPress using GraphQL

https://gatographql.com

License:GNU General Public License v2.0


Languages

Language:PHP 94.1%Language:JavaScript 4.2%Language:CSS 1.1%Language:Shell 0.4%Language:SCSS 0.1%Language:HTML 0.1%