This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'graphql_register_types', function() { | |
| register_graphql_field( 'RootQuery', 'testType', [ | |
| 'type' => 'TestType', | |
| 'resolve' => function() { | |
| return [ | |
| '__typename' => 'TestType', | |
| 'test' => 'Test Field Value...', | |
| 'id' => 'root:testType:1' | |
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Plugin Name: WPGraphQL Smart Cache for Litespeed | |
| * Description: Allows WPGraphQL Smart Cache to work for WordPress sites hosted on environments using Litespeed Cache | |
| * Author: WPGraphQL | |
| * Author URI: http://www.wpgraphql.com | |
| * Text Domain: wp-graphql-smart-cache-litespeed | |
| * Version: 0.0.1 | |
| * Requires at least: 5.0 | |
| * Tested up to: 6.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Plugin Name: WPGraphQL Post Type Order Fix | |
| * Description: Fixes a bug with WPGraphQL pagination when the "Post Type Order" plugin is also active and in use | |
| */ | |
| add_action( 'pre_get_posts', function () { | |
| // access the custom post type order class | |
| global $CPTO; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'init_graphql_request', function() { | |
| $analyzer = null; | |
| add_action( 'graphql_determine_graphql_keys', function( \WPGraphQL\Utils\QueryAnalyzer $query_analyzer, $query ) use ( &$analyzer ) { | |
| $analyzer = $query_analyzer; | |
| }, 10, 2 ); | |
| add_filter( 'graphql_query_analyzer_get_runtime_nodes', function( $nodes ) use ( &$analyzer ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {createPersistedQueryLink} from '@apollo/client/link/persisted-queries'; | |
| import {HttpLink} from "@apollo/client"; | |
| import {sha256} from 'crypto-hash'; | |
| const linkChain = createPersistedQueryLink({ sha256 }).concat( | |
| new HttpLink({ uri: process.env.WPGRAPHQL_URL }), | |
| ); | |
| class PersistedQueriesPlugin { | |
| apply({ addFilter }) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'graphql_register_types', function() { | |
| register_graphql_interface_type( 'Food', [ | |
| 'description' => __( 'An item of food for sale', 'your-textdomain' ), | |
| 'interfaces' => [ 'Node', 'NodeWithTitle' ], | |
| 'fields' => [ | |
| 'price' => [ | |
| 'type' => 'String', | |
| 'description' => __( 'The cost of the food item', 'your-textdomain' ), | |
| 'resolve' => function( $food ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'graphql_register_types', function() { | |
| register_graphql_field( 'Food', 'price', [ | |
| 'type' => 'String', | |
| 'description' => __( 'The cost of the food item', 'your-textdomain' ), | |
| 'resolve' => function( $food ) { | |
| return get_post_meta( $food->databaseId, 'price', true ); | |
| } | |
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UniquePosts { | |
| protected $loaded_posts = []; | |
| protected $amount_requested = 0; | |
| public function __construct() { | |
| add_filter( 'graphql_connection_amount_requested', [ $this, 'filter_amount_requested' ], 10, 2 ); | |
| add_filter( 'graphql_connection_nodes', [ $this, 'connection_nodes' ], 10, 2 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'wpgraphql_cache_purge_nodes', function( $key = 'purge', $nodes = [] ) { | |
| $pipedream_debugging = function_exists( 'get_graphql_setting' ) ? \get_graphql_setting( 'pipedream_post', 'off', 'purge_debugging' ) : 'off'; | |
| $enabled = $pipedream_debugging === 'on'; | |
| if ( ! $enabled || empty( $nodes ) ) { | |
| return; | |
| } | |
| $args = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'graphql_RootQuery_fields', function( $fields ) { | |
| if ( isset( $fields['posts'] ) ) { | |
| $args = is_array( $fields['posts']['args'] ) ? $fields['posts']['args'] : []; | |
| $args['myCustomArg'] = [ | |
| 'type' => 'String', | |
| 'description' => __( 'This is a field that was added via a filter', 'your-textdomain' ), | |
| ]; | |
| $fields['posts']['args'] = $args; | |
| } |