superhuit / wp-graphql-redirection
Exposes Redirection WP plugin in the WP-GraphQL schema
Package info
github.com/superhuit-agency/wp-graphql-redirection
Type:wordpress-plugin
pkg:composer/superhuit/wp-graphql-redirection
Requires
- php: ^7.4 || ^8.0
Requires (Dev)
- wp-graphql/wp-graphql: ^1.8
- wpackagist-plugin/redirection: ^5.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Exposes Redirection plugin in the GraphQL schema.
Requirements
- Requires PHP 7.4+
- Requires WordPress 5.0+
- Requires WP-GraphQL 1.8+
- Requires Redirection 5.0+
Install and Activate
WPGraphQl Redirection is a WordPress Plugin. YOu must then have a running WordPress instance with both WPGraphQL and Redirection plugins installed and activated.
Installing From Github
To install the plugin from Github, you can download the latest release zip file, upload the Zip file to your WordPress install, and activate the plugin.
Click here to learn more about installing WordPress plugins from a Zip file.
Installing from Composer
composer require superhuit/wp-graphql-redirection
Example
query getAllRedirections { redirections { code target url } } query getTheRedirection($uri: String!) { redirections(uri: $uri) { code target url } }
redirections (and isRedirected) only take active redirects into account: enabled redirects, in enabled groups of the WordPress module. Disabled redirects, and redirects in disabled groups or in Apache/Nginx groups, are left out.
WPGraphQL Smart Cache
When WPGraphQL Smart Cache is active, queries selecting redirections are not object-cached, and they are not tagged with the list:redirectionitemtype list type. Frontends usually look up redirections(uri:) on every page render, so that shared cache collection would otherwise grow with every URL rendered, and nothing purges it when a redirect changes. Redirects take effect on the next lookup that reaches WordPress (a network cache in front of GET requests still keeps responses for their max-age).
Keep the lookup in its own request: a query mixing redirections with other root fields isn't object-cached either, yet Smart Cache still maps its key, once per URI, into the collections of those other fields.
Tests
composer install
composer test