All Projects → GraphQLAPI → Graphql Api For Wp

GraphQLAPI / Graphql Api For Wp

Licence: gpl-2.0
[READ ONLY] GraphQL API for WordPress

Projects that are alternatives of or similar to Graphql Api For Wp

Blog Service
blog service @nestjs
Stars: ✭ 188 (+38.24%)
Mutual labels:  api, graphql, graphql-server, api-server
Graphql2rest
GraphQL to REST converter: automatically generate a RESTful API from your existing GraphQL API
Stars: ✭ 181 (+33.09%)
Mutual labels:  api, graphql, graphql-server, api-server
Pop
Monorepo of the PoP project, including: a server-side component model in PHP, a GraphQL server, a GraphQL API plugin for WordPress, and a website builder
Stars: ✭ 160 (+17.65%)
Mutual labels:  api, graphql, graphql-server, wordpress
Wp Graphql
🚀 GraphQL API for WordPress
Stars: ✭ 3,097 (+2177.21%)
Mutual labels:  api, graphql, graphql-server, wordpress
Wp Graphql Gutenberg
Query gutenberg blocks with wp-graphql
Stars: ✭ 158 (+16.18%)
Mutual labels:  api, graphql, wordpress
Grial
A Node.js framework for creating GraphQL API servers easily and without a lot of boilerplate.
Stars: ✭ 194 (+42.65%)
Mutual labels:  graphql, graphql-server, api-server
Storefront Api
Storefront GraphQL API Gateway. Modular architecture. ElasticSearch included. Works great with Magento1, Magento2, Spree, OpenCart, Pimcore and custom backends
Stars: ✭ 180 (+32.35%)
Mutual labels:  api, graphql, graphql-server
Wp Graphql Woocommerce
Add WooCommerce support and functionality to your WPGraphQL server
Stars: ✭ 318 (+133.82%)
Mutual labels:  api, graphql, graphql-server
Wp Graphql Acf
WPGraphQL for Advanced Custom Fields
Stars: ✭ 358 (+163.24%)
Mutual labels:  api, graphql, wordpress
Api Platform
Create REST and GraphQL APIs, scaffold Jamstack webapps, stream changes in real-time.
Stars: ✭ 7,144 (+5152.94%)
Mutual labels:  api, graphql, graphql-server
Graphiti
Stylish Graph APIs
Stars: ✭ 783 (+475.74%)
Mutual labels:  api, graphql, api-server
Omdb Graphql Wrapper
🚀 GraphQL wrapper for the OMDb API
Stars: ✭ 45 (-66.91%)
Mutual labels:  api, graphql, graphql-server
Ariadne
Ariadne is a Python library for implementing GraphQL servers using schema-first approach.
Stars: ✭ 1,274 (+836.76%)
Mutual labels:  api, graphql, graphql-server
Typegql
Create GraphQL schema with TypeScript classes.
Stars: ✭ 415 (+205.15%)
Mutual labels:  api, graphql, graphql-server
Rest Layer
REST Layer, Go (golang) REST API framework
Stars: ✭ 1,068 (+685.29%)
Mutual labels:  api, graphql, api-server
Graphql devise
GraphQL interface on top devise_token_auth
Stars: ✭ 100 (-26.47%)
Mutual labels:  api, graphql, api-server
Server
Framework NodeJS for GraphQl
Stars: ✭ 118 (-13.24%)
Mutual labels:  graphql, graphql-server
Searchobjectgraphql
GraphQL plugin for SearchObject gem
Stars: ✭ 118 (-13.24%)
Mutual labels:  graphql, graphql-server
Subzero Starter Kit
Starter Kit and tooling for authoring GraphQL/REST API backends with subZero
Stars: ✭ 136 (+0%)
Mutual labels:  api, graphql
Wp Graphql Yoast Seo
This is an extension to the WPGraphQL plugin for Yoast SEO
Stars: ✭ 120 (-11.76%)
Mutual labels:  graphql, wordpress

GraphQL API for WordPress

Transform your WordPress site into a modern GraphQL server: graphql-api.com.

The interactive schema visualizer

This plugin is the implementation for WordPress of GraphQL by PoP, a CMS-agnostic GraphQL server in PHP.

Requirements

  • WordPress 5.4 or above
  • PHP 8.0+ for development
  • PHP 7.1+ for production

Install

Ready for production?

This plugin requires 3rd party dependencies, but they have not been scoped yet (see issue #9). So please install this plugin in a development environment first, to make sure there are no conflicts with the other plugins installed in the site.

Upload

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

Timeout in Nginx?

Nginx has a time limit to process the response from the PHP backend, and installing large WordPress plugins may exceed the default time limit.

If when installing the plugin you get a "504 Gateway Timeout" error, or an entry "upstream timed out (110: Connection timed out) while reading upstream" in the log, increase the timeout to 300 seconds in the Nginx config, as explained here.

Composer

Add the following configuration to your composer.json:

{
    "require": {
        "graphql-api/graphql-api-for-wp": "^0.7.13"
    },
    "minimum-stability": "dev",
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "graphql-api/graphql-api-for-wp",
                "type": "wordpress-plugin",
                "version": "0.7.13",
                "dist": {
                    "url": "https://github.com/leoloso/PoP/releases/latest/download/graphql-api.zip",
                    "type": "zip"
                },
                "require": {
                    "composer/installers": "^1"
                }
            }
        }
    ],
    "extra": {
        "installer-paths": {
            "wp-content/plugins/{$name}/": [
                "type:wordpress-plugin"
            ]
        }
    }
}

WP-CLI

To install via WP-CLI, execute this command:

wp plugin install --activate https://github.com/leoloso/PoP/releases/latest/download/graphql-api.zip

GitHub Updater

This plugin support automatic updating via the GitHub Updater.

Development

The source code is hosted on the PoP monorepo, under GraphQLAPIForWP/plugins/graphql-api-for-wp.

To set it up:

  1. Clone the monorepo:
git clone https://github.com/leoloso/PoP.git && cd PoP
  1. Install Composer dependencies:
cd layers/GraphQLAPIForWP/plugins/graphql-api-for-wp && composer install

Using Lando

Launch a development server, with WordPress installed and the GraphQL API plugin activated, through Lando.

Please make sure you have Lando installed, with version 3.0.26 or upwards (or install it from here).

The first time, to install the server, execute:

composer build-server

From then on, to start the server, execute:

composer start-server

The site will be available under http://graphql-api-dev.lndo.site.

To access the wp-admin:

  • User: admin
  • Password: admin

Enable XDebug

To enable debugging, create Lando config file .lando.local.yml with this content:

config:
  xdebug: true

And then rebuild the server:

composer rebuild-server

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.

PHP versions

Requirements:

  • PHP 8.0+ for development
  • PHP 7.1+ for production (through release graphql-api.zip)

Supported PHP features

Check the list of Supported PHP features in leoloso/PoP

Modules

GraphQL API is extensible, and ships with the following modules (organized by category):

Module Description

Endpoint
Single Endpoint Expose a single GraphQL endpoint under /graphql/, with unrestricted access
Persisted Queries Expose predefined responses through a custom URL, akin to using GraphQL queries to publish REST endpoints
Custom Endpoints Expose different subsets of the schema for different targets, such as users (clients, employees, etc), applications (website, mobile app, etc), context (weekday, weekend, etc), and others
API Hierarchy Create a hierarchy of API endpoints extending from other endpoints, and inheriting their properties

Schema Configuration
Schema Configuration Customize the schema accessible to different Custom Endpoints and Persisted Queries, by applying a custom configuration (involving namespacing, access control, cache control, and others) to the grand schema
Schema Namespacing Automatically namespace types and interfaces with a vendor/project name, to avoid naming collisions
Public/Private Schema Enable to communicate the existence of some field from the schema to certain users only (private mode) or to everyone (public mode). If disabled, fields are always available to everyone (public mode)

Access Control
Access Control Set-up rules to define who can access the different fields and directives from a schema
Access Control Rule: Disable Access Remove access to the fields and directives
Access Control Rule: User State Allow or reject access to the fields and directives based on the user being logged-in or not
Access Control Rule: User Roles Allow or reject access to the fields and directives based on the user having a certain role
Access Control Rule: User Capabilities Allow or reject access to the fields and directives based on the user having a certain capability

Versioning
Field Deprecation Deprecate fields, and explain how to replace them, through a user interface

User Interface
Low-Level Persisted Query Editing Have access to schema-configuration low-level directives when editing GraphQL queries in the admin
Excerpt as Description Provide a description of the different entities (Custom Endpoints, Persisted Queries, and others) through their excerpt

Performance
Cache Control Provide HTTP Caching for Persisted Queries, sending the Cache-Control header with a max-age value calculated from all fields in the query
Configuration Cache Cache the generated application configuration to disk
Schema Cache Cache the generated schema to disk

Operational
Multiple Query Execution Execute multiple GraphQL queries in a single operation
Remove if Null Addition of @removeIfNull directive, to remove an output from the response if it is null
Proactive Feedback Usage of the top-level entry extensions to send deprecations, warnings, logs, notices and traces in the response to the query
Embeddable Fields Resolve a field within an argument for another field from the same type, using syntax {{ fieldName }}
Composable Directives Have directives modify the behavior of other directives
Mutations Modify data by executing mutations
Nested Mutations Execute mutations from any type in the schema, not only from the root

Plugin Management
Schema Editing Access Grant access to users other than admins to edit the GraphQL schema

Clients
GraphiQL for Single Endpoint Make a public GraphiQL client available under /graphiql/, to execute queries against the single endpoint. It requires pretty permalinks enabled
Interactive Schema for Single Endpoint Make a public Interactive Schema client available under /schema/, to visualize the schema accessible through the single endpoint. It requires pretty permalinks enabled
GraphiQL for Custom Endpoints Enable custom endpoints to be attached their own GraphiQL client, to execute queries against them
Interactive Schema for Custom Endpoints Enable custom endpoints to be attached their own Interactive schema client, to visualize the custom schema subset
GraphiQL Explorer Add the Explorer widget to the GraphiQL client, to simplify coding the query (by point-and-clicking on the fields)

Schema Type
Schema Custom Posts Base functionality for all custom posts
Schema Generic Custom Posts Query any custom post type (added to the schema or not), through a generic type GenericCustomPost
Schema Posts Query posts, through type Post added to the schema
Schema Pages Query pages, through type Page added to the schema
Schema Users Query users, through type User added to the schema
Schema User Roles Query user roles, through type UserRole added to the schema
Schema Comments Query comments, through type Comment added to the schema
Schema Tags Base functionality for all tags
Schema Post Tags Query post tags, through type PostTag added to the schema
Schema Media Query media elements, through type Media added to the schema
Schema User State Mutations Have the user log-in, and be able to perform mutations
Schema Custom Post Mutations Base functionality to mutate custom posts
Schema Post Mutations Execute mutations on podyd
Schema Custom Post Media Mutations Execute mutations concerning media items on custom posts
Schema Comment Mutations Create comments

Resources

Videos

The following videos demonstrate several features:

WordPress Philosophy

Detailed explanation of the plugin goals, and how it renders the WordPress philosophy:

  1. Rendering the WordPress philosophy in GraphQL

PHP Architecture

Articles explaining how the plugin is coded using PHP 8.0 but can run on PHP 7.1:

  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

GraphQL by PoP documentation

GraphQL API for WordPress is powered by the CMS-agnostic GraphQL server GraphQL by PoP.

For technical information on how it works, check out its documentation.

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

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

Feature Roadmap

Sponsorship

Ongoing development for this project is funded via Leonardo Losoviz's GitHub sponsors:

Become a sponsor to Leonardo Losoviz ❤️

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.1:

composer preview-code-downgrade

Report issues

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

Contributing

We welcome contributions for this package on the PoP 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 [email protected] instead of using the issue tracker.

Credits

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].