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 { addFilter } = wp.hooks; | |
| const { withState } = wp.components; | |
| class GraphQLMiddleware { | |
| constructor(config) { | |
| this.query = config.attributes.graphql.query; | |
| this.mutation = {}; | |
| this.config = _.extend( {}, config ); | |
| } | 
  
    
      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 gql from 'graphql-tag' | |
| import { client } from '../utils/apollo-client' | |
| const { parse } = wp.blocks; | |
| const { select, subscribe, dispatch } = wp.data; | |
| const GET_PAGE_BLOCK_TEMPLATE = gql` | |
| query GET_PAGE_BLOCK_TEMPLATE($id: ID!, $template: String) { | |
| page( id: $id ) { | |
| blockTemplate( pageTemplate: $template ) | |
| } | |
| } | 
  
    
      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_page_fields', function( $fields ) { | |
| $fields['blockTemplate'] = [ | |
| 'type' => \WPGraphQL\Types::string(), | |
| 'description' => __( 'The Block template defined for the page', 'oshpd-guten-blocks' ), | |
| 'args' => [ | |
| 'pageTemplate' => [ | |
| 'type' => \WPGraphQL\Types::string(), | |
| 'description' => __( 'The page template associated with the block template', 'oshpd-guten-blocks' ), | |
| ], | 
  
    
      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 gql from 'graphql-tag' | |
| import { client } from '../utils/apollo-client' | |
| const { parse } = wp.blocks; | |
| const { select, subscribe, dispatch } = wp.data; | |
| const GET_PAGE_BLOCK_TEMPLATE = gql` | |
| query GET_PAGE_BLOCK_TEMPLATE($id: ID!, $template: String) { | |
| page( id: $id ) { | |
| blockTemplate( pageTemplate: $template ) | |
| } | |
| } | 
  
    
      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
    
  
  
    
  | /** | |
| * Adds a field to the Page type in the GraphQL Schema to allow for the page's "blockTemplate" to be fetched and | |
| * returned. | |
| */ | |
| add_filter( 'graphql_page_fields', function( $fields ) { | |
| $fields['blockTemplate'] = [ | |
| 'type' => \WPGraphQL\Types::string(), | |
| 'description' => __( 'The Block template defined for the page', 'oshpd-guten-blocks' ), | |
| '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_root_queries', function( $fields ) { | |
| $fields['userRoles'] = [ | |
| 'type' => \WPGraphQL\Types::list_of( new \WPGraphQL\Type\WPObjectType([ | |
| 'name' => 'UserRole', | |
| 'fields' => [ | |
| 'name' => [ | |
| 'type' => \WPGraphQL\Types::string(), | |
| ], | |
| 'capabilities' => [ | 
  
    
      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( 'app_audio_track', [ | |
| 'label' => 'App Audio Track', | |
| 'public' => true, | |
| 'show_in_graphql' => true, | |
| 'graphql_single_name' => 'AppAudioTrack', | |
| 'graphql_plural_name' => 'AppAudioTracks', | |
| ] ); | |
| } ); | 
  
    
      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( 'Post', 'likeCount', [ | |
| 'type' => 'Int', | |
| 'description' => __( 'The number of likes for the post', 'your-textdomain' ), | |
| 'resolve' => function( $post ) { | |
| $likes = get_post_meta( $post->ID, 'likes', true ); | |
| return isset( $likes ) ? (int) $likes : 0; | |
| } | |
| ] ); | 
  
    
      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( 'audio-track', [ | |
| 'public' => true, | |
| 'label' => __( 'Audio Tracks', 'wp-graphql' ), | |
| 'show_in_graphql' => true, | |
| 'graphql_single_name' => 'AudioTrack', | |
| 'graphql_plural_name' => 'AudioTracks' | |
| ] ); | |
| register_post_type( 'audio-playlist', [ | 
  
    
      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() { | |
| /** | |
| * Define the Types and their Fields that we want to filter | |
| */ | |
| $fields_to_require_auth = [ | |
| 'Post' => [ | |
| 'author' | |
| ], | |
| 'Comment' => [ | 
