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_before_resolve_field', function( $source, $args, $context, \GraphQL\Type\Definition\ResolveInfo $info, $field_resolver, $type_name, $field_key, $field ) { | |
| if ( 'RootMutation' === $info->parentType->name ) { | |
| $type = \WPGraphQL\TypeRegistry::get_type( $type_name ); | |
| if ( isset( $type ) && ! empty( $field = $type->getField( $field_key ) ) ) { | |
| if ( isset( $field->config['isPublic'] ) && true === $field->config['isPublic'] ) { | |
| if ( true === true ) { | |
| throw new Exception( __( 'This mutation has been executed too many times in the allowed timeframe', 'wp-graphql' ) ); | |
| } | 
  
    
      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() { | |
| $args = [ | |
| 'type' => 'String', | |
| 'description' => __( 'Custom field for user mutations', 'your-textdomain' ), | |
| 'resolve' => function( \WP_User $user ) { | |
| return get_user_meta( $user->ID, 'custom_field_meta_key', 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
    
  
  
    
  | <?php | |
| add_action( 'parse_request', 'disable_front_end', 99 ); | |
| function disable_front_end() { | |
| global $wp; | |
| /** | |
| * If the request is not part of a CRON, REST Request, GraphQL Request or Admin request, | 
  
    
      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', 'register_dog_type' ); | |
| function register_dog_type() { | |
| register_graphql_object_type( 'Dog', [ | |
| 'description' => __( "Man's best friend", 'your-textdomain' ), | |
| 'fields' => [ | |
| 'name' => [ | |
| 'type' => 'String', | |
| 'description' => __( 'The name of the dog', 'your-textdomain' ), | |
| ], | 
  
    
      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() { | |
| $post_types = WPGraphQL::$allowed_post_types; | |
| if ( ! empty( $post_types ) && is_array( $post_types ) ) { | |
| foreach ( $post_types as $post_type ) { | |
| $post_type_object = get_post_type_object( $post_type ); | |
| /** | |
| * Get the Type name with ucfirst | 
  
    
      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', function() { | |
| register_post_type( 'physician', [ | |
| 'hierarchical' => false, | |
| 'label' => __( 'Physicians', 'wp-graphql' ), | |
| 'public' => true, | |
| 'show_in_graphql' => true, | |
| 'graphql_single_name' => 'Physician', | |
| 'graphql_plural_name' => 'Physicians', | |
| ] ); | |
| register_post_type( 'disease', [ | 
  
    
      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() { | |
| $myCustomType = [ | |
| 'someField' => 'Some value...', | |
| ]; | |
| register_graphql_object_type( 'MyCustomType', [ | |
| 'fields' => [ | |
| 'someField' => [ | |
| 'type' => 'string', | 
  
    
      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_PostObjectsConnectionOrderbyEnum_values', function( $values ) { | |
| $values['LIKE_COUNT'] = [ | |
| 'value' => 'like_count', | |
| 'description' => __( 'The number of likes on the post', 'wp-graphql' ), | |
| ]; | |
| return $values; | |
| } ); | 
  
    
      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
    
  
  
    
  | /** | |
| * Register the Post Type for storing the logs | |
| */ | |
| add_action( 'init', function() { | |
| register_post_type( 'graphql_mutation_log', [ | |
| 'label' => __( 'Mutation Logs', 'wp-syndication-debugger' ), | |
| 'public' => false, | |
| 'exclude_from_search' => true, | |
| 'show_ui' => current_user_can( 'manage_options' ) ? true : false, | |
| 'show_in_graphql' => 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
    
  
  
    
  | add_action( 'graphql_register_types', function() { | |
| register_graphql_connection([ | |
| 'fromType' => 'Post', | |
| 'toType' => 'MediaItem', | |
| 'fromFieldName' => 'attachments', | |
| 'resolveNode' => function( $id, $args, $context ) { | |
| return \WPGraphQL\Data\DataSource::resolve_post_object( $id, $context ); | |
| }, | |
| 'resolve' => function( $post, $args, $context, $info ) { | 
