PHP code example of valu / wp-graphql-lock

1. Go to this page and download the library: Download valu/wp-graphql-lock library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

valu / wp-graphql-lock example snippets


add_filter( 'graphql_lock_load_query', function( string $query, string $query_id ) {
    $queries = json_decode( file_get_contents( __DIR__ . '/.persisted-query-ids/server.json' ), true );
    return $queries[ $query_id ] ?? null;
}, 10, 2 );

update_option( 'graphql_lock_locked', true );

add_filter( 'option_graphql_lock_locked', function() {
    return 'production' === WP_ENV;
}, 10 , 1 );