Skip to content

Commit bd1627b

Browse files
committed
dev: cleanup and rename to groupLocation
1 parent 5eda24a commit bd1627b

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

src/Type/Enum/ScriptLoadingGroupEnum.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ public static function register_type() {
2222
register_graphql_enum_type(
2323
'ScriptLoadingGroupEnum',
2424
[
25-
'description' => __( 'Locations for script to be loaded', 'wp-graphql' ),
25+
'description' => __( 'Location in the document where the script to be loaded', 'wp-graphql' ),
2626
'values' => [
2727
'HEADER' => [
2828
'value' => 0,
29-
'description' => __( 'Script to be loaded in document `<head>` tags', 'wp-graphql' ),
29+
'description' => __( 'A script to be loaded in document `<head>` tag', 'wp-graphql' ),
3030
],
3131
'FOOTER' => [
3232
'value' => 1,
33-
'description' => __( 'Script to be loaded in document at right before the closing `<body>` tag', 'wp-graphql' ),
33+
'description' => __( 'A script to be loaded in document at right before the closing `<body>` tag', 'wp-graphql' ),
3434
],
3535
],
3636
]

src/Type/InterfaceType/EnqueuedAsset.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,10 @@ static function ( $before ) {
125125
},
126126
],
127127
'group' => [
128-
'type' => 'Integer',
128+
'type' => 'Int',
129129
'description' => __( 'The loading group to which this asset belongs.', 'wp-graphql' ),
130130
'resolve' => static function ( $asset ) {
131-
if ( ! isset( $asset->extra['group'] ) ) {
132-
return 0;
133-
}
134-
135-
return absint( $asset->extra['group'] );
131+
return isset( $asset->extra['group'] ) ? (int) $asset->extra['group'] : null;
136132
},
137133
],
138134
],

src/Type/ObjectType/EnqueuedScript.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ public static function register_type() {
2323
'description' => __( 'Script enqueued by the CMS', 'wp-graphql' ),
2424
'interfaces' => [ 'Node', 'EnqueuedAsset' ],
2525
'fields' => [
26-
'id' => [
26+
'id' => [
2727
'type' => [ 'non_null' => 'ID' ],
2828
'description' => __( 'The global ID of the enqueued script', 'wp-graphql' ),
2929
'resolve' => static function ( $asset ) {
3030
return isset( $asset->handle ) ? Relay::toGlobalId( 'enqueued_script', $asset->handle ) : null;
3131
},
3232
],
33-
'dependencies' => [
33+
'dependencies' => [
3434
'type' => [ 'list_of' => 'EnqueuedScript' ],
3535
'description' => __( 'Dependencies needed to use this asset', 'wp-graphql' ),
3636
],
37-
'extraData' => [
37+
'extraData' => [
3838
'type' => 'String',
3939
'description' => __( 'Extra data supplied to the enqueued script', 'wp-graphql' ),
4040
'resolve' => static function ( \_WP_Dependency $script ) {
@@ -45,7 +45,7 @@ public static function register_type() {
4545
return $script->extra['data'];
4646
},
4747
],
48-
'strategy' => [
48+
'strategy' => [
4949
'type' => 'ScriptLoadingStrategyEnum',
5050
'description' => __( 'The loading strategy to use on the script tag', 'wp-graphql' ),
5151
'resolve' => static function ( \_WP_Dependency $script ) {
@@ -56,18 +56,14 @@ public static function register_type() {
5656
return $script->extra['strategy'];
5757
},
5858
],
59-
'location' => [
59+
'groupLocation' => [
6060
'type' => 'ScriptLoadingGroupEnum',
6161
'description' => __( 'The location where this script should be loaded', 'wp-graphql' ),
6262
'resolve' => static function ( \_WP_Dependency $script ) {
63-
if ( ! isset( $script->extra['group'] ) ) {
64-
return 0;
65-
}
66-
67-
return absint( $script->extra['group'] );
63+
return isset( $script->extra['group'] ) ? (int) $script->extra['group'] : 0;
6864
},
6965
],
70-
'version' => [
66+
'version' => [
7167
'description' => __( 'The version of the enqueued script', 'wp-graphql' ),
7268
'resolve' => static function ( \_WP_Dependency $script ) {
7369
/** @var \WP_Scripts $wp_scripts */

0 commit comments

Comments
 (0)