Skip to content

Commit

Permalink
Update WPGraphQL to 1.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
moiri-gamboni committed Jan 26, 2024
1 parent b9c3114 commit 6eb770b
Show file tree
Hide file tree
Showing 76 changed files with 592 additions and 526 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ function get_graphql_register_action() {
*
* Should be used at the `graphql_register_types` hook.
*
* @param mixed|string|array<string> $interface_names Array of one or more names of the GraphQL Interfaces to apply to the GraphQL Types
* @param mixed|string|array<string> $type_names Array of one or more names of the GraphQL Types to apply the interfaces to.
* @param string|string[] $interface_names Array of one or more names of the GraphQL Interfaces to apply to the GraphQL Types
* @param string|string[] $type_names Array of one or more names of the GraphQL Types to apply the interfaces to.
*
* Example:
* The following would register the "MyNewInterface" interface to the Post and Page type in the
Expand Down Expand Up @@ -819,10 +819,10 @@ function get_graphql_setting( string $option_name, $default_value = '', $section

/**
* Filter the section fields
*
* @param array $section_fields The values of the fields stored for the section
* @param string $section_name The name of the section
* @param mixed $default_value The default value for the option being retrieved
* @param array<string,mixed> $section_fields The values of the fields stored for the section
* @param string $section_name The name of the section
* @param mixed $default_value The default value for the option being retrieved
*/
$section_fields = apply_filters( 'graphql_get_setting_section_fields', $section_fields, $section_name, $default_value );

Expand All @@ -834,11 +834,11 @@ function get_graphql_setting( string $option_name, $default_value = '', $section
/**
* Filter the value before returning it
*
* @param mixed $value The value of the field
* @param mixed $default_value The default value if there is no value set
* @param string $option_name The name of the option
* @param array $section_fields The setting values within the section
* @param string $section_name The name of the section the setting belongs to
* @param mixed $value The value of the field
* @param mixed $default_value The default value if there is no value set
* @param string $option_name The name of the option
* @param array<string,mixed> $section_fields The setting values within the section
* @param string $section_name The name of the section the setting belongs to
*/
return apply_filters( 'graphql_get_setting_section_field_value', $value, $default_value, $option_name, $section_fields, $section_name );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function graphql_setup_constants() {

// Plugin version.
if ( ! defined( 'WPGRAPHQL_VERSION' ) ) {
define( 'WPGRAPHQL_VERSION', '1.16.0' );
define( 'WPGRAPHQL_VERSION', '1.20.0' );
}

// Plugin Folder Path.
Expand Down
25 changes: 23 additions & 2 deletions server/app/public/wp-content/plugins/wp-graphql/readme.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
=== WPGraphQL ===
Contributors: jasonbahl, tylerbarnes1, ryankanner, hughdevore, chopinbach, kidunot89
Contributors: jasonbahl, tylerbarnes1, ryankanner, hughdevore, chopinbach, kidunot89, justlevine
Tags: GraphQL, JSON, API, Gatsby, Faust, Headless, Decoupled, Svelte, React, Nextjs, Vue, Apollo, REST, JSON, HTTP, Remote, Query Language
Requires at least: 5.0
Tested up to: 6.4.1
Requires PHP: 7.1
Stable tag: 1.19.0
Stable tag: 1.20.0
License: GPL-3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -252,6 +252,27 @@ Composer dependencies are no longer versioned in Github. Recommended install sou

== Changelog ==

= 1.20.0=

**New Features**

- [#3013](https://github.com/wp-graphql/wp-graphql/pull/3013): feat: output GRAPHQL_DEBUG message if requested amount is larger than connection limit. Thanks @justlevine!
- [#3008](https://github.com/wp-graphql/wp-graphql/pull/3008): perf: Expose graphql_should_analyze_queries as setting. Thanks @justlevine!

**Chores / Bugfixes**

- [#3022](https://github.com/wp-graphql/wp-graphql/pull/3022): chore: add @justlevine to list of contributors! 🙌 🥳
- [#3011](https://github.com/wp-graphql/wp-graphql/pull/3011): chore: update composer dev-dependencies and use php-compatibility:develop branch to 8.0+ lints. Thanks @justlevine!
- [#3010](https://github.com/wp-graphql/wp-graphql/pull/3010): chore: implement stricter PHPDoc types. Thanks @justlevine!
- [#3009](https://github.com/wp-graphql/wp-graphql/pull/3009): chore: implement stricter PHPStan config and clean up unnecessary type-guards. Thanks @justlevine!
- [#3007](https://github.com/wp-graphql/wp-graphql/pull/3007): fix: call html_entity_decode() with explicit flags and decode single-quotes. Thanks @justlevine!
- [#3006](https://github.com/wp-graphql/wp-graphql/pull/3006): fix: replace deprecated AbstractConnectionResolver::setQueryArg() call with ::set_query_arg(). Thanks @justlevine!
- [#3004](https://github.com/wp-graphql/wp-graphql/pull/3004): docs: Update using-data-from-custom-database-tables.md
- [#2998](https://github.com/wp-graphql/wp-graphql/pull/2998): docs: Update build-your-first-wpgraphql-extension.md. Thanks @Jacob-Daniel!
- [#2997](https://github.com/wp-graphql/wp-graphql/pull/2997): docs: update wpgraphql-concepts.md. Thanks @Jacob-Daniel!
- [#2996](https://github.com/wp-graphql/wp-graphql/pull/2996): fix: Field id duplicates uri field description. Thanks @marcinkrzeminski!


= 1.19.0=

**New Features**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ public function register_settings() {
return absint( $value );
},
],
[
'name' => 'query_analyzer_enabled',
'label' => __( 'Enable GraphQL Type Tracking', 'wp-graphql' ),
'desc' => sprintf(
// translators: %s is either empty or a string with a note about force enabling.
__( 'When enabled, WPGraphQL will track the Types, Models, and Nodes used in the request, and return those values in the headers for use in debugging or header-based cache invalidation. %s', 'wp-graphql' ),
true === \WPGraphQL::debug() ? '<br /><strong>' . __( 'NOTE: This setting is force enabled because GraphQL Debug Mode is enabled. ', 'wp-graphql' ) . '</strong>' : ''
),
'type' => 'checkbox',
'disabled' => true === \WPGraphQL::debug(),
'value' => true === \WPGraphQL\Utils\QueryAnalyzer::is_enabled() ? 'on' : get_graphql_setting( 'query_analyzer_enabled', 'off' ),
],
[
'name' => 'graphiql_enabled',
'label' => __( 'Enable GraphiQL IDE', 'wp-graphql' ),
Expand Down Expand Up @@ -195,6 +207,7 @@ public function register_settings() {
'type' => 'checkbox',
'value' => true === \WPGraphQL::debug() ? 'on' : get_graphql_setting( 'debug_mode_enabled', 'off' ),
'disabled' => defined( 'GRAPHQL_DEBUG' ),
'default' => 'off',
],
[
'name' => 'tracing_enabled',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ public function register_field( string $section, array $field ) {
/**
* Filter the setting field config
*
* @param array $field_config The field config for the setting
* @param string $field_name The name of the field (unfilterable in the config)
* @param string $section The slug of the section the field is registered to
* @param array<string,mixed> $field_config The field config for the setting
* @param string $field_name The name of the field (unfilterable in the config)
* @param string $section The slug of the section the field is registered to
*/
$field = apply_filters( 'graphql_setting_field_config', $field_config, $field_name, $section );

Expand Down Expand Up @@ -160,7 +160,7 @@ public function admin_init() {
/**
* Filter the settings sections
*
* @param array $setting_sections The registered settings sections
* @param array<string,array<string,mixed>> $setting_sections The registered settings sections
*/
$setting_sections = apply_filters( 'graphql_settings_sections', $this->settings_sections );

Expand Down Expand Up @@ -551,7 +551,7 @@ public function callback_user_role_select( array $args ) {
*
* @param array<string,mixed> $options settings field args
*
* @return mixed
* @return array<string,mixed>
*/
public function sanitize_options( array $options ) {
if ( ! $options ) {
Expand All @@ -576,7 +576,7 @@ public function sanitize_options( array $options ) {
*
* @param string $slug option slug
*
* @return mixed string or bool false
* @return callable|false
*/
public function get_sanitize_callback( $slug = '' ) {
if ( empty( $slug ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class AppContext {
/**
* Passes context about the current connection being resolved
*
* @var mixed|String|null
* @var mixed|string|null
*/
public $currentConnection = null;

Expand Down Expand Up @@ -148,7 +148,7 @@ public function __construct() {
*
* @param string $key The name of the loader to get
*
* @return mixed
* @return \WPGraphQL\Data\Loader\AbstractDataLoader|mixed
*
* @deprecated Use get_loader instead.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ public static function prepare_comment_object( array $input, array &$output_args
/**
* Filter the $insert_post_args
*
* @param array $output_args The array of $input_post_args that will be passed to wp_new_comment
* @param array $input The data that was entered as input for the mutation
* @param string $mutation_type The type of mutation being performed ( create, edit, etc )
* @param array<string,mixed> $output_args The array of $input_post_args that will be passed to wp_new_comment
* @param array<string,mixed> $input The data that was entered as input for the mutation
* @param string $mutation_type The type of mutation being performed ( create, edit, etc )
*/
$output_args = apply_filters( 'graphql_comment_insert_post_args', $output_args, $input, $mutation_name );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,10 @@ public function graphql_wp_term_query_cursor_pagination_support( array $pieces,
/**
* If pre-filter hooked, return $pre_pieces.
*
* @param array<string, mixed>|null $pre_pieces The pre-filtered term query SQL clauses.
* @param array<string,mixed> $pieces Terms query SQL clauses.
* @param string[] $taxonomies An array of taxonomies.
* @param array<string,mixed> $args An array of terms query arguments.
*
* @return array|null
* @param ?array<string,mixed> $pre_pieces The pre-filtered term query SQL clauses.
* @param array<string,mixed> $pieces Terms query SQL clauses.
* @param string[] $taxonomies An array of taxonomies.
* @param array<string,mixed> $args An array of terms query arguments.
*/
$pre_pieces = apply_filters( 'graphql_pre_wp_term_query_cursor_pagination_support', null, $pieces, $taxonomies, $args );
if ( null !== $pre_pieces ) {
Expand Down Expand Up @@ -455,11 +453,9 @@ public function graphql_wp_comments_query_cursor_pagination_support( array $piec
/**
* If pre-filter hooked, return $pre_pieces.
*
* @param array|null $pre_pieces The pre-filtered comment query clauses.
* @param array $pieces A compacted array of comment query clauses.
* @param \WP_Comment_Query $query Current instance of WP_Comment_Query, passed by reference.
*
* @return array|null
* @param ?array<string,mixed> $pre_pieces The pre-filtered comment query clauses.
* @param array<string,mixed> $pieces A compacted array of comment query clauses.
* @param \WP_Comment_Query $query Current instance of WP_Comment_Query, passed by reference.
*/
$pre_pieces = apply_filters( 'graphql_pre_wp_comments_query_cursor_pagination_support', null, $pieces, $query );
if ( null !== $pre_pieces ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ abstract class AbstractConnectionResolver {
protected $ids;

/**
* @var array<string,mixed>
* @var mixed[]
*/
protected $nodes;

Expand Down Expand Up @@ -162,9 +162,9 @@ public function __construct( $source, array $args, AppContext $context, ResolveI
*
* Filters the GraphQL args before they are used in get_query_args().
*
* @param array $args The GraphQL args passed to the resolver.
* @param array<string,mixed> $args The GraphQL args passed to the resolver.
* @param \WPGraphQL\Data\Connection\AbstractConnectionResolver $connection_resolver Instance of the ConnectionResolver.
* @param array $unfiltered_args Array of arguments input in the field as part of the GraphQL query.
* @param array<string,mixed> $unfiltered_args Array of arguments input in the field as part of the GraphQL query.
*
* @since 1.11.0
*/
Expand All @@ -188,10 +188,9 @@ public function __construct( $source, array $args, AppContext $context, ResolveI
*
* Filters the args
*
* @param array $query_args The query args to be used with the executable query to get data.
* This should take in the GraphQL args and return args for use in fetching the data.
* @param array<string,mixed> $query_args The query args to be used with the executable query to get data.
* @param \WPGraphQL\Data\Connection\AbstractConnectionResolver $connection_resolver Instance of the ConnectionResolver
* @param array $unfiltered_args Array of arguments input in the field as part of the GraphQL query.
* @param array<string,mixed> $unfiltered_args Array of arguments input in the field as part of the GraphQL query.
*/
$this->query_args = apply_filters( 'graphql_connection_query_args', $this->get_query_args(), $this, $args );
}
Expand Down Expand Up @@ -415,8 +414,9 @@ public function get_node_by_id( $id ) {
/**
* Get_query_amount
*
* Returns the max between what was requested and what is defined as the $max_query_amount to
* ensure that queries don't exceed unwanted limits when querying data.
* Returns the max between what was requested and what is defined as the $max_query_amount to ensure that queries don't exceed unwanted limits when querying data.
*
* If the amount requested is greater than the max query amount, a debug message will be included in the GraphQL response.
*
* @return int
* @throws \Exception
Expand All @@ -429,25 +429,34 @@ public function get_query_amount() {
*
* This filter is intentionally applied AFTER the query_args filter, as
*
* @param int $max_posts the maximum number of posts per page.
* @param mixed $source source passed down from the resolve tree
* @param array $args array of arguments input in the field as part of the GraphQL query
* @param \WPGraphQL\AppContext $context Object containing app context that gets passed down the resolve tree
* @param \GraphQL\Type\Definition\ResolveInfo $info Info about fields passed down the resolve tree
* @param int $max_posts the maximum number of posts per page.
* @param mixed $source source passed down from the resolve tree
* @param array<string,mixed> $args array of arguments input in the field as part of the GraphQL query
* @param \WPGraphQL\AppContext $context Object containing app context that gets passed down the resolve tree
* @param \GraphQL\Type\Definition\ResolveInfo $info Info about fields passed down the resolve tree
*
* @since 0.0.6
*/
$max_query_amount = apply_filters( 'graphql_connection_max_query_amount', 100, $this->source, $this->args, $this->context, $this->info );

$requested_amount = $this->get_amount_requested();

return min( $max_query_amount, absint( $this->get_amount_requested() ) );
if ( $requested_amount > $max_query_amount ) {
graphql_debug(
sprintf( 'The number of items requested by the connection (%s) exceeds the max query amount. Only the first %s items will be returned.', $requested_amount, $max_query_amount ),
[ 'connection' => static::class ]
);
}

return min( $max_query_amount, $requested_amount );
}

/**
* Get_amount_requested
*
* This checks the $args to determine the amount requested, and if
*
* @return int|null
* @return int
* @throws \GraphQL\Error\UserError If there is an issue with the pagination $args.
*/
public function get_amount_requested() {
Expand Down Expand Up @@ -495,7 +504,7 @@ public function get_amount_requested() {
* @param int $amount the requested amount
* @param \WPGraphQL\Data\Connection\AbstractConnectionResolver $resolver Instance of the connection resolver class
*/
return max( 0, apply_filters( 'graphql_connection_amount_requested', $amount_requested, $this ) );
return (int) max( 0, apply_filters( 'graphql_connection_amount_requested', $amount_requested, $this ) );
}

/**
Expand Down Expand Up @@ -820,7 +829,7 @@ public function get_edges() {
/**
* Create the edge, pass it through a filter.
*
* @param array $edge The edge within the connection
* @param array<string,mixed> $edge The edge within the connection
* @param \WPGraphQL\Data\Connection\AbstractConnectionResolver $connection_resolver Instance of the connection resolver class
*/
$edge = apply_filters(
Expand Down Expand Up @@ -940,7 +949,7 @@ public function execute_and_get_ids() {
/**
* Filter the connection IDs
*
* @param array $ids Array of IDs this connection will be resolving
* @param int[]|string[] $ids Array of IDs this connection will be resolving
* @param \WPGraphQL\Data\Connection\AbstractConnectionResolver $connection_resolver Instance of the Connection Resolver
*/
$this->ids = apply_filters( 'graphql_connection_ids', $this->get_ids(), $this );
Expand Down Expand Up @@ -984,15 +993,15 @@ function () {
*
* Filters the nodes in the connection
*
* @param array $nodes The nodes in the connection
* @param array<int|string,mixed|\WPGraphQL\Model\Model|null> $nodes The nodes in the connection
* @param \WPGraphQL\Data\Connection\AbstractConnectionResolver $connection_resolver Instance of the Connection Resolver
*/
$this->nodes = apply_filters( 'graphql_connection_nodes', $this->get_nodes(), $this );

/**
* Filters the edges in the connection
*
* @param array $nodes The nodes in the connection
* @param array<int|string,mixed|\WPGraphQL\Model\Model|null> $nodes The nodes in the connection
* @param \WPGraphQL\Data\Connection\AbstractConnectionResolver $connection_resolver Instance of the Connection Resolver
*/
$this->edges = apply_filters( 'graphql_connection_edges', $this->get_edges(), $this );
Expand All @@ -1015,7 +1024,7 @@ function () {
*
* This filter allows additional fields to be returned to the connection resolver
*
* @param array $connection The connection data being returned
* @param array<string,mixed> $connection The connection data being returned
* @param \WPGraphQL\Data\Connection\AbstractConnectionResolver $connection_resolver The instance of the connection resolver
*/
return apply_filters( 'graphql_connection', $connection, $this );
Expand Down
Loading

0 comments on commit 6eb770b

Please sign in to comment.