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 | |
| /** | |
| * Given the Schema and a query string, return a list of GraphQL Types that are being asked for | |
| * by the query. | |
| * | |
| * @param Schema $schema The WPGraphQL Schema | |
| * @param string $query The query string | |
| * | |
| * @return array | 
  
    
      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', 'privateField', [ | |
| 'type' => 'String', | |
| 'resolve' => function() { | |
| return 'some private data'; | |
| }, | |
| 'auth' => [ | |
| 'callback' => function() { | |
| return current_user_can( 'edit_posts' ); | 
  
    
      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( 'register_post_type_args', function( $args, $post_type ) { | |
| if ( 'wp_template_part' === $post_type ) { | |
| $args['show_in_graphql'] = true; | |
| $args['graphql_single_name'] = 'TemplatePart'; | |
| $args['graphql_plural_name'] = 'TemplateParts'; | |
| } | |
| 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
    
  
  
    
  | <?php | |
| /** | |
| * Plugin Name: WPGraphQL Request Logger | |
| * Description: This plugin logs WPGraphQL Requests to a Custom Post Type. This is a debugging tool. Not intended for production use. Also, not fully tested. Use at your own risk. | |
| * Plugin Author: Jason Bahl | |
| * Author URI: https://www.wpgraphql.com | |
| */ | |
| add_action( 'init', function() { | |
| register_post_type( 'graphql_request_logs', [ | 
  
    
      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
    
  
  
    
  | // NOTE, THIS IS VERY EXPERIMENTAL. TAKE THIS WITH A BIG GRAIN OF SALT, BUT DO WHAT YOU WILL WITH IT. | |
| register_graphql_object_type("ThemeSettings", [ | |
| 'description' => 'Theme Settings', | |
| 'fields' => [ | |
| 'primaryColor' => [ | |
| 'type' => 'string', | |
| 'description' => 'Primary Color', | |
| 'resolve' => function ($settings) { | |
| $colors = $settings->settings->color->palette->theme; | 
  
    
      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_pre_resolve_field', function( $default, $source, $args, $context, $info, $type_name, $field_key, $field, $field_resolver ) { | |
| if ( 'content' === $field_key && 'Post' === $type_name ) { | |
| return 'your override value'; | |
| } | |
| return $default; | |
| }, 10, 9 ); | 
  
    
      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
    
  
  
    
  | const { hooks, useAppContext } = wpGraphiQL | |
| const { useState } = wp.element | |
| const DemoButton = props => { | |
| const { GraphiQL, graphiql } = props; | |
| const [ count, setCount ] = useState( 0 ) | |
| return ( | 
  
    
      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
    
  
  
    
  | /** | |
| * This is an example showing how to add a custom action | |
| * to the operation action menu | |
| */ | |
| hooks.addFilter( | |
| "graphiql_operation_action_menu_items", | |
| "graphiql-extension", | |
| (menuItems, props) => { | |
| const { Menu } = props; | 
  
    
      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
    
  
  
    
  | const { hooks } = wpGraphiQL; | |
| import LZString from 'lz-string' | |
| hooks.addFilter( 'graphiql_after_graphiql', 'wp-graphiql-extension', (res, props) => { | |
| const encoded = LZString.compressToEncodedURIComponent(props.query) | |
| const decoded = LZString.decompressFromEncodedURIComponent(encoded) | |
| res.push( | |
| <div style={{maxWidth: `200px`}}> | 
  
    
      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
    
  
  
    
  | { | |
| posts { | |
| nodes { | |
| id | |
| title | |
| author { | |
| node { | |
| id | |
| firstName | |
| avatar { | 
