Added dependency plugins

This commit is contained in:
Moris Zen
2018-06-25 00:00:37 +02:00
parent 720a1c31a4
commit f069f6782f
698 changed files with 289637 additions and 1 deletions

View File

@@ -0,0 +1,57 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class WPGraphQL_CLI_Command extends WP_CLI_Command {
/**
* Generate a static schema.
*
* Defaults to creating a schema.graphql file in the IDL format at the root
* of the plugin.
*
* @todo: Provide alternative formats (AST? INTROSPECTION JSON?) and options for output location/file-type?
* @todo: Add Unit Tests
*
* ## EXAMPLE
*
* $ wp graphql generate
*
* @alias generate
* @subcommand generate-static-schema
*/
public function generate_static_schema( $args, $assoc_args ) {
/**
* Set the file path for where to save the static schema
*/
$file_path = WPGRAPHQL_PLUGIN_DIR . 'schema.graphql';
/**
* Generate the Schema
*/
WP_CLI::line( 'Getting the Schema...' );
$schema = WPGraphQL::get_schema();
/**
* Format the Schema
*/
WP_CLI::line( 'Formatting the Schema...' );
$printed = \GraphQL\Utils\SchemaPrinter::doPrint( $schema );
/**
* Save the Schema to the file
*/
WP_CLI::line( 'Saving the Schema...' );
file_put_contents( $file_path, $printed );
/**
* All done!
*/
WP_CLI::success( sprintf( 'All done. Schema output to %s.', $file_path ) );
}
}
WP_CLI::add_command( 'graphql', 'WPGraphQL_CLI_Command' );